diff --git a/src/views/wpm_bx/mlogb_form.vue b/src/views/wpm_bx/mlogb_form.vue index 0748f605..44fc2fef 100644 --- a/src/views/wpm_bx/mlogb_form.vue +++ b/src/views/wpm_bx/mlogb_form.vue @@ -59,7 +59,7 @@ 提交 - 取消 + 取消 @@ -197,87 +197,67 @@ export default { }, //扫描后处理方法 formWminChange(code){ - let that = this,codeId='',keys="",arr=[]; + let that = this,codeId='',arr=[]; if(code.indexOf("#")>-1){ let arrs = code.split("#"); - keys = arrs[0]; codeId = arrs[1]; - that.scanKyes = keys; - if(keys=='wpr'){//个 - console.log('wpr',codeId) - that.form.parent = ''; - that.$API.wpm.wpr.item.req(codeId).then((res) => { - if(res){ - let bwitem = {}; - bwitem.mlogb=""; - bwitem.number=res.number; - bwitem.wpr=res.id; - arr = that.materialOptions.filter((item) => { - return item.id == res.wm; - }) - if (arr.length > 0) {//车间存在该批次 - let batch = arr[0].batch; - that.wm_in = arr[0].batch; - that.mlogbInCount = arr[0].count;//该批次数量 - //判断日志中是否存在该批次 - let arr0= that.mlogbIns.filter((item)=>{ - return item.batch == batch; - }) - if (arr0.length > 0) { - that.hasMlogbIn = true; - that.form.count_use = 1; - bwitem.mlogb = arr0[0].id; - }else{ - that.form.batch = arr[0].batch; - that.form.wm_in = arr[0].id; - that.form.count_use = 1; - that.wm_in = arr[0].batch; - } - that.bwItemForm = bwitem; - console.log('that.bwItemForm',that.bwItemForm) - }else{ - that.wm_in = ''; - that.$message.error("批次号不存在"); - } - } - }).catch((err) => {}) - }else{//批次 - this.$API.cm.labelmat.item.req(codeId).then((res) => { - if(res){ - arr = that.materialOptions.filter((item) => { - return item.batch == res.batch&&item.state==res.state; - }) - if (arr.length > 0) { - that.form.batch = arr[0].batch; - that.form.wm_in = arr[0].id; - that.form.count_use = arr[0].count; - that.wm_in = arr[0].batch; - }else{ - that.wm_in = ''; - that.$message.error("批次号不存在"); - } + that.scanKyes = arrs[0]; + this.$API.cm.labelmat.item.req(codeId).then((res) => { + if(res){ + arr = that.materialOptions.filter((item) => { + return item.batch == res.batch&&item.state==res.state; + }) + if (arr.length > 0) { + that.form.batch = arr[0].batch; + that.form.wm_in = arr[0].id; + that.form.count_use = arr[0].count; + that.wm_in = arr[0].batch; }else{ that.wm_in = ''; + that.$message.error("批次号不存在"); } - }).catch((err) => { + }else{ that.wm_in = ''; - that.$message.error("批次号不存在"); - }); - } - - }else{ - arr = that.materialOptions.filter((item) => { - return item.batch == code; - }) - if (arr.length > 0) { - that.form.batch = arr[0].batch; - that.form.wm_in = arr[0].id; - that.form.count_use = arr[0].count; - that.wm_in = arr[0].batch; - }else{ + } + }).catch((err) => { that.wm_in = ''; that.$message.error("批次号不存在"); - } + }); + }else{ + that.$API.wpm.wpr.list.req({number:code,page:0}).then((res) => { + if(res.length>0){ + let bwitem = {}; + bwitem.mlogb=""; + bwitem.number=res[0].number; + bwitem.wpr=res[0].id; + let arr = that.materialOptions.filter((item) => { + return item.id == res[0].wm; + }) + if(arr.length>0){ //车间存在该批次 + let batch = arr[0].batch; + that.wm_in = arr[0].batch; + that.mlogbInCount = arr[0].count;//该批次数量 + //判断日志中是否存在该批次 + let arr0= that.mlogbIns.filter((item)=>{ + return item.batch == batch; + }) + if (arr0.length > 0) { + that.hasMlogbIn = true; + that.form.count_use = 1; + bwitem.mlogb = arr0[0].id; + }else{ + that.form.batch = arr[0].batch; + that.form.wm_in = arr[0].id; + that.form.count_use = 1; + that.wm_in = arr[0].batch; + } + that.bwItemForm = bwitem; + }else{ + that.wm_in = ''; + that.$message.error("批次号不存在"); + } + } + }) } }, @@ -305,7 +285,7 @@ export default { that.form.batch = ''; that.form.parent = ''; that.form.count_use = 0; - if(that.scanKyes=='wpr'&&that.mlogbInCount>1){ + if(that.scanKyes!=='mat'&&that.mlogbInCount>1){ //当批次数量不为1时 that.bwItemForm.mlogb = res.id; that.$API.wpm.mlogbw.create.req(that.bwItemForm).then((res) => {})