提交 fc605271 编写于 作者: P piexlMax

增加自动化代码图片功能

上级 7c02634a
......@@ -27,6 +27,7 @@ type AutoCodeStruct struct {
PackageT string `json:"-"`
NeedValid bool `json:"-"`
NeedSort bool `json:"-"`
HasPic bool `json:"-"`
}
func (a *AutoCodeStruct) Pretreatment() {
......
......@@ -11,10 +11,10 @@ type {{.StructName}} struct {
global.GVA_MODEL {{- range .Fields}}
{{- if eq .FieldType "enum" }}
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};type:enum({{.DataTypeLong}});comment:{{.Comment}};"`
{{- else if eq .FieldType "picture" }}
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}"`
{{- else if ne .FieldType "string" }}
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}"`
{{- else if qe .FieldType "picture" }}
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}"`
{{- else }}
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}"`
{{- end }} {{- end }}
......
......@@ -62,7 +62,7 @@ import { getDictFunc } from '@/utils/format'
import { useRoute, useRouter } from "vue-router"
import { ElMessage } from 'element-plus'
import { ref, reactive } from 'vue'
{{- if eq .FieldType "picture" }}
{{- if .HasPic }}
import SelectImage from '@/components/selectImage/selectImage.vue'
{{- end }}
const route = useRoute()
......
......@@ -169,7 +169,7 @@
</el-select>
{{- end }}
{{- if eq .FieldType "picture" }}
<SelectImage v-model="formData.{{ .FieldJson }}" />
<SelectImage v-model="getUrl(formData.{{ .FieldJson }})" />
{{- end }}
</el-form-item>
{{- end }}
......@@ -200,8 +200,9 @@ import {
get{{.StructName}}List
} from '@/api/{{.PackageName}}'
{{- if eq .FieldType "picture" }}
{{- if .HasPic }}
// 图片选择组件
import { getUrl } from '@/utils/image'
import SelectImage from '@/components/selectImage/selectImage.vue'
{{- end }}
......
......@@ -141,6 +141,9 @@ func (autoCodeService *AutoCodeService) PreviewTemp(autoCode system.AutoCodeStru
if autoCode.Fields[i].Sort {
autoCode.NeedSort = true
}
if autoCode.Fields[i].FieldType == "picture" {
autoCode.HasPic = true
}
}
dataList, _, needMkdir, err := autoCodeService.getNeedList(&autoCode)
if err != nil {
......@@ -231,6 +234,9 @@ func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruc
if autoCode.Fields[i].Sort {
autoCode.NeedSort = true
}
if autoCode.Fields[i].FieldType == "picture" {
autoCode.HasPic = true
}
}
// 增加判断: 重复创建struct
if autoCode.AutoMoveFile && AutoCodeHistoryServiceApp.Repeat(autoCode.BusinessDB, autoCode.StructName, autoCode.Package) {
......
......@@ -20,14 +20,14 @@
<upload-common
v-model:imageCommon="imageCommon"
class="upload-btn-media-library"
@on-success="open"
@on-success="getImageList"
/>
<upload-image
v-model:imageUrl="imageUrl"
:file-size="512"
:max-w-h="1080"
class="upload-btn-media-library"
@on-success="open"
@on-success="getImageList"
/>
<el-form ref="searchForm" :inline="true" :model="search">
<el-form-item label="">
......@@ -35,7 +35,7 @@
</el-form-item>
<el-form-item>
<el-button type="primary" icon="search" @click="open">查询</el-button>
<el-button type="primary" icon="search" @click="getImageList">查询</el-button>
</el-form-item>
</el-form>
</div>
......@@ -103,12 +103,12 @@ const emits = defineEmits(['update:modelValue'])
// 分页
const handleSizeChange = (val) => {
pageSize.value = val
openChooseImg()
getImageList()
}
const handleCurrentChange = (val) => {
page.value = val
openChooseImg()
getImageList()
}
const editFileNameFunc = async(row) => {
ElMessageBox.prompt('请输入文件名或者备注', '编辑', {
......@@ -126,7 +126,7 @@ const editFileNameFunc = async(row) => {
type: 'success',
message: '编辑成功!',
})
openChooseImg()
getImageList()
}
}).catch(() => {
ElMessage({
......@@ -144,13 +144,17 @@ const chooseImg = (url) => {
drawer.value = false
}
const openChooseImg = async() => {
await getImageList()
drawer.value = true
}
const getImageList = async() => {
const res = await getFileList({ page: page.value, pageSize: pageSize.value, ...search.value })
if (res.code === 0) {
picList.value = res.data.list
total.value = res.data.total
page.value = res.data.page
pageSize.value = res.data.pageSize
drawer.value = true
}
}
......@@ -161,10 +165,10 @@ const openChooseImg = async() => {
width: 120px;
height: 120px;
line-height: 120px;
margin: 0 auto;
display: flex;
justify-content: center;
border-radius: 20px;
border: 1px dashed #ccc;
background-repeat: no-repeat;
background-size: cover;
&:hover {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册