|
@ -19,8 +19,8 @@ |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
{{- else }} |
|
|
{{- else }} |
|
|
<el-form-item label="{{.FieldDesc}}"> |
|
|
<el-form-item label="{{.FieldDesc}}"> |
|
|
<el-input placeholder="搜索条件" v-model="searchInfo.{{.FieldJson}}" /> |
|
|
|
|
|
</el-form-item> {{ end }} {{ end }} {{ end }} |
|
|
|
|
|
|
|
|
<el-input v-model="searchInfo.{{.FieldJson}}" placeholder="搜索条件" /> |
|
|
|
|
|
</el-form-item>{{ end }}{{ end }}{{ end }} |
|
|
<el-form-item> |
|
|
<el-form-item> |
|
|
<el-button size="mini" type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button> |
|
|
<el-button size="mini" type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button> |
|
|
<el-button size="mini" type="primary" icon="el-icon-plus" @click="openDialog">新增</el-button> |
|
|
<el-button size="mini" type="primary" icon="el-icon-plus" @click="openDialog">新增</el-button> |
|
@ -52,15 +52,16 @@ |
|
|
{{- if .DictType}} |
|
|
{{- if .DictType}} |
|
|
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120"> |
|
|
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120"> |
|
|
<template slot-scope="scope"> |
|
|
<template slot-scope="scope"> |
|
|
{{"{{"}}filterDict(scope.row.{{.FieldJson}},"{{.DictType}}"){{"}}"}} |
|
|
|
|
|
|
|
|
{{"{{"}} filterDict(scope.row.{{.FieldJson}},"{{.DictType}}") {{"}}"}} |
|
|
</template> |
|
|
</template> |
|
|
</el-table-column> |
|
|
</el-table-column> |
|
|
{{- else if eq .FieldType "bool" }} |
|
|
{{- else if eq .FieldType "bool" }} |
|
|
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120"> |
|
|
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120"> |
|
|
<template slot-scope="scope">{{ "{{scope.row."}}{{.FieldJson}}{{"|formatBoolean}}" }}</template> |
|
|
<template slot-scope="scope">{{ "{{scope.row."}}{{.FieldJson}}{{"|formatBoolean}}" }}</template> |
|
|
</el-table-column> {{- else }} |
|
|
</el-table-column> {{- else }} |
|
|
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120" /> {{ end -}} |
|
|
|
|
|
{{ end -}} |
|
|
|
|
|
|
|
|
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120" /> |
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- end }} |
|
|
<el-table-column label="按钮组"> |
|
|
<el-table-column label="按钮组"> |
|
|
<template slot-scope="scope"> |
|
|
<template slot-scope="scope"> |
|
|
<el-button size="small" type="primary" icon="el-icon-edit" class="table-button" @click="update{{.StructName}}(scope.row)">变更</el-button> |
|
|
<el-button size="small" type="primary" icon="el-icon-edit" class="table-button" @click="update{{.StructName}}(scope.row)">变更</el-button> |
|
@ -82,27 +83,27 @@ |
|
|
<el-form :model="formData" label-position="right" label-width="80px"> |
|
|
<el-form :model="formData" label-position="right" label-width="80px"> |
|
|
{{- range .Fields}} |
|
|
{{- range .Fields}} |
|
|
<el-form-item label="{{.FieldDesc}}:"> |
|
|
<el-form-item label="{{.FieldDesc}}:"> |
|
|
{{ if eq .FieldType "bool" }} |
|
|
|
|
|
|
|
|
{{- if eq .FieldType "bool" }} |
|
|
<el-switch active-color="#13ce66" inactive-color="#ff4949" active-text="是" inactive-text="否" v-model="formData.{{.FieldJson}}" clearable ></el-switch> |
|
|
<el-switch active-color="#13ce66" inactive-color="#ff4949" active-text="是" inactive-text="否" v-model="formData.{{.FieldJson}}" clearable ></el-switch> |
|
|
{{ end -}} |
|
|
|
|
|
{{ if eq .FieldType "string" }} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "string" }} |
|
|
<el-input v-model="formData.{{.FieldJson}}" clearable placeholder="请输入" /> |
|
|
<el-input v-model="formData.{{.FieldJson}}" clearable placeholder="请输入" /> |
|
|
{{ end -}} |
|
|
|
|
|
{{ if eq .FieldType "int" }} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "int" }} |
|
|
{{- if .DictType}} |
|
|
{{- if .DictType}} |
|
|
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择" clearable> |
|
|
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择" clearable> |
|
|
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" /> |
|
|
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" /> |
|
|
</el-select> |
|
|
</el-select> |
|
|
{{ else }} |
|
|
|
|
|
|
|
|
{{- else }} |
|
|
<el-input v-model.number="formData.{{ .FieldJson }}" clearable placeholder="请输入" /> |
|
|
<el-input v-model.number="formData.{{ .FieldJson }}" clearable placeholder="请输入" /> |
|
|
{{ end -}} |
|
|
|
|
|
{{ end -}} |
|
|
|
|
|
{{ if eq .FieldType "time.Time" }} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "time.Time" }} |
|
|
<el-date-picker type="date" placeholder="选择日期" v-model="formData.{{ .FieldJson }}" clearable /> |
|
|
<el-date-picker type="date" placeholder="选择日期" v-model="formData.{{ .FieldJson }}" clearable /> |
|
|
{{ end -}} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
{{- if eq .FieldType "float64" }} |
|
|
{{- if eq .FieldType "float64" }} |
|
|
<el-input-number v-model="formData.{{ .FieldJson }}" :precision="2" clearable /> |
|
|
<el-input-number v-model="formData.{{ .FieldJson }}" :precision="2" clearable /> |
|
|
{{ end -}} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
{{- end }} |
|
|
{{- end }} |
|
|
</el-form> |
|
|
</el-form> |
|
@ -127,6 +128,23 @@ import { formatTimeToStr } from '@/utils/date' |
|
|
import infoList from '@/mixins/infoList' |
|
|
import infoList from '@/mixins/infoList' |
|
|
export default { |
|
|
export default { |
|
|
name: '{{.StructName}}', |
|
|
name: '{{.StructName}}', |
|
|
|
|
|
filters: { |
|
|
|
|
|
formatDate: function(time) { |
|
|
|
|
|
if (time !== null && time !== '') { |
|
|
|
|
|
var date = new Date(time) |
|
|
|
|
|
return formatTimeToStr(date, 'yyyy-MM-dd hh:mm:ss') |
|
|
|
|
|
} else { |
|
|
|
|
|
return '' |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
formatBoolean: function(bool) { |
|
|
|
|
|
if (bool != null) { |
|
|
|
|
|
return bool ? '是' : '否' |
|
|
|
|
|
} else { |
|
|
|
|
|
return '' |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
mixins: [infoList], |
|
|
mixins: [infoList], |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
@ -135,66 +153,49 @@ export default { |
|
|
type: '', |
|
|
type: '', |
|
|
deleteVisible: false, |
|
|
deleteVisible: false, |
|
|
multipleSelection: [], |
|
|
multipleSelection: [], |
|
|
{{ range .Fields}} |
|
|
|
|
|
|
|
|
{{- range .Fields}} |
|
|
{{- if .DictType }} |
|
|
{{- if .DictType }} |
|
|
{{ .DictType }}Options: [], |
|
|
{{ .DictType }}Options: [], |
|
|
{{ end -}} |
|
|
|
|
|
{{ end }} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- end }} |
|
|
formData: { |
|
|
formData: { |
|
|
{{range .Fields}} |
|
|
|
|
|
{{- if eq .FieldType "bool" -}} |
|
|
|
|
|
|
|
|
{{- range .Fields}} |
|
|
|
|
|
{{- if eq .FieldType "bool" }} |
|
|
{{.FieldJson}}: false, |
|
|
{{.FieldJson}}: false, |
|
|
{{ end -}} |
|
|
|
|
|
{{- if eq .FieldType "string" -}} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "string" }} |
|
|
{{.FieldJson}}: '', |
|
|
{{.FieldJson}}: '', |
|
|
{{ end -}} |
|
|
|
|
|
{{- if eq .FieldType "int" -}} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "int" }} |
|
|
{{.FieldJson}}: 0, |
|
|
{{.FieldJson}}: 0, |
|
|
{{ end -}} |
|
|
|
|
|
{{- if eq .FieldType "time.Time" -}} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "time.Time" }} |
|
|
{{.FieldJson}}: new Date(), |
|
|
{{.FieldJson}}: new Date(), |
|
|
{{ end -}} |
|
|
|
|
|
{{- if eq .FieldType "float64" -}} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "float64" }} |
|
|
{{.FieldJson}}: 0, |
|
|
{{.FieldJson}}: 0, |
|
|
{{ end -}} |
|
|
|
|
|
{{ end }} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
filters: { |
|
|
|
|
|
formatDate: function(time) { |
|
|
|
|
|
if (time !== null && time !== '') { |
|
|
|
|
|
var date = new Date(time); |
|
|
|
|
|
return formatTimeToStr(date, 'yyyy-MM-dd hh:mm:ss'); |
|
|
|
|
|
} else { |
|
|
|
|
|
return '' |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
formatBoolean: function(bool) { |
|
|
|
|
|
if (bool != null) { |
|
|
|
|
|
return bool ? '是' : '否' |
|
|
|
|
|
} else { |
|
|
|
|
|
return '' |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- end }} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
async created() { |
|
|
async created() { |
|
|
await this.getTableData() |
|
|
await this.getTableData() |
|
|
{{ range .Fields -}} |
|
|
|
|
|
|
|
|
{{- range .Fields }} |
|
|
{{- if .DictType }} |
|
|
{{- if .DictType }} |
|
|
await this.getDict('{{.DictType}}') |
|
|
await this.getDict('{{.DictType}}') |
|
|
{{ end -}} |
|
|
|
|
|
{{- end }} |
|
|
{{- end }} |
|
|
|
|
|
{{- end }} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
// 条件搜索前端看此方法 |
|
|
// 条件搜索前端看此方法 |
|
|
onSubmit() { |
|
|
onSubmit() { |
|
|
this.page = 1 |
|
|
this.page = 1 |
|
|
this.pageSize = 10 |
|
|
this.pageSize = 10 |
|
|
{{- range .Fields}} {{- if eq .FieldType "bool" }} |
|
|
|
|
|
|
|
|
{{- range .Fields}}{{- if eq .FieldType "bool" }} |
|
|
if (this.searchInfo.{{.FieldJson}} === ""){ |
|
|
if (this.searchInfo.{{.FieldJson}} === ""){ |
|
|
this.searchInfo.{{.FieldJson}}=null |
|
|
this.searchInfo.{{.FieldJson}}=null |
|
|
} {{ end }} {{ end }} |
|
|
|
|
|
|
|
|
}{{ end }}{{ end }} |
|
|
this.getTableData() |
|
|
this.getTableData() |
|
|
}, |
|
|
}, |
|
|
handleSelectionChange(val) { |
|
|
handleSelectionChange(val) { |
|
@ -246,23 +247,23 @@ export default { |
|
|
closeDialog() { |
|
|
closeDialog() { |
|
|
this.dialogFormVisible = false |
|
|
this.dialogFormVisible = false |
|
|
this.formData = { |
|
|
this.formData = { |
|
|
{{range .Fields}} |
|
|
|
|
|
{{- if eq .FieldType "bool" -}} |
|
|
|
|
|
|
|
|
{{- range .Fields}} |
|
|
|
|
|
{{- if eq .FieldType "bool" }} |
|
|
{{.FieldJson}}: false, |
|
|
{{.FieldJson}}: false, |
|
|
{{ end -}} |
|
|
|
|
|
{{- if eq .FieldType "string" -}} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "string" }} |
|
|
{{.FieldJson}}: '', |
|
|
{{.FieldJson}}: '', |
|
|
{{ end -}} |
|
|
|
|
|
{{- if eq .FieldType "int" -}} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "int" }} |
|
|
{{.FieldJson}}: 0, |
|
|
{{.FieldJson}}: 0, |
|
|
{{ end -}} |
|
|
|
|
|
{{- if eq .FieldType "time.Time" -}} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "time.Time" }} |
|
|
{{.FieldJson}}: new Date(), |
|
|
{{.FieldJson}}: new Date(), |
|
|
{{ end -}} |
|
|
|
|
|
{{- if eq .FieldType "float64" -}} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- if eq .FieldType "float64" }} |
|
|
{{.FieldJson}}: 0, |
|
|
{{.FieldJson}}: 0, |
|
|
{{ end -}} |
|
|
|
|
|
{{ end }} |
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
|
|
{{- end }} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
async delete{{.StructName}}(row) { |
|
|
async delete{{.StructName}}(row) { |
|
@ -272,7 +273,7 @@ export default { |
|
|
type: 'success', |
|
|
type: 'success', |
|
|
message: '删除成功' |
|
|
message: '删除成功' |
|
|
}) |
|
|
}) |
|
|
if (this.tableData.length === 1 && this.page > 1 ) { |
|
|
|
|
|
|
|
|
if (this.tableData.length === 1 && this.page > 1) { |
|
|
this.page-- |
|
|
this.page-- |
|
|
} |
|
|
} |
|
|
this.getTableData() |
|
|
this.getTableData() |
|
@ -281,10 +282,10 @@ export default { |
|
|
async enterDialog() { |
|
|
async enterDialog() { |
|
|
let res |
|
|
let res |
|
|
switch (this.type) { |
|
|
switch (this.type) { |
|
|
case "create": |
|
|
|
|
|
|
|
|
case 'create': |
|
|
res = await create{{.StructName}}(this.formData) |
|
|
res = await create{{.StructName}}(this.formData) |
|
|
break |
|
|
break |
|
|
case "update": |
|
|
|
|
|
|
|
|
case 'update': |
|
|
res = await update{{.StructName}}(this.formData) |
|
|
res = await update{{.StructName}}(this.formData) |
|
|
break |
|
|
break |
|
|
default: |
|
|
default: |
|
|