feature:自动化代码增加数据源配置功能
This commit is contained in:
@@ -140,8 +140,11 @@ func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}InfoLis
|
||||
|
||||
{{- if .HasDataSource }}
|
||||
func ({{.Abbreviation}}Service *{{.StructName}}Service)Get{{.StructName}}DataSource() (res map[string][]map[string]any, err error) {
|
||||
res = make(map[string][]map[string]any)
|
||||
{{range $key, $value := .DataSourceMap}}
|
||||
{{$db}}.Table("{{$value.Table}}").Select("{{$value.Label}} as label,{{$value.Value}} as value").Scan(&res["{{$key}}"])
|
||||
{{$key}} := make([]map[string]any, 0)
|
||||
{{$db}}.Table("{{$value.Table}}").Select("{{$value.Label}} as label,{{$value.Value}} as value").Scan(&{{$key}})
|
||||
res["{{$key}}"] = {{$key}}
|
||||
{{- end }}
|
||||
return
|
||||
}
|
||||
|
@@ -164,6 +164,7 @@ const elFormRef = ref()
|
||||
dataSource.value = res.data
|
||||
}
|
||||
}
|
||||
getDataSourceFunc()
|
||||
{{- end }}
|
||||
|
||||
// 初始化方法
|
||||
|
@@ -109,6 +109,7 @@
|
||||
<template #default="scope">
|
||||
{{"{{"}} filterDataSource(dataSource.{{.FieldJson}},scope.row.{{.FieldJson}}) {{"}}"}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if .DictType}}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
|
||||
<template #default="scope">
|
||||
@@ -369,6 +370,7 @@ const formData = ref({
|
||||
dataSource.value = res.data
|
||||
}
|
||||
}
|
||||
getDataSourceFunc()
|
||||
{{- end }}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user