商品信息
parent
456cf765be
commit
37d367fdaf
|
@ -400,7 +400,8 @@ export default {
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
name: [
|
name: [
|
||||||
{ required: true, message: "商品名称不能为空", trigger: "blur" }
|
{required: true, message: '请输入商品名称', trigger: 'blur'},
|
||||||
|
{min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'}
|
||||||
],
|
],
|
||||||
unit: [
|
unit: [
|
||||||
{ required: true, message: "单位不能为空", trigger: "blur" }
|
{ required: true, message: "单位不能为空", trigger: "blur" }
|
||||||
|
@ -671,22 +672,28 @@ export default {
|
||||||
submitForm() {
|
submitForm() {
|
||||||
this.$refs["form"].validate(valid => {
|
this.$refs["form"].validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
// 表单校验通过,执行提交逻辑
|
||||||
let typeIds = this.form.type.join(',');
|
let typeIds = this.form.type.join(',');
|
||||||
let type = this.form.type[this.form.type - 1];
|
let type = this.form.type[this.form.type - 1];
|
||||||
this.form.typeIds = typeIds;
|
this.form.typeIds = typeIds;
|
||||||
this.form.type = type;
|
this.form.type = type;
|
||||||
this.form.step = this.active
|
this.form.step = this.active;
|
||||||
|
|
||||||
this.form["skuInfoList"] = this.tableBodyTemplate;
|
this.form["skuInfoList"] = this.tableBodyTemplate;
|
||||||
|
|
||||||
if (this.form.id != null) {
|
if (this.form.id != null) {
|
||||||
this.updateInfoById(this.form)
|
// 如果表单已存在 ID,则执行更新操作
|
||||||
|
this.updateInfoById(this.form);
|
||||||
} else {
|
} else {
|
||||||
|
// 否则执行新增操作
|
||||||
addInfo(this.form).then(response => {
|
addInfo(this.form).then(response => {
|
||||||
this.$modal.msgSuccess("新增成功");
|
this.$modal.msgSuccess("新增成功");
|
||||||
this.open = false;
|
this.open = false;
|
||||||
this.getList();
|
this.getList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// 表单校验失败,显示错误提示信息
|
||||||
|
this.$message.error("表单校验失败,请检查输入内容");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue