diff --git a/src/views/qm/product_form.vue b/src/views/qm/product_form.vue index af85cf43..1e32decc 100644 --- a/src/views/qm/product_form.vue +++ b/src/views/qm/product_form.vue @@ -16,24 +16,19 @@ > - - - - - + + + + + @@ -104,6 +99,7 @@ export default { emits: ["success", "closed"], data() { return { + apiObjBatch:this.$API.inm.warehouse.batch, apiUserObj: this.$API.system.user.list, loading: false, form: { @@ -126,6 +122,7 @@ export default { }, ], }, + selectBatch:null, visible: false, isSaveing: false, options: [], @@ -170,46 +167,38 @@ export default { that.options = res; }); }, - handleChange(val) { + handleBatchChange() { let that = this; - console.log(val); - that.options.forEach((item) => { - if (item.id == val) { - that.form.count = item.count; - that.form.batch = item.batch; - that.form.material = item.material; - that.form.mb = item.id; - } - }); + that.form.count = that.selectBatch.count; + that.form.batch = that.selectBatch.batch; + that.form.material = that.selectBatch.material; + that.form.mb = that.selectBatch.id; }, //提交 submit() { - this.$refs.dialogForm.validate(async (valid) => { + let that = this; + that.$refs.dialogForm.validate(async (valid) => { if (valid) { - this.isSaveing = true; + that.isSaveing = true; try { - if (this.mode == "add") { - this.$API.qm.ftestwork.create - .req(this.form) - .then((res) => { - this.isSaveing = false; - this.visible = false; - this.$emit("success"); - this.$message.success("操作成功"); - }); - } else if (this.mode == "edit") { - this.$API.qm.ftestwork.update - .req(this.form.id, this.form) - .then((res) => { - this.isSaveing = false; - this.visible = false; - this.$emit("success"); - this.$message.success("操作成功"); - }); + if (that.mode == "add") { + that.$API.qm.ftestwork.create.req(that.form).then((res) => { + that.isSaveing = false; + that.visible = false; + that.$emit("success"); + that.$message.success("操作成功"); + }).catch(err => {that.isSaveing = false;}); + } else if (that.mode == "edit") { + that.$API.qm.ftestwork.update.req(that.form.id, that.form).then((res) => { + that.isSaveing = false; + that.visible = false; + that.$emit("success"); + that.$message.success("操作成功"); + }).catch(err => {that.isSaveing = false;}); } } catch (err) { //可以处理校验错误 - this.isSaveing = false; + that.isSaveing = false; return err; } }