add_quality_testing.vue 18 KB

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