fix:无聊复制只要表单中的字段

This commit is contained in:
shijing 2025-05-30 13:58:38 +08:00
parent 23fdd0f466
commit 52b8d2764f
1 changed files with 42 additions and 28 deletions

View File

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