edit_quality_testing.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. <template>
  2. <view>
  3. <view class='wrap'>
  4. <view class='title_b'>基本信息</view>
  5. <view class="c-row ">
  6. <view class="title">仓库</view>
  7. <view class="con-list">
  8. {{gridList.warehouseName}}
  9. </view>
  10. </view>
  11. <view class="c-row ">
  12. <view class="title">编号</view>
  13. <view class="con-list">
  14. {{gridList.qualityNo}}
  15. </view>
  16. </view>
  17. <view class="c-row ">
  18. <view class="title">客户</view>
  19. <view class="con-list">
  20. {{gridList.customerName}}({{gridList.customerPhone}})
  21. </view>
  22. </view>
  23. <view class="c-row ">
  24. <view class="title">车牌号</view>
  25. <view class="con-list">
  26. <input :disabled='flag==1' v-model='gridList.carNumber' placeholder="请输入车牌号" name="input"></input>
  27. </view>
  28. </view>
  29. <view v-if="gridList.paramType != '1'" class="c-row ">
  30. <view class="title">扣重比</view>
  31. <view class="con-list">
  32. <input :disabled='flag==1' v-model='gridList.buckleWeightRatio' placeholder="请输入扣重比"
  33. name="input"></input>
  34. </view>
  35. </view>
  36. <view v-else class="c-row ">
  37. <view class="title">扣杂</view>
  38. <view class="con-list">
  39. <input :disabled='flag==1' v-model='gridList.buckleMiscellaneous' placeholder="初检扣杂"
  40. @input="waterContentChange" name="input"></input>
  41. <input v-if='flag==0' value='未复检' disabled placeholder="复检扣杂" name="input"></input>
  42. <input v-else :disabled='flag!=1' v-model='gridList.reBuckleMiscellaneous' placeholder="复检扣杂"
  43. name="input"></input>
  44. </view>
  45. </view>
  46. <view class="c-row ">
  47. <view class="title">购粮性质</view>
  48. <view class="con-list">
  49. <input :disabled='flag==1' v-model='gridList.natureOfGrainPurchase' placeholder="请输入购粮性质"
  50. name="input"></input>
  51. </view>
  52. </view>
  53. <view class="c-row ">
  54. <view class="title">仓位号</view>
  55. <view class="con-list">
  56. <u-picker :range="warehouseList" range-key="binNumber" @confirm='binNumberpicker($event)'
  57. v-model="show" mode="selector">
  58. </u-picker>
  59. <view v-if='flag!=1' @click='show=true'>{{gridList.binNumber}}</view>
  60. <view v-else>{{gridList.binNumber}}</view>
  61. </view>
  62. </view>
  63. <view class="c-row ">
  64. <view class="title">囤位号</view>
  65. <view class="con-list">
  66. <input :disabled='flag==1' v-model='gridList.storageTagNo' placeholder="请输入囤位号"
  67. name="input"></input>
  68. </view>
  69. </view>
  70. <view class="c-row ">
  71. <view class="title">货名</view>
  72. <view class="con-list">
  73. {{gridList.goodsName}}
  74. </view>
  75. </view>
  76. <view class="c-row ">
  77. <view class="title">类型</view>
  78. <view class="con-list">
  79. {{gridList.type}}
  80. </view>
  81. </view>
  82. <view v-if="gridList.type == '潮粮'" class="c-row">
  83. <view class="title">净重单价(元/公斤)</view>
  84. <view class="con-list">
  85. <input :disabled='flag==1' v-model='gridList.tidalGrainPrice' disabled placeholder="自动获取,不可编辑"
  86. name="input"></input>
  87. </view>
  88. </view>
  89. <view v-if="gridList.type == '干粮'" class="c-row">
  90. <view class="title">干粮单价(元/公斤)</view>
  91. <view class="con-list">
  92. <input v-model='gridList.dryGrainPrice' placeholder="请输入干粮单价" name="input"></input>
  93. </view>
  94. </view>
  95. </view>
  96. <view style='padding-bottom:300rpx;'>
  97. <view class='wrap'>
  98. <view class='title_b'>化验信息</view>
  99. <view class="c-row ">
  100. <view class="title">等级</view>
  101. <view class="con-list">
  102. <u-picker :range="gradeList" range-key="value" @confirm='gradepicker($event)' v-model="show1"
  103. mode="selector">
  104. </u-picker>
  105. <view v-if='flag!=1' @click='show1=true'>{{gridList.grade?gridList.grade:'请选择等级'}}</view>
  106. <view v-else>{{gridList.grade}}</view>
  107. </view>
  108. </view>
  109. <view class="c-row ">
  110. <view class="title">水分(%)</view>
  111. <view class="con-list">
  112. <input :disabled='flag==1' v-model='gridList.waterContent' placeholder="初检水分"
  113. @input="waterContentChange" name="input"></input>
  114. <input v-if='flag==0' value='未复检' disabled placeholder="复检水分" name="input"></input>
  115. <input :disabled='flag!=1' v-else v-model='gridList.reWaterContent' placeholder="复检水分"
  116. name="input"></input>
  117. </view>
  118. </view>
  119. <view class="c-row ">
  120. <view class="title">容重(克/升)</view>
  121. <view class="con-list">
  122. <input :disabled='flag==1' v-model='gridList.bulkDensity' placeholder="请输入容重"
  123. name="input"></input>
  124. </view>
  125. </view>
  126. <view class="c-row ">
  127. <view class="title">不完善粒(%)</view>
  128. <view class="con-list">
  129. <input :disabled='flag==1' v-model='gridList.imperfectGrain' placeholder="请输入不完整粒占比"
  130. name="input"></input>
  131. </view>
  132. </view>
  133. <view class="c-row ">
  134. <view class="title">杂质(%)</view>
  135. <view class="con-list">
  136. <input :disabled='flag==1' v-model='gridList.impurity' placeholder="请输入杂质占比"
  137. name="input"></input>
  138. </view>
  139. </view>
  140. <view class="c-row ">
  141. <view class="title">霉变粒(%)</view>
  142. <view class="con-list">
  143. <input :disabled='flag==1' v-model='gridList.mildewGrain' placeholder="请输入霉变粒占比"
  144. name="input"></input>
  145. </view>
  146. </view>
  147. <view class="c-row ">
  148. <view class="title">热损伤(%)</view>
  149. <view class="con-list">
  150. <input :disabled='flag==1' v-model='gridList.jiaorenli' placeholder="请输入热损伤占比"
  151. name="input"></input>
  152. </view>
  153. </view>
  154. </view>
  155. </view>
  156. <view class="footer">
  157. <view @click='submit' class="button">提交</view>
  158. </view>
  159. </view>
  160. </template>
  161. <script>
  162. import dragButton from "@/components/drag-button/drag-button.vue";
  163. import {
  164. mapState
  165. } from 'vuex';
  166. let startY = 0,
  167. moveY = 0,
  168. pageAtTop = true;
  169. export default {
  170. components: {
  171. dragButton
  172. },
  173. data() {
  174. return {
  175. inputShow: false,
  176. modalName: '',
  177. mycarStyle: '',
  178. feild: undefined,
  179. id: 0,
  180. show: false,
  181. selector: [],
  182. show1: false,
  183. inputContent: '',
  184. coverTransform: 'translateY(0px)',
  185. coverTransition: '0s',
  186. moving: false,
  187. footprintList: [],
  188. searchKeyWord: '',
  189. isVip: false,
  190. flag: 0,
  191. userInfoTmp: [],
  192. inputStatus: 'none',
  193. carInfo: [],
  194. gridCol: 4,
  195. pageSize: 10,
  196. currentPage: 1,
  197. gridBorder: false,
  198. headUrl: "../../static/img/myimg/YongHu@3x.png",
  199. userphone: "",
  200. username: "请更改昵称",
  201. gridList: {
  202. natureOfGrainPurchase: '贸易粮',
  203. type: '潮粮',
  204. tidalGrainPrice: '',
  205. dryGrainPrice: ''
  206. },
  207. managementType: '',
  208. warehouseName: '',
  209. warehouseList: [],
  210. showTran: true,
  211. companyId: 1,
  212. current: 4,
  213. gradeList: [{
  214. key: 1,
  215. value: '一等品'
  216. },
  217. {
  218. key: 2,
  219. value: '二等品'
  220. },
  221. {
  222. key: 3,
  223. value: '三等品'
  224. },
  225. {
  226. key: 4,
  227. value: '等外'
  228. },
  229. ],
  230. cangid: ''
  231. }
  232. },
  233. // #ifndef MP
  234. onNavigationBarButtonTap(e) {
  235. const index = e.index;
  236. if (index === 0) {
  237. this.navTo('/pages/set/set');
  238. } else if (index === 1) {
  239. // #ifdef APP-PLUS
  240. const pages = getCurrentPages();
  241. const page = pages[pages.length - 1];
  242. const currentWebview = page.$getAppWebview();
  243. currentWebview.hideTitleNViewButtonRedDot({
  244. index
  245. });
  246. // #endif
  247. uni.navigateTo({
  248. url: '/pages/notice/notice'
  249. })
  250. }
  251. },
  252. // #endif
  253. computed: {
  254. ...mapState(['hasLogin', 'userInfo']),
  255. // 手机号中间4位加*
  256. starUserphone() {
  257. let reg = /^(\d{3})\d{4}(\d{4})$/;
  258. if (this.userphone) {
  259. return this.userphone.replace(reg, "$1****$2");
  260. }
  261. }
  262. },
  263. onLoad(options) {
  264. this.id = options.id
  265. this.flag = options.flag
  266. this.cangid = options.cangid
  267. this.managementType = options.managementType
  268. },
  269. onShow() {
  270. var that = this
  271. this.$api.doRequest('get', '/qualityInspectionManagement/api/getQualityInspection', {
  272. id: this.id
  273. }).then(res => {
  274. if (res.data.data) {
  275. let data = res.data.data
  276. that.gridList = data
  277. that.$api.doRequest('get', '/warehouseBaseInfo/getWarehouse', {
  278. id: this.cangid
  279. }).then(res => {
  280. that.warehouseList = res.data.data.warehousePositionInfoList
  281. })
  282. }
  283. })
  284. this.gridList.grade = this.gradeList[0].value
  285. this.gridList.gradeKey = this.gradeList[0].key
  286. },
  287. methods: {
  288. waterContentChange() {
  289. var that = this
  290. if (this.gridList.goodsName && this.cangid) {
  291. if (!this.gridList.dryGrainPrice || this.gridList.dryGrainPrice == 0) {
  292. this.$api.doRequest('get', '/purchasePrice/dryGrainPrice', {
  293. warehouseId: this.cangid,
  294. goodsName: this.gridList.goodsName
  295. }).then(res => {
  296. that.gridList.dryGrainPrice = res.data.data
  297. })
  298. }
  299. }
  300. if (this.gridList.goodsName) {
  301. for (var i = 0; i < this.purchasePriceList.length; i++) {
  302. if (this.purchasePriceList[i].goodsName == this.gridList.goodsName) {
  303. this.gridList.buckleWeightRatio = this.purchasePriceList[i].deductWeight
  304. this.gridList.paramType = this.purchasePriceList[i].paramType
  305. }
  306. }
  307. }
  308. var numReg = /^[0-9]*$/
  309. var numRe = new RegExp(numReg)
  310. //潮粮单价改变事件
  311. if (
  312. this.gridList.goodsName &&
  313. this.gridList.waterContent &&
  314. this.gridList.grade &&
  315. numRe.test(this.gridList.waterContent)
  316. ) {
  317. this.$api.doRequest('get', '/purchasePrice/tidalGrainPrice', {
  318. warehouseId: this.cangid,
  319. goodsName: this.gridList.goodsName,
  320. waterContent: this.gridList.waterContent,
  321. grade: this.gridList.grade,
  322. }).then(res => {
  323. if (that.gridList.paramType == '1') {
  324. that.gridList.tidalGrainPrice = parseFloat(parseFloat(res.data.data) - parseFloat(that
  325. .gridList.buckleMiscellaneous) / 100 * parseFloat(that.gridList
  326. .dryGrainPrice)).toFixed(4)
  327. if (!that.gridList.tidalGrainPrice) {
  328. that.gridList.tidalGrainPrice = ''
  329. }
  330. } else {
  331. that.gridList.tidalGrainPrice = res.data.data
  332. }
  333. })
  334. }
  335. },
  336. submit() {
  337. this.gridList.flag = this.flag
  338. // if(this.flag==2){
  339. // this.gridList.reInspector=this.userInfo.userName
  340. // }
  341. var that = this
  342. if (!this.gridList.qualityNo) {
  343. this.$api.msg('编号不能为空')
  344. return
  345. }
  346. if (!this.gridList.binNumber) {
  347. this.$api.msg('仓位不能为空')
  348. return
  349. }
  350. if (!this.gridList.customerName) {
  351. this.$api.msg('客户不能为空')
  352. return
  353. }
  354. if (!this.gridList.storageTagNo) {
  355. this.$api.msg('囤位号不能为空')
  356. return
  357. }
  358. if (this.gridList.storageTagNo.length > 10) {
  359. this.$api.msg('囤位号不能为空')
  360. return
  361. }
  362. if (!this.gridList.carNumber) {
  363. this.$api.msg('车牌号不能为空')
  364. return
  365. }
  366. if (this.gridList.carNumber.length > 7) {
  367. this.$api.msg('车牌号输入错误')
  368. return
  369. }
  370. if (!this.gridList.goodsName) {
  371. this.$api.msg('货名不能为空')
  372. return
  373. }
  374. if (this.gridList.paramType != 1 && this.gridList.buckleWeightRatio < 0 || this.gridList.paramType != 1 &&
  375. this.gridList.buckleWeightRatio > 2) {
  376. this.$api.msg('扣重比输入错误')
  377. return
  378. }
  379. if (
  380. this.gridList.paramType != 1 && String(this.gridList.buckleWeightRatio).indexOf('.') != -1 &&
  381. String(this.gridList.buckleWeightRatio).length -
  382. (String(this.gridList.buckleWeightRatio).indexOf('.') + 1) > 2) {
  383. this.$api.msg('扣重比输入错误')
  384. return
  385. }
  386. if (this.flag == 0 && this.gridList.paramType == 1 && this.gridList.buckleMiscellaneous < 0 || this.flag ==
  387. 0 && this.gridList.paramType == 1 && this.gridList.buckleMiscellaneous > 50) {
  388. this.$api.msg('初检扣杂输入错误')
  389. return
  390. }
  391. if (this.flag == 1 && this.gridList.paramType == 1 && this.gridList.reBuckleMiscellaneous < 0 || this
  392. .flag == 0 && this.gridList.paramType == 1 && this.gridList.reBuckleMiscellaneous > 50) {
  393. this.$api.msg('复检扣杂输入错误')
  394. return
  395. }
  396. if (!this.gridList.type) {
  397. this.$api.msg('类型不能为空')
  398. return
  399. }
  400. if (!this.gridList.natureOfGrainPurchase) {
  401. this.$api.msg('购粮性质不能为空')
  402. return
  403. }
  404. if (!this.gridList.grade) {
  405. this.$api.msg('等级不能为空')
  406. return
  407. }
  408. if (!this.gridList.impurity) {
  409. this.$api.msg('杂质不能为空')
  410. return
  411. }
  412. if (!this.gridList.waterContent) {
  413. this.$api.msg('初检水分不能为空')
  414. return
  415. }
  416. if (!this.gridList.reWaterContent) {
  417. this.$api.msg('复检水分不能为空')
  418. return
  419. }
  420. if (!this.gridList.mildewGrain) {
  421. this.$api.msg('霉变粒不能为空')
  422. return
  423. }
  424. if (!this.gridList.bulkDensity) {
  425. this.$api.msg('容重不能为空')
  426. return
  427. }
  428. if (!this.gridList.jiaorenli) {
  429. this.$api.msg('热损伤不能为空')
  430. return
  431. }
  432. if (!this.gridList.imperfectGrain) {
  433. this.$api.msg('不完整粒不能为空')
  434. return
  435. }
  436. uni.showModal({
  437. content: "确定提交质检信息?",
  438. showCancel: true,
  439. confirmText: '提交',
  440. success: function(res) {
  441. if (res.confirm) {
  442. that.$api.doRequest('post',
  443. '/qualityInspectionManagement/api/editQualityInspection', that.gridList)
  444. .then(res => {
  445. if (res.data.code == 200) {
  446. that.$api.msg('编辑质检成功')
  447. uni.navigateBack({})
  448. }
  449. })
  450. }
  451. }
  452. })
  453. },
  454. gradepicker(e) {
  455. console.log(e)
  456. // this.$set(this.gradeList,'grade',this.gradeList[e[0]].value)
  457. this.gridList.grade = this.gradeList[e[0]].value
  458. this.gridList.gradeKey = this.gradeList[e[0]].key
  459. this.waterContentChange()
  460. },
  461. binNumberpicker(e) {
  462. this.gridList.binNumber = this.warehouseList[e[0]].binNumber
  463. },
  464. del(item) {
  465. this.$api.doRequest('get', '/qualityInspectionManagement/api/deleteQualityInspection', {
  466. id: item.id
  467. }).then(res => {
  468. if (res.data.code == 200) {
  469. this.$api.msg('删除成功')
  470. } else {
  471. this.$api.msg('系统异常,请联系管理员')
  472. }
  473. })
  474. },
  475. contactUs() {
  476. const that = this
  477. uni.makePhoneCall({
  478. // 手机号
  479. phoneNumber: '18241771147',
  480. // 成功回调
  481. success: (res) => {},
  482. // 失败回调
  483. fail: (res) => {}
  484. });
  485. },
  486. loadData() {
  487. // const that = this
  488. // if(uni.getStorageSync("PageCur")){
  489. // that.PageCur = uni.getStorageSync("PageCur");
  490. // }
  491. // that.userInfoTmp = uni.getStorageSync("userInfo")
  492. // uni.showLoading({
  493. // title: '正在加载',
  494. // mask:true
  495. // })
  496. // that.$api.request('integral', 'getIndexData', failres => {
  497. // that.$api.msg(failres.errmsg)
  498. // uni.hideLoading()
  499. // }).then(res => {
  500. // let data = res.data
  501. // uni.setStorageSync("message", data.message);
  502. // uni.setStorageSync("task", data.task);
  503. // uni.setStorageSync("contract", data.contract);
  504. // uni.setStorageSync('showTran', data.showTran);
  505. // that.showTran = data.showTran
  506. // that.gridList[4].tips = data.task
  507. // that.gridList[2].tips = data.contract
  508. // that.companyId = data.companyId
  509. // uni.hideLoading()
  510. // })
  511. },
  512. confirm() {
  513. const that = this
  514. if (!that.inputContent) {
  515. that.$api.msg('输入不能为空')
  516. return
  517. }
  518. let obj = {}
  519. obj[that.feild] = that.inputContent
  520. that.$api.request('user', 'syncUserInfo', obj).then(res => {
  521. that.userInfo.nickname = that.inputContent
  522. that.inputContent = ''
  523. that.$store.commit('login', that.userInfo)
  524. })
  525. },
  526. cancel() {
  527. this.inputShow = false
  528. this.inputStatus = 'none'
  529. this.genderShow = false
  530. },
  531. myAccount() {
  532. uni.navigateTo({
  533. url: `/pageA/pages/contract`
  534. })
  535. },
  536. /**
  537. * 统一跳转接口,拦截未登录路由
  538. * navigator标签现在默认没有转场动画,所以用view
  539. */
  540. navTo(url) {
  541. if (!this.hasLogin) {
  542. url = '/pages/public/login';
  543. }
  544. uni.navigateTo({
  545. url
  546. })
  547. },
  548. mycarClick(carNo) {
  549. this.modalName = null
  550. uni.navigateTo({
  551. url: `/pageB/car/mycar_detail?carNo=${carNo}`
  552. })
  553. },
  554. scanCode() {
  555. uni.scanCode({
  556. success: function(res) {
  557. uni.navigateTo({
  558. url: res.result
  559. })
  560. }
  561. })
  562. },
  563. hideModal(e) {
  564. this.modalName = null
  565. },
  566. }
  567. }
  568. </script>
  569. <style lang='scss' scoped>
  570. .title_b {
  571. margin: 20rpx 20rpx 0rpx 20rpx;
  572. padding: 20rpx 10rpx 20rpx 10rpx;
  573. font-size: 18px;
  574. font-weight: 550;
  575. }
  576. page {
  577. background: #F5F6FA;
  578. }
  579. .wrap {
  580. padding-bottom: 10px;
  581. font-size: 14px;
  582. background: #fff;
  583. margin: 10px;
  584. border-radius: 10px;
  585. input {
  586. font-size: 14px;
  587. }
  588. >.title {
  589. padding: 10px 16px;
  590. }
  591. .b-b:after {
  592. border-bottom: 1px solid #eee;
  593. }
  594. }
  595. .footer {
  596. background: #fff;
  597. position: fixed;
  598. bottom: 0;
  599. width: 100%;
  600. padding: 20px 10px;
  601. z-index: 10;
  602. .button {
  603. background: #22C572;
  604. width: 90%;
  605. margin: 0 auto;
  606. padding: 10px;
  607. color: #fff;
  608. text-align: center;
  609. border-radius: 30px;
  610. }
  611. }
  612. .c-row {
  613. display: -webkit-box;
  614. display: -webkit-flex;
  615. display: flex;
  616. -webkit-box-align: center;
  617. -webkit-align-items: center;
  618. align-items: center;
  619. padding: 20rpx 30rpx;
  620. position: relative;
  621. }
  622. .con-list {
  623. -webkit-box-flex: 1;
  624. -webkit-flex: 1;
  625. flex: 1;
  626. display: -webkit-box;
  627. display: -webkit-flex;
  628. display: flex;
  629. -webkit-box-orient: vertical;
  630. -webkit-box-direction: normal;
  631. -webkit-flex-direction: column;
  632. flex-direction: column;
  633. color: #303133;
  634. line-height: 40rpx;
  635. text-align: right;
  636. padding-right: 20rpx;
  637. }
  638. input:disabled {
  639. color: #ccc;
  640. }
  641. </style>