增加模版

This commit is contained in:
wuweihua
2026-10-22 14:46:52 +08:00
parent c064d925ca
commit f07386f4aa
16 changed files with 1129 additions and 26 deletions
@@ -198,6 +198,11 @@ const props = defineProps({
type: Function,
default: null
},
// System template file_code (sys_file_template); preferred over static templateUrl
templateFileCode: {
type: String,
default: ''
},
// 确定按钮文字
submitText: {
type: String,
@@ -229,7 +234,9 @@ const uploadUrl = computed(() => {
return import.meta.env.VITE_APP_BASE_API + props.action + '?' + query.toString()
})
const hasTemplate = computed(() => !!(props.templateDownloadHandler || props.templateUrl || props.templateAction))
const hasTemplate = computed(() => !!(
props.templateDownloadHandler || props.templateFileCode || props.templateUrl || props.templateAction
))
// 打开对话框(供父组件通过 ref 调用)
function open() {
@@ -254,7 +261,7 @@ function handleClosed() {
selectedFiles.value = []
}
// 下载模板:自定义 handler > 静态文件 > 接口 proxy.download
// Download: custom handler > system fileCode (OSS) > static url > proxy.download
async function handleDownloadTemplate() {
if (typeof props.templateDownloadHandler === 'function') {
try {
@@ -265,6 +272,16 @@ async function handleDownloadTemplate() {
}
return
}
if (props.templateFileCode) {
try {
const { downloadFileTemplate } = await import('@/api/system/fileTemplate')
await downloadFileTemplate(props.templateFileCode, props.templateFileName)
} catch (e) {
const tip = (e && e.message) ? e.message : '下载模板失败'
proxy.$modal.msgError(tip)
}
return
}
if (props.templateUrl) {
const link = document.createElement('a')
link.href = props.templateUrl