diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplTreeVue.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplTreeVue.txt index 945d742..c49dc94 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplTreeVue.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplTreeVue.txt @@ -105,6 +105,7 @@ $end }, // 弹出层标题 title: "", + // 操作类型 1、add 2、edit // 是否显示弹出层 open: false, // 是否展开,默认全部折叠 @@ -245,6 +246,7 @@ $end this.reset(); this.open = true; this.title = "添加"; + this.opertype = 1; }, /** 删除按钮操作 */ handleDelete(row) { @@ -269,6 +271,7 @@ $end if (code == 200) { this.open = true; this.title = "修改数据"; + this.opertype = 2; this.form = { ...data, @@ -327,7 +330,7 @@ $end $end console.log(JSON.stringify(this.form)); - if (this.form.${replaceDto.FistLowerPk} != undefined && this.title === "修改数据") { + if (this.form.${replaceDto.FistLowerPk} != undefined && this.opertype === 2) { update${genTable.BusinessName}(this.form) .then((res) => { this.msgSuccess("修改成功"); diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVue.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVue.txt index 13f8e5b..5419adf 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVue.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVue.txt @@ -102,6 +102,8 @@ $end }, // 弹出层标题 title: "", + // 操作类型 1、add 2、edit + opertype: 0, // 是否显示弹出层 open: false, // 表单参数 @@ -240,6 +242,7 @@ $end this.reset(); this.open = true; this.title = "添加"; + this.opertype = 1; }, /** 删除按钮操作 */ handleDelete(row) { @@ -264,6 +267,7 @@ $end if (code == 200) { this.open = true; this.title = "修改数据"; + this.opertype = 2; this.form = { ...data, @@ -322,7 +326,7 @@ $end $end console.log(JSON.stringify(this.form)); - if (this.form.${replaceDto.FistLowerPk} != undefined && this.title === "修改数据") { + if (this.form.${replaceDto.FistLowerPk} != undefined && this.opertype === 2) { update${genTable.BusinessName}(this.form) .then((res) => { this.msgSuccess("修改成功"); diff --git a/ZR.CodeGenerator/CodeGenerateTemplate.cs b/ZR.CodeGenerator/CodeGenerateTemplate.cs index 693d6bd..80bb41a 100644 --- a/ZR.CodeGenerator/CodeGenerateTemplate.cs +++ b/ZR.CodeGenerator/CodeGenerateTemplate.cs @@ -22,7 +22,7 @@ namespace ZR.CodeGenerator string columnName = dbFieldInfo.CsharpFieldFl; string labelName = CodeGeneratorTool.GetLabelName(dbFieldInfo.ColumnComment, columnName); string labelDisabled = dbFieldInfo.IsPk ? ":disabled=\"true\"" : ""; - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new(); string value = CodeGeneratorTool.IsNumber(dbFieldInfo.CsharpType) ? "parseInt(item.dictValue)" : "item.dictValue"; if (GenConstants.inputDtoNoField.Any(f => f.Contains(dbFieldInfo.CsharpField, StringComparison.OrdinalIgnoreCase))) @@ -31,7 +31,7 @@ namespace ZR.CodeGenerator } if (!dbFieldInfo.IsInsert && !dbFieldInfo.IsEdit) { - sb.AppendLine(" "); + sb.AppendLine(" "); sb.AppendLine($" {{{{form.{columnName}}}}}"); sb.AppendLine(" "); return sb.ToString();