From 52b8d2764f67b126eee796023586652cb2d66832 Mon Sep 17 00:00:00 2001 From: shijing Date: Fri, 30 May 2025 13:58:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=97=A0=E8=81=8A=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E5=8F=AA=E8=A6=81=E8=A1=A8=E5=8D=95=E4=B8=AD=E7=9A=84=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/mtm/materials_form_gx.vue | 70 +++++++++++++++++------------ 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/src/views/mtm/materials_form_gx.vue b/src/views/mtm/materials_form_gx.vue index 9aae81c6..9990e240 100644 --- a/src/views/mtm/materials_form_gx.vue +++ b/src/views/mtm/materials_form_gx.vue @@ -255,41 +255,55 @@ export default { }, //提交 submit() { - this.$refs.dialogForm.validate(async (valid) => { + let that = this; + that.$refs.dialogForm.validate(async (valid) => { if (valid) { - this.isSaveing = true; - if (this.mode == "add") { - this.$API.mtm.material.create - .req(this.form) - .then((res) => { - this.isSaveing = false; - this.$emit("success", this.form, this.mode); - this.visible = false; - this.$message.success("操作成功"); - }) - .catch(() => { - this.isSaveing = false; - this.visible = false; - }); - } else if (this.mode == "edit") { - this.$API.mtm.material.update - .req(this.form.id, this.form) - .then((res) => { - this.isSaveing = false; - this.$emit("success", this.form, this.mode); - this.visible = false; - this.$message.success("操作成功"); - }) - .catch(() => { - this.isSaveing = false; - }); + that.isSaveing = true; + if (that.mode == "add") { + that.$API.mtm.material.create.req(that.form).then((res) => { + that.isSaveing = false; + that.$emit("success", that.form, that.mode); + that.visible = false; + that.$message.success("操作成功"); + }) + .catch(() => { + that.isSaveing = false; + that.visible = false; + }); + } else if (that.mode == "edit") { + that.$API.mtm.material.update.req(that.form.id, that.form).then((res) => { + that.isSaveing = false; + that.$emit("success", that.form, that.mode); + that.visible = false; + that.$message.success("操作成功"); + }) + .catch(() => { + that.isSaveing = false; + }); } } }); }, //表单注入数据 setData(data) { - Object.assign(this.form, data); + let that = this; + if(that.mode=="add"){ + that.form.name = data.name; + that.form.type = data.type; + that.form.number = data.number; + that.form.specification = data.specification; + that.form.model = data.model; + that.form.unit = data.unit; + that.form.process = data.process; + that.form.tracking = data.tracking; + that.form.count_safe = data.count_safe; + that.form.is_hidden = data.is_hidden; + that.form.unit_price = data.unit_price; + that.form.photo = data.photo; + that.form.photo_number = data.photo_number; + }else{ + Object.assign(this.form, data); + } this.getMaterial(data.type); },