From c119285f81451d3cacabc896137c2bf5fce1d0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=98=89=E8=B1=AA?= <42510293+ziyujiahao@users.noreply.github.com> Date: Mon, 9 Mar 2026 18:20:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E7=BB=84=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=89=87=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=97=B6=E7=AD=89=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=20(#1804?= =?UTF-8?q?3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core-frontend/src/api/staticResource.ts | 10 +++-- .../picture-group/Component.vue | 3 ++ .../picture-group/PictureGroupUploadAttr.vue | 40 +++++++++++++++---- 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/core/core-frontend/src/api/staticResource.ts b/core/core-frontend/src/api/staticResource.ts index c6a24483dc..cb245a70e0 100644 --- a/core/core-frontend/src/api/staticResource.ts +++ b/core/core-frontend/src/api/staticResource.ts @@ -33,9 +33,13 @@ export function uploadFileResult(file, callback) { const fileUrl = staticResourcePath + newFileName const param = new FormData() param.append('file', file) - return uploadFile(fileId, param).then(() => { - callback(fileUrl) - }) + return uploadFile(fileId, param) + .then(() => { + callback(fileUrl, null) + }) + .catch(error => { + callback(null, error) + }) } export function findResourceAsBase64(params) { diff --git a/core/core-frontend/src/custom-component/picture-group/Component.vue b/core/core-frontend/src/custom-component/picture-group/Component.vue index 6c434f916a..457d510547 100644 --- a/core/core-frontend/src/custom-component/picture-group/Component.vue +++ b/core/core-frontend/src/custom-component/picture-group/Component.vue @@ -232,7 +232,10 @@ const conditionAdaptor = (chart: Chart) => { const withInit = () => { if (element.value.propValue['urlList'] && element.value.propValue['urlList'].length > 0) { state.showUrl = element.value.propValue['urlList'][0].url + } else { + state.showUrl = null } + initCarousel() } diff --git a/core/core-frontend/src/custom-component/picture-group/PictureGroupUploadAttr.vue b/core/core-frontend/src/custom-component/picture-group/PictureGroupUploadAttr.vue index 06a8de1854..d113f6cd1d 100644 --- a/core/core-frontend/src/custom-component/picture-group/PictureGroupUploadAttr.vue +++ b/core/core-frontend/src/custom-component/picture-group/PictureGroupUploadAttr.vue @@ -4,7 +4,7 @@ import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapsho import { storeToRefs } from 'pinia' import { ElIcon, ElMessage } from 'element-plus-secondary' -import { ref, onMounted, onBeforeUnmount, watch, PropType, computed } from 'vue' +import { ref, onMounted, onBeforeUnmount, watch, PropType, computed, nextTick } from 'vue' import { beforeUploadCheck, uploadFileResult } from '@/api/staticResource' import { imgUrlTrans } from '@/utils/imgUtils' import eventBus from '@/utils/eventBus' @@ -14,6 +14,9 @@ import { toRefs } from 'vue' import { useEmitt } from '@/hooks/web/useEmitt' const { t } = useI18n() +let uploadCount = 0 +let totalUploads = 0 + const props = defineProps({ themes: { type: String as PropType, @@ -67,10 +70,33 @@ const handleRemove = (file, fileListArray) => { } async function upload(file) { if (element.value.propValue.urlList.length < 10) { - uploadFileResult(file.file, fileUrl => { - snapshotStore.recordSnapshotCache('pic-upload') - element.value.propValue.urlList.unshift({ name: file.file.name, url: fileUrl }) - useEmitt().emitter.emit('calcData-' + element.value.id) + // 增加总任务数 + totalUploads++ + + uploadFileResult(file.file, (fileUrl, error) => { + if (error) { + // 上传失败 + console.error('上传失败:', error) + } else { + // 上传成功 + snapshotStore.recordSnapshotCache('pic-upload') + element.value.propValue.urlList.unshift({ name: file.file.name, url: fileUrl }) + useEmitt().emitter.emit('calcData-' + element.value.id) + } + + // 无论成功失败,都增加完成计数 + uploadCount++ + + // 检查是否所有上传都完成了 + if (uploadCount === totalUploads) { + // 所有图片上传完成,刷新列表 + nextTick(() => { + fileListInit() + // 重置计数器 + uploadCount = 0 + totalUploads = 0 + }) + } }) } } @@ -126,7 +152,7 @@ onBeforeUnmount(() => { accept=".jpeg,.jpg,.png,.gif,.svg" class="avatar-uploader" list-type="picture-card" - :class="{ disabled: uploadDisabled }" + :class="{ disabled: uploadDisabled || element.propValue.urlList.length >= 10 }" :on-preview="handlePictureCardPreview" :on-remove="handleRemove" :before-upload="beforeUploadCheck" @@ -200,7 +226,7 @@ onBeforeUnmount(() => { } } -.disabled :deep(.el-upload--picture-card) { +.disabled :deep(.ed-upload) { display: none; }