From 7831d87869caab96f072e2efa67b1ecef65c3617 Mon Sep 17 00:00:00 2001 From: shijing Date: Wed, 15 Jan 2025 15:51:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:mlogb=E4=B8=AD=E6=89=B9=E6=AC=A1=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=89=AB=E7=A0=81=EF=BC=88wm||wb=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/wpm_bx/mlogb_form.vue | 86 +++++++++++++++++++++++++++------ 1 file changed, 70 insertions(+), 16 deletions(-) diff --git a/src/views/wpm_bx/mlogb_form.vue b/src/views/wpm_bx/mlogb_form.vue index 8347fb51..bb941ad1 100644 --- a/src/views/wpm_bx/mlogb_form.vue +++ b/src/views/wpm_bx/mlogb_form.vue @@ -121,10 +121,13 @@ export default { ] }, wm_in:'', + mlogbIns:[], options: [], mlogbInOptions:[], materialOptions: [], mgroup_code:'', + mlogbInId:'', + hasMlogbIn:false, visible: false, isSaveing: false, setFiltersVisible: false, @@ -140,6 +143,7 @@ export default { this.params.mlog = this.mlog; let arr = this.$route.path.split("/"); this.mgroup_code = arr[2]; + this.getMlogbIn(); this.getMtask(); this.getMaterial(); this.getParentList(); @@ -148,6 +152,16 @@ export default { open() { this.visible = true; }, + getMlogbIn(){ + let that = this; + let params = {}; + params.page= 0; + params.mlog= that.mlog; + params.material_in__isnull=0; + this.$API.wpm.mlogb.list.req(params).then((res) => { + that.mlogbIns = res; + }) + }, getParentList(){ let that = this; that.$API.wpm.mlogb.list.req(that.params).then((res) => { @@ -188,17 +202,40 @@ export default { let arrs = code.split("#"); keys = arrs[0]; codeId = arrs[1]; + that.scanKyes = keys; if(keys=='wpr'){//个 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) { - that.form.batch = arr[0].batch; - that.form.wm_in = arr[0].id; - that.form.count_use = arr[0].count; + if (arr.length > 0) {//车间存在该批次 + let batch = arr[0].batch; that.wm_in = arr[0].batch; + that.form.count_use =1; + console.log('batch',batch); + //判断日志中是否存在该批次 + let arr0= that.mlogbIns.filter((item)=>{ + return item.batch == batch; + }) + console.log('arr0',arr0) + if (arr0.length > 0) { + that.hasMlogbIn = true; + bwitem.mlogb = arr0[0].id; + that.form.parent = ''; + console.log('bwitem',bwitem) + }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("批次号不存在"); @@ -248,18 +285,35 @@ export default { //表单提交方法 submit() { let that = this; - that.form.mlog = that.mlog; - that.$API.wpm.mlogb.in.req(that.form).then((res) => { - that.$message.success("添加成功"); - that.$emit("success"); - that.wm_in = ''; - that.form.mtask = ''; - that.form.batch = ''; - that.form.parent = ''; - that.form.count_use = 0; - that.$emit("closed"); - that.visible = false; - }).catch((err) => {}); + if(that.hasMlogbIn){ + that.$API.wpm.mlogbw.create.req(that.bwItemForm).then((res) => { + that.$message.success("添加成功"); + that.wm_in = ''; + that.form.mtask = ''; + that.form.batch = ''; + that.form.parent = ''; + that.form.count_use = 0; + that.$emit("closed"); + that.visible = false; + }) + }else{ + that.form.mlog = that.mlog; + that.$API.wpm.mlogb.in.req(that.form).then((res) => { + that.$message.success("添加成功"); + that.$emit("success"); + that.wm_in = ''; + that.form.mtask = ''; + that.form.batch = ''; + that.form.parent = ''; + that.form.count_use = 0; + if(that.scanKyes=='wpr'){ + that.bwItemForm.mlogb = res.id; + that.$API.wpm.mlogbw.create.req(that.bwItemForm).then((res) => {}) + } + that.$emit("closed"); + that.visible = false; + }).catch((err) => {}); + } }, //设置过滤项 setFilters(filters) {