代码生成添加修改新增加CheckBox

This commit is contained in:
不做码农 2021-12-14 15:40:39 +08:00
parent 7352c2fea5
commit d1fc87bcc3
5 changed files with 37 additions and 4 deletions

View File

@ -195,6 +195,9 @@ $foreach(item in genTable.Columns)
$if((item.IsEdit || item.IsInsert))
$item.ColumnName: undefined,
$end
$if((item.HtmlType == "checkbox"))
${item.ColumnName}Checked: [],
$end
$end
};
this.resetForm("form");
@ -247,10 +250,19 @@ $end
this.reset();
const id = row.${replaceDto.FistLowerPk} || this.ids;
get${genTable.BusinessName}(id).then((res) => {
if (res.code == 200) {
this.form = res.data;
const { code, data } = res;
if (code == 200) {
this.open = true;
this.title = "修改数据";
this.form = {
...data,
$foreach(item in genTable.Columns)
$if(item.HtmlType == "checkbox")
${item.ColumnName}Checked: data.${item.columnName} ? data.${item.columnName}.split(',') : [],
$end
$end
};
}
});
},
@ -288,6 +300,11 @@ $end
submitForm: function () {
this.${refs}refs["form"].validate((valid) => {
if (valid) {
$foreach(item in genTable.Columns)
$if(item.HtmlType == "checkbox")
this.form.${item.ColumnName} = this.form.${item.columnName}Checked.toString();
$end
$end
console.log(JSON.stringify(this.form));
if (this.form.${replaceDto.FistLowerPk} != undefined || this.title === "修改数据") {

View File

@ -118,6 +118,21 @@ namespace ZR.CodeGenerator
sb.AppendLine(" </el-form-item>");
sb.AppendLine(" </el-col>");
}
else if( dbFieldInfo.HtmlType == GenConstants.HTML_CHECKBOX)
{
//多选框
sb.AppendLine(" <el-col :span=\"12\">");
sb.AppendLine($" <el-form-item label=\"{labelName}\" prop=\"{columnName}\">");
sb.AppendLine($" <el-checkbox-group v-model=\"form.{columnName}Checked\"> ");
if (string.IsNullOrEmpty(dbFieldInfo.DictType))
{
sb.AppendLine($" <el-checkbox>请选择字典生成</el-checkbox>");
}
sb.AppendLine($" <el-checkbox v-for=\"item in {columnName}Options\" :key=\"item.dictValue\" :label=\"item.dictValue\">{{{{item.dictLabel}}}}</el-checkbox>");
sb.AppendLine(" </el-checkbox-group>");
sb.AppendLine(" </el-form-item>");
sb.AppendLine(" </el-col>");
}
else
{
string inputNumTxt = CodeGeneratorTool.IsNumber(dbFieldInfo.CsharpType) ? ".number" : "";

View File

@ -717,6 +717,7 @@ CREATE TABLE `gen_demo` (
`remark` VARCHAR(200) COMMENT '备注',
`beginTime` datetime(0) NULL DEFAULT NULL COMMENT '开始时间',
`endTime` datetime(0) NULL DEFAULT NULL COMMENT '结束时间',
`feature` varchar(100) NULL COMMENT '特征'
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

Binary file not shown.