19
19
</el-form-item >
20
20
{ {- else } }
21
21
<el-form-item label =" { { .FieldDesc} } " >
22
- <el-input placeholder = " 搜索条件 " v-model =" searchInfo.{ { .FieldJson} } " />
23
- </el-form-item > { { end } } { { end } } { { end } }
22
+ <el-input v-model =" searchInfo.{ { .FieldJson} } " placeholder = " 搜索条件 " />
23
+ </el-form-item >{ { end } }{ { end } }{ { end } }
24
24
<el-form-item >
25
25
<el-button size =" mini" type =" primary" icon =" el-icon-search" @click =" onSubmit" >查询</el-button >
26
26
<el-button size =" mini" type =" primary" icon =" el-icon-plus" @click =" openDialog" >新增</el-button >
52
52
{ {- if .DictType} }
53
53
<el-table-column label =" { { .FieldDesc} } " prop =" { { .FieldJson} } " width =" 120" >
54
54
<template slot-scope =" scope" >
55
- { {" {{" } }filterDict(scope.row.{ {.FieldJson} },"{ {.DictType} }"){ {" }}" } }
55
+ { {" {{" } } filterDict(scope.row.{ {.FieldJson} },"{ {.DictType} }") { {" }}" } }
56
56
</template >
57
57
</el-table-column >
58
58
{ {- else if eq .FieldType " bool" } }
59
59
<el-table-column label =" { { .FieldDesc} } " prop =" { { .FieldJson} } " width =" 120" >
60
60
<template slot-scope =" scope" >{ { " {{scope.row." } }{ {.FieldJson} }{ {" |formatBoolean}}" } }</template >
61
61
</el-table-column > { {- else } }
62
- <el-table-column label =" { { .FieldDesc} } " prop =" { { .FieldJson} } " width =" 120" /> { { end -} }
63
- { { end -} }
62
+ <el-table-column label =" { { .FieldDesc} } " prop =" { { .FieldJson} } " width =" 120" />
63
+ { {- end } }
64
+ { {- end } }
64
65
<el-table-column label =" 按钮组" >
65
66
<template slot-scope =" scope" >
66
67
<el-button size =" small" type =" primary" icon =" el-icon-edit" class =" table-button" @click =" update{ { .StructName} } (scope.row)" >变更</el-button >
82
83
<el-form :model =" formData" label-position =" right" label-width =" 80px" >
83
84
{ {- range .Fields} }
84
85
<el-form-item label =" { { .FieldDesc} } :" >
85
- { { if eq .FieldType " bool" } }
86
+ { {- if eq .FieldType " bool" } }
86
87
<el-switch active-color =" #13ce66" inactive-color =" #ff4949" active-text =" 是" inactive-text =" 否" v-model =" formData.{ { .FieldJson} } " clearable ></el-switch >
87
- { { end - } }
88
- { { if eq .FieldType " string" } }
88
+ { {- end } }
89
+ { {- if eq .FieldType " string" } }
89
90
<el-input v-model =" formData.{ { .FieldJson} } " clearable placeholder =" 请输入" />
90
- { { end - } }
91
- { { if eq .FieldType " int" } }
91
+ { {- end } }
92
+ { {- if eq .FieldType " int" } }
92
93
{ {- if .DictType} }
93
94
<el-select v-model =" formData.{ { .FieldJson } } " placeholder =" 请选择" clearable >
94
95
<el-option v-for =" (item,key) in { { .DictType } } Options" :key =" key" :label =" item.label" :value =" item.value" />
95
96
</el-select >
96
- { { else } }
97
+ { {- else } }
97
98
<el-input v-model.number =" formData.{ { .FieldJson } } " clearable placeholder =" 请输入" />
98
- { { end - } }
99
- { { end - } }
100
- { { if eq .FieldType " time.Time" } }
99
+ { {- end } }
100
+ { {- end } }
101
+ { {- if eq .FieldType " time.Time" } }
101
102
<el-date-picker type =" date" placeholder =" 选择日期" v-model =" formData.{ { .FieldJson } } " clearable />
102
- { { end - } }
103
- { {- if eq .FieldType " float64" } }
103
+ { {- end } }
104
+ { {- if eq .FieldType " float64" } }
104
105
<el-input-number v-model =" formData.{ { .FieldJson } } " :precision =" 2" clearable />
105
- { { end - } }
106
- </el-form-item >
107
- { {- end } }
108
- </el-form >
106
+ { {- end } }
107
+ </el-form-item >
108
+ { {- end } }
109
+ </el-form >
109
110
<div slot =" footer" class =" dialog-footer" >
110
111
<el-button @click =" closeDialog" >取 消</el-button >
111
112
<el-button type =" primary" @click =" enterDialog" >确 定</el-button >
@@ -127,6 +128,23 @@ import { formatTimeToStr } from '@/utils/date'
127
128
import infoList from ' @/mixins/infoList'
128
129
export default {
129
130
name: ' { { .StructName} } ' ,
131
+ filters: {
132
+ formatDate: function(time) {
133
+ if (time !== null && time !== ' ' ) {
134
+ var date = new Date(time)
135
+ return formatTimeToStr(date, ' yyyy-MM-dd hh:mm:ss' )
136
+ } else {
137
+ return ' '
138
+ }
139
+ } ,
140
+ formatBoolean: function(bool) {
141
+ if (bool != null) {
142
+ return bool ? ' 是' : ' 否'
143
+ } else {
144
+ return ' '
145
+ }
146
+ }
147
+ } ,
130
148
mixins: [infoList],
131
149
data() {
132
150
return {
@@ -135,66 +153,49 @@ export default {
135
153
type: ' ' ,
136
154
deleteVisible: false ,
137
155
multipleSelection: [],
138
- { { range .Fields} }
156
+ { { - range .Fields} }
139
157
{ { - if .DictType } }
140
158
{ { .DictType } } Options: [],
141
- { { end - } }
142
- { { end } }
159
+ { { - end } }
160
+ { { - end } }
143
161
formData: {
144
- { { range .Fields} }
145
- { { - if eq .FieldType " bool" - } }
162
+ { { - range .Fields} }
163
+ { { - if eq .FieldType " bool" } }
146
164
{ { .FieldJson} } : false ,
147
- { { end - } }
148
- { { - if eq .FieldType " string" - } }
165
+ { { - end } }
166
+ { { - if eq .FieldType " string" } }
149
167
{ { .FieldJson} } : ' ' ,
150
- { { end - } }
151
- { { - if eq .FieldType " int" - } }
168
+ { { - end } }
169
+ { { - if eq .FieldType " int" } }
152
170
{ { .FieldJson} } : 0,
153
- { { end - } }
154
- { { - if eq .FieldType " time.Time" - } }
171
+ { { - end } }
172
+ { { - if eq .FieldType " time.Time" } }
155
173
{ { .FieldJson} } : new Date(),
156
- { { end - } }
157
- { { - if eq .FieldType " float64" - } }
174
+ { { - end } }
175
+ { { - if eq .FieldType " float64" } }
158
176
{ { .FieldJson} } : 0,
159
- { { end -} }
160
- { { end } }
161
- }
162
- }
163
- } ,
164
- filters: {
165
- formatDate: function(time) {
166
- if (time !== null && time !== ' ' ) {
167
- var date = new Date(time);
168
- return formatTimeToStr(date, ' yyyy-MM-dd hh:mm:ss' );
169
- } else {
170
- return ' '
171
- }
172
- } ,
173
- formatBoolean: function(bool) {
174
- if (bool != null) {
175
- return bool ? ' 是' : ' 否'
176
- } else {
177
- return ' '
177
+ { { - end } }
178
+ { { - end } }
178
179
}
179
180
}
180
181
} ,
181
182
async created() {
182
183
await this.getTableData()
183
- { { range .Fields - } }
184
- { { - if .DictType } }
184
+ { { - range .Fields } }
185
+ { { - if .DictType } }
185
186
await this.getDict(' { { .DictType} } ' )
186
- { { end - } }
187
- { { - end } }
187
+ { { - end } }
188
+ { { - end } }
188
189
} ,
189
190
methods: {
190
191
// 条件搜索前端看此方法
191
192
onSubmit() {
192
193
this.page = 1
193
194
this.pageSize = 10
194
- { { - range .Fields} } { { - if eq .FieldType " bool" } }
195
+ { { - range .Fields} } { { - if eq .FieldType " bool" } }
195
196
if (this.searchInfo.{ { .FieldJson} } === " " ){
196
197
this.searchInfo.{ { .FieldJson} } =null
197
- } { { end } } { { end } }
198
+ } { { end } } { { end } }
198
199
this.getTableData()
199
200
} ,
200
201
handleSelectionChange(val) {
@@ -246,23 +247,23 @@ export default {
246
247
closeDialog() {
247
248
this.dialogFormVisible = false
248
249
this.formData = {
249
- { { range .Fields} }
250
- { { - if eq .FieldType " bool" - } }
250
+ { { - range .Fields} }
251
+ { { - if eq .FieldType " bool" } }
251
252
{ { .FieldJson} } : false ,
252
- { { end - } }
253
- { { - if eq .FieldType " string" - } }
253
+ { { - end } }
254
+ { { - if eq .FieldType " string" } }
254
255
{ { .FieldJson} } : ' ' ,
255
- { { end - } }
256
- { { - if eq .FieldType " int" - } }
256
+ { { - end } }
257
+ { { - if eq .FieldType " int" } }
257
258
{ { .FieldJson} } : 0,
258
- { { end - } }
259
- { { - if eq .FieldType " time.Time" - } }
259
+ { { - end } }
260
+ { { - if eq .FieldType " time.Time" } }
260
261
{ { .FieldJson} } : new Date(),
261
- { { end - } }
262
- { { - if eq .FieldType " float64" - } }
262
+ { { - end } }
263
+ { { - if eq .FieldType " float64" } }
263
264
{ { .FieldJson} } : 0,
264
- { { end - } }
265
- { { end } }
265
+ { { - end } }
266
+ { { - end } }
266
267
}
267
268
} ,
268
269
async delete{ { .StructName} } (row) {
@@ -272,7 +273,7 @@ export default {
272
273
type: ' success' ,
273
274
message: ' 删除成功'
274
275
} )
275
- if (this.tableData.length === 1 && this.page > 1 ) {
276
+ if (this.tableData.length === 1 && this.page > 1) {
276
277
this.page--
277
278
}
278
279
this.getTableData()
@@ -281,10 +282,10 @@ export default {
281
282
async enterDialog() {
282
283
let res
283
284
switch (this.type) {
284
- case " create" :
285
+ case ' create' :
285
286
res = await create{ { .StructName} } (this.formData)
286
287
break
287
- case " update" :
288
+ case ' update' :
288
289
res = await update{ { .StructName} } (this.formData)
289
290
break
290
291
default :
0 commit comments