修改代码生成form表单模板

This commit is contained in:
不做码农 2021-11-27 19:52:26 +08:00
parent 6433861fe7
commit 2cc6e1d0ec
2 changed files with 9 additions and 8 deletions

View File

@ -41,7 +41,9 @@
<!-- 添加或修改菜单对话框 --> <!-- 添加或修改菜单对话框 -->
<el-dialog :title="title" :lock-scroll="false" :visible.sync="open" > <el-dialog :title="title" :lock-scroll="false" :visible.sync="open" >
<el-form ref="form" :model="form" :rules="rules" :label-width="formLabelWidth"> <el-form ref="form" :model="form" :rules="rules" :label-width="formLabelWidth">
<el-row>
{VueViewFormContent} {VueViewFormContent}
</el-row>
</el-form> </el-form>
<div slot="footer" class="dialog-footer" v-if="btnSubmitVisible"> <div slot="footer" class="dialog-footer" v-if="btnSubmitVisible">
<el-button @click="cancel">取 消</el-button> <el-button @click="cancel">取 消</el-button>
@ -63,7 +65,7 @@ import {
{VueComponentImport} {VueComponentImport}
export default { export default {
name: '{ModelTypeName}', name: "{ModelTypeName}",
components: { {VueComponent} }, components: { {VueComponent} },
data() { data() {
return { return {
@ -187,7 +189,7 @@ export default {
if (valid) { if (valid) {
console.log(JSON.stringify(this.form)); console.log(JSON.stringify(this.form));
if (this.form.{PrimaryKey} != undefined || this.title === '修改数据') { if (this.form.{PrimaryKey} != undefined || this.title === "修改数据") {
update{ModelTypeName}(this.form).then((res) => { update{ModelTypeName}(this.form).then((res) => {
if (!res.data) { if (!res.data) {
this.msgError("修改失败"); this.msgError("修改失败");

View File

@ -152,7 +152,6 @@ namespace ZR.CodeGenerator
{ {
return sb.ToString(); return sb.ToString();
} }
sb.AppendLine(" <el-row>");
if (dbFieldInfo.HtmlType == GenConstants.HTML_INPUT_NUMBER) if (dbFieldInfo.HtmlType == GenConstants.HTML_INPUT_NUMBER)
{ {
sb.AppendLine(" <el-col :span=\"12\">"); sb.AppendLine(" <el-col :span=\"12\">");
@ -173,6 +172,7 @@ namespace ZR.CodeGenerator
else if (dbFieldInfo.HtmlType == GenConstants.HTML_IMAGE_UPLOAD) else if (dbFieldInfo.HtmlType == GenConstants.HTML_IMAGE_UPLOAD)
{ {
//图片 //图片
sb.AppendLine(" <el-col :span=\"24\">");
sb.AppendLine($" <el-form-item label=\"{labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">"); sb.AppendLine($" <el-form-item label=\"{labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">");
sb.AppendLine($" <el-upload class=\"avatar-uploader\" name=\"file\" action=\"/api/upload/saveFile/\" :show-file-list=\"false\" :on-success=\"handleUpload{dbFieldInfo.CsharpField}Success\" :before-upload=\"beforeFileUpload\">"); sb.AppendLine($" <el-upload class=\"avatar-uploader\" name=\"file\" action=\"/api/upload/saveFile/\" :show-file-list=\"false\" :on-success=\"handleUpload{dbFieldInfo.CsharpField}Success\" :before-upload=\"beforeFileUpload\">");
sb.AppendLine($" <img v-if=\"form.{columnName}\" :src=\"form.{columnName}\" class=\"icon\">"); sb.AppendLine($" <img v-if=\"form.{columnName}\" :src=\"form.{columnName}\" class=\"icon\">");
@ -188,7 +188,7 @@ namespace ZR.CodeGenerator
sb.AppendLine(" <el-col :span=\"12\">"); sb.AppendLine(" <el-col :span=\"12\">");
sb.AppendLine($" <el-form-item label=\"{labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">"); sb.AppendLine($" <el-form-item label=\"{labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">");
sb.AppendLine($" <el-radio-group v-model=\"form.{columnName}\">"); sb.AppendLine($" <el-radio-group v-model=\"form.{columnName}\">");
sb.AppendLine($" <el-radio v-for=\"item in {columnName}Options\" :key=\"item.dictValue\" :label=\"{value}\">{{item.dictLabel}}</el-radio>"); sb.AppendLine($" <el-radio v-for=\"item in {columnName}Options\" :key=\"item.dictValue\" :label=\"{value}\">{{{{item.dictLabel}}}}</el-radio>");
sb.AppendLine(" </el-radio-group>"); sb.AppendLine(" </el-radio-group>");
sb.AppendLine(" </el-form-item>"); sb.AppendLine(" </el-form-item>");
sb.AppendLine(" </el-col>"); sb.AppendLine(" </el-col>");
@ -241,7 +241,6 @@ namespace ZR.CodeGenerator
sb.AppendLine(" </el-col>"); sb.AppendLine(" </el-col>");
} }
sb.AppendLine(" </el-row>");
return sb.ToString(); return sb.ToString();
} }