Skip to content

Commit 4655633

Browse files
author
奇淼(piexlmax
authored
Merge pull request flipped-aurora#620 from fengchao/develop
Develop Fix eslint errors and warnings in auto generated code
2 parents 7144443 + 532c170 commit 4655633

File tree

4 files changed

+123
-122
lines changed

4 files changed

+123
-122
lines changed

server/resource/template/web/api.js.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,4 @@ export const get{{.StructName}}List = (params) => {
9494
method: 'get',
9595
params
9696
})
97-
}
97+
}

server/resource/template/web/form.vue.tpl

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,35 @@
33
<el-form :model="formData" label-position="right" label-width="80px">
44
{{- range .Fields}}
55
<el-form-item label="{{.FieldDesc}}:">
6-
{{ if eq .FieldType "bool" -}}
7-
<el-switch active-color="#13ce66" inactive-color="#ff4949" active-text="" inactive-text="" v-model="formData.{{.FieldJson}}" clearable ></el-switch>
8-
{{ end -}}
9-
{{ if eq .FieldType "string" -}}
10-
<el-input v-model="formData.{{.FieldJson}}" clearable placeholder="请输入" />
11-
{{ end -}}
12-
{{ if eq .FieldType "int" -}}
13-
{{ if .DictType -}}
14-
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择" clearable>
15-
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value"></el-option>
16-
</el-select>
17-
{{ else -}}
18-
<el-input v-model.number="formData.{{ .FieldJson }}" clearable placeholder="请输入"/>
19-
{{ end -}}
20-
{{ end -}}
21-
{{ if eq .FieldType "time.Time" }}
22-
<el-date-picker type="date" placeholder="选择日期" v-model="formData.{{ .FieldJson }}" clearable></el-date-picker>
23-
{{ end -}}
24-
{{ if eq .FieldType "float64" }}
25-
<el-input-number v-model="formData.{{ .FieldJson }}" :precision="2" clearable></el-input-number>
26-
{{ end -}}
6+
{{- if eq .FieldType "bool" }}
7+
<el-switch active-color="#13ce66" inactive-color="#ff4949" active-text="" inactive-text="" v-model="formData.{{.FieldJson}}" clearable ></el-switch>
8+
{{- end }}
9+
{{- if eq .FieldType "string" }}
10+
<el-input v-model="formData.{{.FieldJson}}" clearable placeholder="请输入" />
11+
{{- end }}
12+
{{- if eq .FieldType "int" }}
13+
{{- if .DictType }}
14+
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择" clearable>
15+
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
16+
</el-select>
17+
{{- else }}
18+
<el-input v-model.number="formData.{{ .FieldJson }}" clearable placeholder="请输入" />
19+
{{- end }}
20+
{{- end }}
21+
{{- if eq .FieldType "time.Time" }}
22+
<el-date-picker type="date" placeholder="选择日期" v-model="formData.{{ .FieldJson }}" clearable></el-date-picker>
23+
{{- end }}
24+
{{- if eq .FieldType "float64" }}
25+
<el-input-number v-model="formData.{{ .FieldJson }}" :precision="2" clearable></el-input-number>
26+
{{- end }}
2727
</el-form-item>
28-
{{ end -}}
28+
{{- end }}
2929
<el-form-item>
3030
<el-button size="mini" type="primary" @click="save">保存</el-button>
3131
<el-button size="mini" type="primary" @click="back">返回</el-button>
3232
</el-form-item>
3333
</el-form>
34-
</div>
34+
</div>
3535
</template>
3636

