diff --git a/src/views/wpm_gx/inm_record_form.vue b/src/views/wpm_gx/inm_record_form.vue index dd4bf42d..f1bf47dc 100644 --- a/src/views/wpm_gx/inm_record_form.vue +++ b/src/views/wpm_gx/inm_record_form.vue @@ -46,6 +46,7 @@ filterable value-key="id" style="width: 100%;" + multiple @change="selectwmChange" > - - - + + + - + { console.log('res',res); @@ -294,42 +339,37 @@ export default { } console.log('arr',arr); if(arr.length>0){ - that.form.material = arr[0].material; - that.selectBatch = arr[0].id; - that.form.batch = arr[0].batch; - that.form.count = arr[0].count; - if(this.cate == 'do_out'){ - that.form.mb = arr[0].id; - that.form.warehouse = arr[0].warehouse; + // that.selectBatch = arr[0].id; + if(that.mode == "add"){ + that.selectBatch.push(arr[0].id); + let obj = {}; + obj.batch = arr[0].batch; + obj.warehouse = arr[0].warehouse; + obj.mb = arr[0].id; + obj.count = Number(arr[0].count); + if(this.cate == 'do_out'){ + obj.mb = arr[0].id; + obj.warehouse = arr[0].warehouse; + }else{ + obj.wm = arr[0].id; + } + that.selectList.push(obj); }else{ - that.form.wm = arr[0].id; + that.selectBatch = arr[0].id; + that.form.material = arr[0].material; + that.form.batch = arr[0].batch; + that.form.count = arr[0].count; + if(this.cate == 'do_out'){ + that.form.mb = arr[0].id; + that.form.warehouse = arr[0].warehouse; + }else{ + that.form.wm = arr[0].id; + } } }else{ that.$message.error("该批次不存在") } }) - // that.form.batch = id; - // let arr = []; - // if(this.cate == 'do_out'){//领料---仓库 - // arr = this.batchOptions.filter(item => item.batch == that.codeText); - // }else{//入库----工段 - // arr = this.wbatchOptions.filter(item => item.batch == that.codeText); - // } - // console.log('arr',arr); - // if(arr.length>0){ - // that.form.material = arr[0].material - // that.selectBatch = arr[0].id; - // that.form.batch = arr[0].batch; - // that.form.count = arr[0].count; - // if(this.cate == 'do_out'){ - // that.form.mb = arr[0].id; - // that.form.warehouse = arr[0].warehouse; - // }else{ - // that.form.wm = arr[0].id; - // } - // }else{ - // this.$message.warning("该物料没有库存"); - // } }, selectMaterialChange() { this.getBatchOptions(); @@ -341,28 +381,53 @@ export default { } } }, - selectBatchChange(id) { + selectBatchChange() { let that = this; + console.log('selectBatch',that.selectBatch); + that.selectList = []; that.batchOptions.forEach((item) => { - if(item.id == id){ - console.log('item',item); - this.form.batch = item.batch; - this.form.warehouse = item.warehouse; - this.form.mb = item.id; - that.form.count = Number(item.count); + console.log('indexOfselectBatch',that.selectBatch.indexOf(item.id)); + if(that.mode == "add"){//领料 + if(that.selectBatch.indexOf(item.id)>-1){ + let obj = {}; + console.log('item',item); + obj.batch = item.batch; + obj.warehouse = item.warehouse; + obj.mb = item.id; + obj.count = Number(item.count); + that.selectList.push(obj); + } + }else{ + if(item.id == id){ + that.form.batch = item.batch; + that.form.warehouse = item.warehouse; + that.form.mb = item.id; + that.form.count = Number(item.count); + } } }) }, //选择车间库存物料后的处理 selectwmChange(id){ let that = this; + that.selectList = []; that.wbatchOptions.forEach((item) => { - if(item.id == id){ - console.log('item',item); - that.form.batch = item.batch; - that.form.wm = item.id; - that.form.count = Number(item.count); - } + if(that.mode == "add"){//领料 + if(that.selectBatch.indexOf(item.id)>-1){ + let obj = {}; + console.log('item',item); + obj.batch = item.batch; + obj.wm = item.id; + obj.count = Number(item.count); + that.selectList.push(obj); + } + }else{ + if(item.id == id){ + that.form.batch = item.batch; + that.form.wm = item.id; + that.form.count = Number(item.count); + } + } }) }, selectBatchClear() { @@ -380,25 +445,37 @@ export default { }, //提交 submit() { - this.$refs.dialogForm.validate(async (valid) => { + let that = this; + that.$refs.dialogForm.validate(async (valid) => { if (valid) { - this.isSaveing = true; - this.form.mio = this.mioId; - try { - var res; - if (this.mode == "add") { - res = await this.$API.inm.mioitem.create.req(this.form); - } else if (this.mode == "edit") { - res = await this.$API.inm.mioitem.update.req(this.form.id,this.form); - } - this.isSaveing = false; - this.$emit("success"); - this.visible = false; - this.$message.success("操作成功"); - } catch (err) { - //可以处理校验错误 - this.isSaveing = false; - return err; + that.isSaveing = true; + that.form.mio = that.mioId; + if(that.mode == "add"){ + that.selectList.forEach((item) => { + let obj = {}; + obj = item; + obj.mio = that.mioId; + if(that.cate == 'do_out'){ + obj.material = that.form.material; + }else{ + obj.warehouse = that.form.warehouse; + } + that.$API.inm.mioitem.create.req(obj).then((res) => { + that.isSaveing = false; + that.$emit("success"); + that.visible = false; + }) + }) + }else{ + that.$API.inm.mioitem.update.req(that.form.id,that.form).then((res) => { + that.isSaveing = false; + that.$emit("success"); + that.visible = false; + that.$message.success("操作成功"); + }).then(() => { + that.isSaveing = false; + return err; + }) } } });