edit_quality_testing.vue 17 KB

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