diff --git a/server/model/system/sys_auto_code.go b/server/model/system/sys_auto_code.go index 7047b810..99a9e2e7 100644 --- a/server/model/system/sys_auto_code.go +++ b/server/model/system/sys_auto_code.go @@ -13,6 +13,7 @@ type AutoCodeStruct struct { AutoCreateApiToSql bool `json:"autoCreateApiToSql"` // 是否自动创建api AutoMoveFile bool `json:"autoMoveFile"` // 是否自动移动文件 Fields []*Field `json:"fields"` + DictTypes []string `json:"-"` } type Field struct { diff --git a/server/resource/template/web/form.vue.tpl b/server/resource/template/web/form.vue.tpl index dc607dae..17e31158 100644 --- a/server/resource/template/web/form.vue.tpl +++ b/server/resource/template/web/form.vue.tpl @@ -49,10 +49,8 @@ export default { data() { return { type: '', - {{- range .Fields}} - {{- if .DictType }} - {{ .DictType }}Options: [], - {{- end }} + {{- range $index, $element := .DictTypes}} + {{ $element }}Options: [], {{- end }} formData: { {{- range .Fields}} @@ -86,10 +84,8 @@ export default { } else { this.type = 'create' } - {{- range .Fields }} - {{- if .DictType }} - await this.getDict('{{.DictType}}') - {{- end }} + {{- range $index, $element := .DictTypes }} + await this.getDict('{{$element}}') {{- end }} }, methods: { diff --git a/server/resource/template/web/table.vue.tpl b/server/resource/template/web/table.vue.tpl index 2999607e..2c2dde47 100644 --- a/server/resource/template/web/table.vue.tpl +++ b/server/resource/template/web/table.vue.tpl @@ -144,10 +144,8 @@ export default { type: '', deleteVisible: false, multipleSelection: [], - {{- range .Fields}} - {{- if .DictType }} - {{ .DictType }}Options: [], - {{- end }} + {{- range $index, $element := .DictTypes }} + {{ $element }}Options: [], {{- end }} formData: { {{- range .Fields}} @@ -172,10 +170,8 @@ export default { }, async created() { await this.getTableData() -{{- range .Fields }} - {{- if .DictType }} - await this.getDict('{{.DictType}}') - {{- end }} +{{- range $index, $element := .DictTypes }} + await this.getDict('{{$element}}') {{- end }} }, methods: { diff --git a/server/service/system/sys_auto_code.go b/server/service/system/sys_auto_code.go index aa605142..d73e8b0c 100644 --- a/server/service/system/sys_auto_code.go +++ b/server/service/system/sys_auto_code.go @@ -89,6 +89,7 @@ var AutoCodeServiceApp = new(AutoCodeService) //@return: map[string]string, error func (autoCodeService *AutoCodeService) PreviewTemp(autoCode system.AutoCodeStruct) (map[string]string, error) { + makeDictTypes(&autoCode) dataList, _, needMkdir, err := autoCodeService.getNeedList(&autoCode) if err != nil { return nil, err @@ -147,6 +148,19 @@ func (autoCodeService *AutoCodeService) PreviewTemp(autoCode system.AutoCodeStru return ret, nil } +func makeDictTypes(autoCode *system.AutoCodeStruct) { + DictTypeM := make(map[string]string) + for _, v := range autoCode.Fields { + if v.DictType != "" { + DictTypeM[v.DictType] = "" + } + } + + for k, _ := range DictTypeM { + autoCode.DictTypes = append(autoCode.DictTypes, k) + } +} + //@author: [piexlmax](https://github.com/piexlmax) //@function: CreateTemp //@description: 创建代码 @@ -154,6 +168,7 @@ func (autoCodeService *AutoCodeService) PreviewTemp(autoCode system.AutoCodeStru //@return: err error func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruct, ids ...uint) (err error) { + makeDictTypes(&autoCode) // 增加判断: 重复创建struct if autoCode.AutoMoveFile && AutoCodeHistoryServiceApp.Repeat(autoCode.StructName) { return RepeatErr diff --git a/web/src/components/customPic/index.vue b/web/src/components/customPic/index.vue index 7463e3e4..3c052241 100644 --- a/web/src/components/customPic/index.vue +++ b/web/src/components/customPic/index.vue @@ -1,12 +1,12 @@