diff --git a/template/vue.go.template b/template/vue.go.template index 128bcdc..305d1ad 100644 --- a/template/vue.go.template +++ b/template/vue.go.template @@ -183,7 +183,7 @@ isEdit: false, // 类型数据字典 typeOptions: [], - list{{.ClassName}}: [], + {{.ModuleName}}List: [], {{range .Columns}} {{- if ne .DictType "" -}} {{.JsonField}}Options: [], @@ -222,11 +222,13 @@ this.getList() {{range .Columns}} {{- if ne .DictType "" -}} + this.getDicts('{{.DictType}}').then(response => { this.{{.JsonField}}Options = response.data }) + + {{ end -}} {{- end -}} - {{- end }} }, methods: { /** 查询参数列表 */ @@ -256,8 +258,7 @@ {{- else if eq .GoField "UpdateBy" -}} {{- else if eq .GoField "CreateBy" -}} {{- else }} - {{.JsonField}}: - undefined, + {{.JsonField}}: undefined, {{- end }} {{- end -}} {{- end }} @@ -269,7 +270,7 @@ {{.JsonField}}Format(row) { return this.selectDictLabel(this.{{.JsonField}}Options, row.{{.JsonField}}) }, - {{- end -}} + {{ end -}} {{- end }} /** 搜索按钮操作 */ diff --git a/tools/string.go b/tools/string.go index a98c82b..750172d 100644 --- a/tools/string.go +++ b/tools/string.go @@ -29,6 +29,12 @@ func GetCurrentTime() time.Time { return time.Now() } +func FormatTimeStr(timeStr string) (string, error) { + loc, _ := time.LoadLocation("Local") + theTime, err := time.ParseInLocation("2006-01-02T15:04:05.000Z", timeStr, loc) + return theTime.Format("2006/01/02 15:04:05"), err +} + func StructToJsonStr(e interface{}) (string, error) { if b, err := json.Marshal(e); err == nil { return string(b), err