From 7c01f69a2407e47c57dfe2c63e38159497e29bfa Mon Sep 17 00:00:00 2001 From: 2910410219 <2910410219@qq.com> Date: Tue, 7 Jul 2026 18:11:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=B4=E7=89=87=E6=A8=A1=E7=89=88=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../patchTemplate/PatchTemplateEditor.vue | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/patchTemplate/PatchTemplateEditor.vue b/src/components/patchTemplate/PatchTemplateEditor.vue index fd9c3d3..5cb1723 100644 --- a/src/components/patchTemplate/PatchTemplateEditor.vue +++ b/src/components/patchTemplate/PatchTemplateEditor.vue @@ -20,14 +20,14 @@ :accept="'.html,.htm'" :on-change="(file: any) => handleTemplateUpload(index, file)" > - - 上传模板 + + {{ uploadingIndex === index ? '上传中...' : (template.url ? '替换模板' : '上传模板') }} 下载参考模板 - 已上传 + {{ template.url === DEFAULT_TEMPLATE_URL ? '已有默认模板' : '已上传' }} @@ -166,6 +166,8 @@ function nextImageKey(template: PatchTemplate): string | null { return null; } +const DEFAULT_TEMPLATE_URL = 'https://cdn.redpowerfuture.com/tenantid-1/template_example1.html'; + const props = defineProps<{ modelValue: PatchTemplate[]; }>(); @@ -177,6 +179,8 @@ const emit = defineEmits<{ // 图片预览 const previewVisible = ref(false); const previewUrl = ref(''); +// 模板文件上传状态(记录正在上传的模板索引) +const uploadingIndex = ref(null); const previewImage = (url: string) => { previewUrl.value = url; @@ -189,7 +193,7 @@ const updateTemplates = (newTemplates: PatchTemplate[]) => { const addTemplate = () => { const newTemplate: PatchTemplate = { - url: '', + url: DEFAULT_TEMPLATE_URL, start: 0, end: 0, data: { @@ -244,6 +248,7 @@ const removeProductImage = (template: PatchTemplate, imgIdx: number) => { const handleTemplateUpload = async (index: number, file: any) => { const raw = file.raw; if (!raw) return; + uploadingIndex.value = index; try { const uploadRes = await uploadFile(raw, { timeout: 0 }); @@ -255,9 +260,10 @@ const handleTemplateUpload = async (index: number, file: any) => { newList[index].url = fileUrl; updateTemplates(newList); - ElMessage.success('模板上传成功'); } catch (error: any) { - ElMessage.error(error?.message || '模板上传失败'); + ElMessage.error(error?.message || "模板上传失败"); + } finally { + uploadingIndex.value = null; } };