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); },