3737
<script>
@@ -47,29 +47,29 @@ export default {
4747
data() {
4848
return {
4949
type: '',
50-
{{range .Fields}}
50+
{{- range .Fields}}
5151
{{- if .DictType }}
5252
{{ .DictType }}Options: [],
53-
{{ end -}}
54-
{{end -}}
53+
{{- end }}
54+
{{- end }}
5555
formData: {
56-
{{range .Fields}}
57-
{{- if eq .FieldType "bool" -}}
58-
{{.FieldJson}}: false,
59-
{{ end -}}
60-
{{- if eq .FieldType "string" -}}
61-
{{.FieldJson}}: '',
62-
{{ end -}}
63-
{{- if eq .FieldType "int" -}}
64-
{{.FieldJson}}: 0,
65-
{{ end -}}
66-
{{- if eq .FieldType "time.Time" -}}
67-
{{.FieldJson}}: new Date(),
68-
{{ end -}}
69-
{{- if eq .FieldType "float64" -}}
70-
{{.FieldJson}}: 0,
71-
{{ end -}}
72-
{{ end }}
56+
{{- range .Fields}}
57+
{{- if eq .FieldType "bool" }}
58+
{{.FieldJson}}: false,
59+
{{- end }}
60+
{{- if eq .FieldType "string" }}
61+
{{.FieldJson}}: '',
62+
{{- end }}
63+
{{- if eq .FieldType "int" }}
64+
{{.FieldJson}}: 0,
65+
{{- end }}
66+
{{- if eq .FieldType "time.Time" }}
67+
{{.FieldJson}}: new Date(),
68+
{{- end }}
69+
{{- if eq .FieldType "float64" }}
70+
{{.FieldJson}}: 0,
71+
{{- end }}
72+
{{- end }}
7373
}
7474
}
7575
},
@@ -84,10 +84,10 @@ export default {
8484
} else {
8585
this.type = 'create'
8686
}
87-
{{ range .Fields -}}
87+
{{- range .Fields }}
8888
{{- if .DictType }}
89-
await this.getDict("{{.DictType}}")
90-
{{ end -}}
89+
await this.getDict('{{.DictType}}')
90+
{{- end }}
9191
{{- end }}
9292
},
9393
methods: {
@@ -119,4 +119,4 @@ export default {
119119
</script>
120120

121121
<style>
122-
</style>
122+
</style>

server/resource/template/web/table.vue.tpl

Lines changed: 74 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
</el-form-item>
2020
{{- else }}
2121
<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 }}
2424
<el-form-item>
2525
<el-button size="mini" type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
2626
<el-button size="mini" type="primary" icon="el-icon-plus" @click="openDialog">新增</el-button>
@@ -52,15 +52,16 @@
5252
{{- if .DictType}}
5353
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
5454
<template slot-scope="scope">
55-
{{"{{"}}filterDict(scope.row.{{.FieldJson}},"{{.DictType}}"){{"}}"}}
55+
{{"{{"}} filterDict(scope.row.{{.FieldJson}},"{{.DictType}}") {{"}}"}}
5656
</template>
5757
</el-table-column>
5858
{{- else if eq .FieldType "bool" }}
5959
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
6060
<template slot-scope="scope">{{ "{{scope.row."}}{{.FieldJson}}{{"|formatBoolean}}" }}</template>
6161
</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 }}
6465
<el-table-column label="按钮组">
6566
<template slot-scope="scope">
6667
<el-button size="small" type="primary" icon="el-icon-edit" class="table-button" @click="update{{.StructName}}(scope.row)">变更</el-button>
@@ -82,30 +83,30 @@
8283
<el-form :model="formData" label-position="right" label-width="80px">
8384
{{- range .Fields}}
8485
<el-form-item label="{{.FieldDesc}}:">
85-
{{ if eq .FieldType "bool" }}
86+
{{- if eq .FieldType "bool" }}
8687
<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" }}
8990
<el-input v-model="formData.{{.FieldJson}}" clearable placeholder="请输入" />
90-
{{ end -}}
91-
{{ if eq .FieldType "int" }}
91+
{{- end }}
92+
{{- if eq .FieldType "int" }}
9293
{{- if .DictType}}
9394
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择" clearable>
9495
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
9596
</el-select>
96-
{{ else }}
97+
{{- else }}
9798
<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" }}
101102
<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" }}
104105
<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>
109110
<div slot="footer" class="dialog-footer">
110111
<el-button @click="closeDialog">取 消</el-button>
111112
<el-button type="primary" @click="enterDialog">确 定</el-button>
@@ -127,6 +128,23 @@ import { formatTimeToStr } from '@/utils/date'
127128
import infoList from '@/mixins/infoList'
128129
export default {
129130
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+
},
130148
mixins: [infoList],
131149
data() {
132150
return {
@@ -135,66 +153,49 @@ export default {
135153
type: '',
136154
deleteVisible: false,
137155
multipleSelection: [],
138-
{{ range .Fields}}
156+
{{- range .Fields}}
139157
{{- if .DictType }}
140158
{{ .DictType }}Options: [],
141-
{{ end -}}
142-
{{ end }}
159+
{{- end }}
160+
{{- end }}
143161
formData: {
144-
{{range .Fields}}
145-
{{- if eq .FieldType "bool" -}}
162+
{{- range .Fields}}
163+
{{- if eq .FieldType "bool" }}
146164
{{.FieldJson}}: false,
147-
{{ end -}}
148-
{{- if eq .FieldType "string" -}}
165+
{{- end }}
166+
{{- if eq .FieldType "string" }}
149167
{{.FieldJson}}: '',
150-
{{ end -}}
151-
{{- if eq .FieldType "int" -}}
168+
{{- end }}
169+
{{- if eq .FieldType "int" }}
152170
{{.FieldJson}}: 0,
153-
{{ end -}}
154-
{{- if eq .FieldType "time.Time" -}}
171+
{{- end }}
172+
{{- if eq .FieldType "time.Time" }}
155173
{{.FieldJson}}: new Date(),
156-
{{ end -}}
157-
{{- if eq .FieldType "float64" -}}
174+
{{- end }}
175+
{{- if eq .FieldType "float64" }}
158176
{{.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 }}
178179
}
179180
}
180181
},
181182
async created() {
182183
await this.getTableData()
183-
{{ range .Fields -}}
184-
{{- if .DictType }}
184+
{{- range .Fields }}
185+
{{- if .DictType }}
185186
await this.getDict('{{.DictType}}')
186-
{{ end -}}
187-
{{- end }}
187+
{{- end }}
188+
{{- end }}
188189
},
189190
methods: {
190191
// 条件搜索前端看此方法
191192
onSubmit() {
192193
this.page = 1
193194
this.pageSize = 10
194-
{{- range .Fields}} {{- if eq .FieldType "bool" }}
195+
{{- range .Fields}}{{- if eq .FieldType "bool" }}
195196
if (this.searchInfo.{{.FieldJson}} === ""){
196197
this.searchInfo.{{.FieldJson}}=null
197-
} {{ end }} {{ end }}
198+
}{{ end }}{{ end }}
198199
this.getTableData()
199200
},
200201
handleSelectionChange(val) {
@@ -246,23 +247,23 @@ export default {
246247
closeDialog() {
247248
this.dialogFormVisible = false
248249
this.formData = {
249-
{{range .Fields}}
250-
{{- if eq .FieldType "bool" -}}
250+
{{- range .Fields}}
251+
{{- if eq .FieldType "bool" }}
251252
{{.FieldJson}}: false,
252-
{{ end -}}
253-
{{- if eq .FieldType "string" -}}
253+
{{- end }}
254+
{{- if eq .FieldType "string" }}
254255
{{.FieldJson}}: '',
255-
{{ end -}}
256-
{{- if eq .FieldType "int" -}}
256+
{{- end }}
257+
{{- if eq .FieldType "int" }}
257258
{{.FieldJson}}: 0,
258-
{{ end -}}
259-
{{- if eq .FieldType "time.Time" -}}
259+
{{- end }}
260+
{{- if eq .FieldType "time.Time" }}
260261
{{.FieldJson}}: new Date(),
261-
{{ end -}}
262-
{{- if eq .FieldType "float64" -}}
262+
{{- end }}
263+
{{- if eq .FieldType "float64" }}
263264
{{.FieldJson}}: 0,
264-
{{ end -}}
265-
{{ end }}
265+
{{- end }}
266+
{{- end }}
266267
}
267268
},
268269
async delete{{.StructName}}(row) {
@@ -272,7 +273,7 @@ export default {
272273
type: 'success',
273274
message: '删除成功'
274275
})
275-
if (this.tableData.length === 1 && this.page > 1 ) {
276+
if (this.tableData.length === 1 && this.page > 1) {
276277
this.page--
277278
}
278279
this.getTableData()
@@ -281,10 +282,10 @@ export default {
281282
async enterDialog() {
282283
let res
283284
switch (this.type) {
284-
case "create":
285+
case 'create':
285286
res = await create{{.StructName}}(this.formData)
286287
break
287-
case "update":
288+
case 'update':
288289
res = await update{{.StructName}}(this.formData)
289290
break
290291
default:

web/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module.exports = {
5252
properties: 'always'
5353
}
5454
],
55-
'comma-dangle': [2, 'never'],
55+
'comma-dangle': [2, 'only-multiline'],
5656
'comma-spacing': [
5757
2,
5858
{

0 commit comments

Comments
 (0)