From e5c1ba067eb7c1c9436d442cca99389cd976408e Mon Sep 17 00:00:00 2001 From: Yuikill <1191184301@qq.com> Date: Thu, 26 Sep 2024 17:36:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=8C=E7=9B=AE=E5=BD=95=E4=B8=8B?= =?UTF-8?q?=E4=B8=8A=E4=BC=A02500=E4=B8=AA=E6=96=87=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../import-file/import-from-local-file.vue | 76 +++++++++++++------ 1 file changed, 54 insertions(+), 22 deletions(-) diff --git a/bcs-services/bcs-bscp/ui/src/views/space/service/detail/config/config-list/config-table-list/create-config/import-file/import-from-local-file.vue b/bcs-services/bcs-bscp/ui/src/views/space/service/detail/config/config-list/config-table-list/create-config/import-file/import-from-local-file.vue index d343524ab4..3f6e99d356 100644 --- a/bcs-services/bcs-bscp/ui/src/views/space/service/detail/config/config-list/config-table-list/create-config/import-file/import-from-local-file.vue +++ b/bcs-services/bcs-bscp/ui/src/views/space/service/detail/config/config-list/config-table-list/create-config/import-file/import-from-local-file.vue @@ -12,7 +12,9 @@ theme="button" :size="100000" :multiple="true" - :custom-request="handleFileUpload"> + :limit="10" + :custom-request="handleFileUpload" + @exceed="handleExceed"> +
{{ isOpenFileList ? $t('收起上传列表') : $t('展开上传列表') }}
-
-
+ +
- - + +
- -
{{ fileItem.file.name }}
-
-
+
+
{{ item.file.name }}
+
+
- -
{{ fileItem.errorMessage }}
-
+
+
{{ item.errorMessage }}
+
- +
-
+
@@ -71,6 +74,7 @@ status: string; progress: number; errorMessage?: string; + id: string; } const { t } = useI18n(); @@ -90,6 +94,7 @@ const isDecompression = ref(true); const isOpenFileList = ref(true); const fileList = ref([]); + const multipleUploading = ref(false); // 是否是多个文件上传 const uploadTips = computed(() => { if (isDecompression.value) { @@ -103,7 +108,7 @@ watch( () => fileList.value, () => { - if (fileList.value.some((fileItem) => fileItem.status === 'uploading')) { + if (fileList.value.some((fileItem) => fileItem.status === 'uploading') || multipleUploading.value) { emits('uploading', true); } else { emits('uploading', false); @@ -161,11 +166,15 @@ if (fileList.value.find((fileItem) => fileItem.file.name === option.file.name)) { handleDeleteFile(option.file.name); } - fileList.value?.push({ - file: option.file, - status: 'uploading', - progress: 0, - }); + fileList.value = [ + ...fileList.value, + { + file: option.file, + status: 'uploading', + progress: 0, + id: `${option.file.name}-${Date.now()}`, + }, + ]; let res; if (props.isTemplate) { res = await importTemplateFile( @@ -223,6 +232,25 @@ const ext = filename.split('.').pop()!.toLowerCase(); return ['zip', 'rar', 'tar', 'gz', 'tgz'].includes(ext); }; + + const handleExceed = async (files: any) => { + multipleUploading.value = true; + let index = 0; + const uploadNext = async () => { + if (index < files.length) { + index += 1; + const file = files[index]; + await handleFileUpload({ file }); + await uploadNext(); + } + }; + const uploadPromises = []; + for (let i = 0; i < 5; i++) { + uploadPromises.push(uploadNext()); + } + await Promise.allSettled(uploadPromises); + multipleUploading.value = false; + };