From 4387037b2d68f4b8622597bd093440f5dc5ebb58 Mon Sep 17 00:00:00 2001 From: rd <1344903914@qq.com> Date: Mon, 21 Jul 2025 15:42:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=B9=E9=87=8F=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5-=E9=87=8D=E6=96=B0=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/export-task/index.vue | 38 ++++++++++++------- src/utils/arcoD.tsx | 27 ++++++++++++- 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/src/components/_base/navbar/components/task-center-modal/components/export-task/index.vue b/src/components/_base/navbar/components/task-center-modal/components/export-task/index.vue index 4ee0181..7a54ed4 100644 --- a/src/components/_base/navbar/components/task-center-modal/components/export-task/index.vue +++ b/src/components/_base/navbar/components/task-center-modal/components/export-task/index.vue @@ -11,7 +11,7 @@ import { useTableSelectionWithPagination } from '@/hooks/useTableSelectionWithPa import { downloadByUrl } from '@/utils/tools'; import DeleteTaskModal from './delete-task-modal.vue'; import icon1 from '@/assets/img/media-account/icon-delete.png'; -import { showExportNotification } from '@/utils/arcoD'; +import { showExportNotification, showFailExportNotification } from '@/utils/arcoD'; export default { setup(props, { emit, expose }) { @@ -102,12 +102,13 @@ export default { } }; - const clearQueryTaskTimer = () => { - if (queryTaskTimer) { - clearInterval(queryTaskTimer); - queryTaskTimer = null; + // 批量下载 + const handleBatchDownload = debounce(async () => { + const { code, data } = await postBatchDownload({ ids: selectedRowKeys.value }); + if (code === 200) { + startBatchDownload(data.id); } - }; + }, 500); const startBatchDownload = (id) => { const randomId = genRandomId(); showExportNotification( @@ -122,17 +123,10 @@ export default { randomId, }); - // getSyncTaskStatus(randomId); if (!queryTaskTimer) { queryTaskTimer = setInterval(() => getSyncTaskStatus(), 3000); } }; - const handleBatchDownload = debounce(async () => { - const { code, data } = await postBatchDownload({ ids: selectedRowKeys.value }); - if (code === 200) { - startBatchDownload(data.id); - } - }, 500); const getSyncTaskStatus = async () => { const { code, data } = await batchQueryTaskStatus({ ids: downloadTaskIds.value.map((v) => v.id) }); if (code === 200) { @@ -149,8 +143,17 @@ export default { AMessage.success('批量下载已完成,正在下载文件...'); downloadByUrl(file); } else if (status === 2) { - AMessage.error('批量下载失败,请重新尝试下载'); + const onReDownload = () => { + startBatchDownload(id); + }; + showFailExportNotification( + `${selectedRows.value[0]?.name}”等${selectedRows.value.length}个文件下载失败`, + { onReDownload }, + ); } + + // 结束的任务过滤掉 + downloadTaskIds.value = downloadTaskIds.value.filter((v) => v.id !== id); } }); @@ -182,6 +185,13 @@ export default { selectedRowKeys.value = []; getData(); }; + + const clearQueryTaskTimer = () => { + if (queryTaskTimer) { + clearInterval(queryTaskTimer); + queryTaskTimer = null; + } + }; const unloadComp = () => { clearQueryTaskTimer(); }; diff --git a/src/utils/arcoD.tsx b/src/utils/arcoD.tsx index 1d8f9ee..abea1ea 100644 --- a/src/utils/arcoD.tsx +++ b/src/utils/arcoD.tsx @@ -5,6 +5,7 @@ import { IconLoading } from '@arco-design/web-vue/es/icon'; import icon1 from '@/assets/img/media-account/icon-warn-1.png'; import icon2 from '@/assets/img/media-account/icon-success.png'; +import icon3 from "@/assets/img/media-account/icon-warn.png" interface RenderNotificationData { total_number: number; @@ -13,7 +14,9 @@ interface RenderNotificationData { file?: string; } -export function showExportNotification(label: string, { id = '', duration = 3000}) { +// 下载通知框 +export function showExportNotification(label: string, others: { id?: string, duration?: number }) { + const { id = '', duration = 3000 } = others ?? {} Notification.warning({ id, showIcon: false, @@ -29,6 +32,28 @@ export function showExportNotification(label: string, { id = '', duration = 300 }); } +// 下载失败框 +export function showFailExportNotification(label: string, others: { id?: string, duration?: number, onReDownload?: Function }) { + const { id = '', duration = 0, onReDownload } = others ?? {} + Notification.warning({ + id, + showIcon: false, + closable: true, + content: () => ( +
{label}
+onReDownload?.()}>重新下载
+