9292 ></el-pagination >
9393
9494 <el-dialog :before-close =" closeDialog" :visible.sync =" dialogFormVisible" title =" 弹窗操作" >
95- 此处请使用表单生成器生成form填充 表单默认绑定 formData 如手动修改过请自行修改key
95+ <el-form :model =" formData" label-position =" right" label-width =" 80px" >
96+ { {- range .Fields} }
97+ <el-form-item label =" { { .FieldDesc} } :" >
98+ { {- if eq .FieldType " bool" } }
99+ <el-switch active-color =" #13ce66" inactive-color =" #ff4949" active-text =" 是" inactive-text =" 否" v-model =" formData.{ { .FieldJson} } " clearable ></el-switch >
100+ { { end -} }
101+ { {- if eq .FieldType " string" } }
102+ <el-input v-model =" formData.{ { .FieldJson} } " clearable placeholder =" 请输入" ></el-input >
103+ { { end -} }
104+ { {- if eq .FieldType " int" } }
105+ { {- if .DictType} }
106+ <el-select v-model =" formData.{ { .FieldJson } } " placeholder =" 请选择" clearable >
107+ <el-option v-for =" (item,key) in { { .DictType } } Options" :key =" key" :label =" item.label" :value =" item.value" ></el-option >
108+ </el-select >
109+ { { else -} }
110+ <el-input v-model.number =" formData.{ { .FieldJson } } " clearable placeholder =" 请输入" ></el-input >
111+ { { end -} }
112+ { { end -} }
113+ { {- if eq .FieldType " time.Time" } }
114+ <el-date-picker type =" date" placeholder =" 选择日期" v-model =" formData.{ { .FieldJson } } " clearable ></el-date-picker >
115+ { { end -} }
116+ { {- if eq .FieldType " float64" } }
117+ <el-input-number v-model =" formData.{ { .FieldJson } } " :precision =" 2" clearable ></el-input-number >
118+ { { end -} }
119+ </el-form-item >
120+ { { end -} }
121+ </el-form >
96122 <div class =" dialog-footer" slot =" footer" >
97123 <el-button @click =" closeDialog" >取 消</el-button >
98124 <el-button @click =" enterDialog" type =" primary" >确 定</el-button >
@@ -111,26 +137,41 @@ import {
111137 get{ { .StructName} } List
112138} from " @/api/{ { .PackageName} } " ; // 此处请自行替换地址
113139import { formatTimeToStr } from " @/utils/data" ;
114- import infoList from " @/components/mixins/infoList" ;
115-
140+ import infoList from " @/mixins/infoList" ;
116141export default {
117142 name: " { { .StructName} } " ,
118143 mixins: [infoList],
119144 data() {
120145 return {
121- listApi: get{ { .StructName} } List,
146+ listApi: get{ { .StructName } } List,
122147 dialogFormVisible: false ,
123148 visible: false ,
124149 type: " " ,
125150 deleteVisible: false ,
126151 multipleSelection: [],
127152 { { - range .Fields} }
128153 { { - if .DictType } }
129- { { .DictType} } Options:[],
154+ { { .DictType } } Options:[],
130155 { { end -} }
131156 { { end -} }
132157 formData: {
133- { { range .Fields} } { { .FieldJson} } :null,{ { end } }
158+ { { range .Fields} }
159+ { { - if eq .FieldType " bool" -} }
160+ { { .FieldJson} } :false ,
161+ { { end -} }
162+ { { - if eq .FieldType " string" -} }
163+ { { .FieldJson} } :" " ,
164+ { { end -} }
165+ { { - if eq .FieldType " int" -} }
166+ { { .FieldJson} } :0,
167+ { { end -} }
168+ { { - if eq .FieldType " time.Time" -} }
169+ { { .FieldJson} } :new Date(),
170+ { { end -} }
171+ { { - if eq .FieldType " float64" -} }
172+ { { .FieldJson} } :0,
173+ { { end -} }
174+ { { end } }
134175 }
135176 } ;
136177 } ,
@@ -192,8 +233,23 @@ export default {
192233 closeDialog() {
193234 this.dialogFormVisible = false ;
194235 this.formData = {
195- { { range .Fields} }
196- { { .FieldJson} } :null,{ { end } }
236+ { { range .Fields} }
237+ { { - if eq .FieldType " bool" -} }
238+ { { .FieldJson} } :false ,
239+ { { end -} }
240+ { { - if eq .FieldType " string" -} }
241+ { { .FieldJson} } :" " ,
242+ { { end -} }
243+ { { - if eq .FieldType " int" -} }
244+ { { .FieldJson} } :0,
245+ { { end -} }
246+ { { - if eq .FieldType " time.Time" -} }
247+ { { .FieldJson} } :new Date(),
248+ { { end -} }
249+ { { - if eq .FieldType " float64" -} }
250+ { { .FieldJson} } :0,
251+ { { end -} }
252+ { { end } }
197253 } ;
198254 } ,
199255 async delete{ { .StructName} } (row) {
@@ -236,11 +292,11 @@ export default {
236292 } ,
237293 async created() {
238294 await this.getTableData();
239- { { - range .Fields -} }
240- { { - if .DictType - } }
241- await this.getDict(" { { .DictType} } " )
242- { { - end -} }
243- { { - end - } }
295+ { { range .Fields -} }
296+ { { - if .DictType } }
297+ await this.getDict(" { { .DictType} } " );
298+ { { end -} }
299+ { { - end } }
244300}
245301} ;
246302 </script >
0 commit comments