mirror of
https://github.com/flipped-aurora/gin-vue-admin.git
synced 2026-09-21 12:32:25 +00:00
增加自动化代码文件组件
This commit is contained in:
@@ -4,6 +4,7 @@ package {{.Package}}
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
{{ if .HasTimer }}"time"{{ end }}
|
||||
{{ if .HasFile }}"gorm.io/datatypes"{{ end }}
|
||||
)
|
||||
|
||||
// {{.StructName}} 结构体
|
||||
@@ -13,6 +14,8 @@ type {{.StructName}} struct {
|
||||
{{.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 eq .FieldType "file" }}
|
||||
{{.FieldName}} datatypes.JSON `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 }}
|
||||
|
||||
@@ -65,6 +65,9 @@ import { ref, reactive } from 'vue'
|
||||
{{- if .HasPic }}
|
||||
import SelectImage from '@/components/selectImage/selectImage.vue'
|
||||
{{- end }}
|
||||
{{- if .HasFile }}
|
||||
import SelectFile from '@/components/selectFile/selectFile.vue'
|
||||
{{- end }}
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
|
||||
@@ -115,6 +115,14 @@
|
||||
<el-image style="width: 100px; height: 100px" :src="getUrl(scope.row.{{.FieldJson}})" fit="cover"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "file" }}
|
||||
<el-table-column label="{{.FieldDesc}}" width="200">
|
||||
<template #default="scope">
|
||||
<div class="file-list">
|
||||
<el-tag v-for="file in scope.row.{{.FieldJson}}" :key="file.uid">{{"{{"}}file.name{{"}}"}}</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else }}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120" />
|
||||
{{- end }}
|
||||
@@ -138,7 +146,7 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog v-model="dialogFormVisible" :before-close="closeDialog" title="弹窗操作">
|
||||
<el-dialog v-model="dialogFormVisible" :before-close="closeDialog" title="弹窗操作" destroy-on-close>
|
||||
<el-form :model="formData" label-position="right" ref="elFormRef" :rules="rule" label-width="80px">
|
||||
{{- range .Fields}}
|
||||
<el-form-item label="{{.FieldDesc}}:" prop="{{.FieldJson}}" >
|
||||
@@ -170,6 +178,9 @@
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "picture" }}
|
||||
<SelectImage v-model="formData.{{ .FieldJson }}" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "file" }}
|
||||
<SelectFile v-model="formData.{{ .FieldJson }}" />
|
||||
{{- end }}
|
||||
</el-form-item>
|
||||
{{- end }}
|
||||
@@ -206,6 +217,12 @@ import { getUrl } from '@/utils/image'
|
||||
import SelectImage from '@/components/selectImage/selectImage.vue'
|
||||
{{- end }}
|
||||
|
||||
{{- if .HasFile }}
|
||||
// 文件选择组件
|
||||
import { getUrl } from '@/utils/image'
|
||||
import SelectFile from '@/components/selectFile/selectFile.vue'
|
||||
{{- end }}
|
||||
|
||||
// 全量引入格式化工具 请按需保留
|
||||
import { getDictFunc, formatDate, formatBoolean, filterDict } from '@/utils/format'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
@@ -459,7 +476,19 @@ const enterDialog = async () => {
|
||||
}
|
||||
})
|
||||
}
|
||||
{{if eq .FieldType "file"}}
|
||||
const downloadFile = (url) => {
|
||||
window.open(getUrl(url), '_blank')
|
||||
}
|
||||
{{end}}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
{{if eq .FieldType "file"}}
|
||||
.file-list{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
{{end}}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user