edit_quality_testing.vue 18 KB

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