奇淼(piexlmax
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
29 additions and
19 deletions
-
server/model/system/sys_auto_code.go
-
server/resource/template/web/form.vue.tpl
-
server/resource/template/web/table.vue.tpl
-
server/service/system/sys_auto_code.go
-
web/src/components/customPic/index.vue
|
|
@ -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 { |
|
|
|
|
|
@ -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: { |
|
|
|
|
|
@ -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: { |
|
|
|
|
|
@ -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 |
|
|
|
|
|
@ -1,12 +1,12 @@ |
|
|
|
<template> |
|
|
|
<span class="headerAvatar"> |
|
|
|
<template v-if="picType === 'avatar'"> |
|
|
|
<el-avatar v-if="userInfo.headerImg" :size="24" :src="avatar" /> |
|
|
|
<el-avatar v-else :size="24" :src="require('@/assets/noBody.png')" /> |
|
|
|
<el-avatar v-if="userInfo.headerImg" :size="30" :src="avatar" /> |
|
|
|
<el-avatar v-else :size="30" :src="noAvatar" /> |
|
|
|
</template> |
|
|
|
<template v-if="picType === 'img'"> |
|
|
|
<img v-if="userInfo.headerImg" :src="avatar" class="avatar"> |
|
|
|
<img v-else :src="require('@/assets/noBody.png')" class="avatar"> |
|
|
|
<img v-else :src="noAvatar" class="avatar"> |
|
|
|
</template> |
|
|
|
<template v-if="picType === 'file'"> |
|
|
|
<img :src="file" class="file"> |
|
|
@ -15,6 +15,7 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import noAvatar from '@/assets/noBody.png' |
|
|
|
import { mapGetters } from 'vuex' |
|
|
|
const path = import.meta.env.VITE_BASE_API |
|
|
|
export default { |
|
|
@ -33,6 +34,7 @@ export default { |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
noAvatar: noAvatar, |
|
|
|
path: path + '/' |
|
|
|
} |
|
|
|
}, |
|
|
|