edit_quality_testing.vue 17 KB

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