diff --git a/server/resource/autocode_template/web/table.vue.tpl b/server/resource/autocode_template/web/table.vue.tpl index 56d86ea38..38db32aad 100644 --- a/server/resource/autocode_template/web/table.vue.tpl +++ b/server/resource/autocode_template/web/table.vue.tpl @@ -159,6 +159,10 @@ {{- end }} @@ -177,50 +181,52 @@ - - {{- range .Fields}} - - {{- if eq .FieldType "bool" }} - - {{- end }} - {{- if eq .FieldType "string" }} - - {{- end }} - {{- if eq .FieldType "richtext" }} - - {{- end }} - {{- if eq .FieldType "int" }} - {{- if .DictType}} - - - - {{- else }} - - {{- end }} - {{- end }} - {{- if eq .FieldType "time.Time" }} - - {{- end }} - {{- if eq .FieldType "float64" }} - - {{- end }} - {{- if eq .FieldType "enum" }} - - - - {{- end }} - {{- if eq .FieldType "picture" }} - - {{- end }} - {{- if eq .FieldType "pictures" }} - - {{- end }} - {{- if eq .FieldType "file" }} - - {{- end }} - - {{- end }} - + + + {{- range .Fields}} + + {{- if eq .FieldType "bool" }} + + {{- end }} + {{- if eq .FieldType "string" }} + + {{- end }} + {{- if eq .FieldType "richtext" }} + + {{- end }} + {{- if eq .FieldType "int" }} + {{- if .DictType}} + + + + {{- else }} + + {{- end }} + {{- end }} + {{- if eq .FieldType "time.Time" }} + + {{- end }} + {{- if eq .FieldType "float64" }} + + {{- end }} + {{- if eq .FieldType "enum" }} + + + + {{- end }} + {{- if eq .FieldType "picture" }} + + {{- end }} + {{- if eq .FieldType "pictures" }} + + {{- end }} + {{- if eq .FieldType "file" }} + + {{- end }} + + {{- end }} + + + + + + + {{- range .Fields}} + + {{- if and (ne .FieldType "picture" ) (ne .FieldType "pictures" ) (ne .FieldType "file" ) }} + {{"{{"}} formData.{{.FieldJson}} {{"}}"}} + {{- else }} + {{- if eq .FieldType "picture" }} + + {{- end }} + {{- if eq .FieldType "pictures" }} + + {{- end }} + {{- if eq .FieldType "file" }} +
+ + + {{item.name}} + +
+ {{- end }} + {{- end }} +
+ {{- end }} +
+
+
@@ -267,7 +302,7 @@ import SelectFile from '@/components/selectFile/selectFile.vue' {{- end }} // 全量引入格式化工具 请按需保留 -import { getDictFunc, formatDate, formatBoolean, filterDict } from '@/utils/format' +import { getDictFunc, formatDate, formatBoolean, filterDict, ReturnArrImg, onDownloadFile } from '@/utils/format' import { ElMessage, ElMessageBox } from 'element-plus' import { ref, reactive } from 'vue' @@ -340,7 +375,7 @@ const searchRule = reactive({ }, trigger: 'change' } ], {{- range .Fields }} - {{- if .FieldSearchType}} + {{- if .FieldSearchType}} {{- if eq .FieldType "time.Time" }} {{.FieldJson }} : [{ validator: (rule, value, callback) => { if (searchInfo.value.start{{.FieldName}} && !searchInfo.value.end{{.FieldName}}) { @@ -517,6 +552,53 @@ const delete{{.StructName}}Func = async (row) => { // 弹窗控制标记 const dialogFormVisible = ref(false) + +// 查看详情控制标记 +const detailShow = ref(false) + + +// 打开详情弹窗 +const openDetailShow = () => { + detailShow.value = true +} + + +// 打开详情 +const getDetails = async (row) => { + // 打开弹窗 + const res = await find{{.StructName}}({ ID: row.ID }) + if (res.code === 0) { + formData.value = res.data.re{{.Abbreviation}} + openDetailShow() + } +} + + +// 关闭详情弹窗 +const closeDetailShow = () => { + detailShow.value = false + formData.value = { + {{- range .Fields}} + {{- if eq .FieldType "bool" }} + {{.FieldJson}}: false, + {{- end }} + {{- if eq .FieldType "string" }} + {{.FieldJson}}: '', + {{- end }} + {{- if eq .FieldType "int" }} + {{.FieldJson}}: {{- if .DictType }} undefined{{ else }} 0{{- end }}, + {{- end }} + {{- if eq .FieldType "time.Time" }} + {{.FieldJson}}: new Date(), + {{- end }} + {{- if eq .FieldType "float64" }} + {{.FieldJson}}: 0, + {{- end }} + {{- end }} + } +} + + // 打开弹窗 const openDialog = () => { type.value = 'create' @@ -586,5 +668,13 @@ const downloadFile = (url) => { flex-wrap: wrap; gap: 4px; } + +.fileBtn{ + margin-bottom: 10px; +} + +.fileBtn:last-child{ + margin-bottom: 0; +} {{end}} diff --git a/web/src/utils/format.js b/web/src/utils/format.js index b8361be33..da213dead 100644 --- a/web/src/utils/format.js +++ b/web/src/utils/format.js @@ -26,3 +26,29 @@ export const getDictFunc = async(type) => { const dicts = await getDict(type) return dicts } + +const path = import.meta.env.VITE_BASE_PATH + ':' + import.meta.env.VITE_SERVER_PORT + '/' +export const ReturnArrImg = (arr) => { + let imgArr = [] + if (arr instanceof Array){ // 如果是数组类型 + for (let arrKey in arr) { + if (arr[arrKey].slice(0, 4) !== 'http'){ + imgArr.push(path + arr[arrKey]) + }else { + imgArr.push(arr[arrKey]) + } + } + }else { // 如果不是数组类型 + if (arr.slice(0, 4) !== 'http'){ + imgArr.push(path + arr) + }else { + imgArr.push(arr) + } + } + return imgArr +} + +export const onDownloadFile = (url) => { + window.open(path + url) + +} \ No newline at end of file