From 76fd83bd2c65a3154051f0a3a3e52cd1c0224c6d Mon Sep 17 00:00:00 2001 From: ysn <2126564605@qq.com> Date: Fri, 24 Apr 2026 20:15:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E6=95=88=E7=AE=A1=E7=90=86-=E7=BB=A9?= =?UTF-8?q?=E6=95=88=E7=AE=A1=E7=90=86-=E7=BB=A9=E6=95=88=E5=A1=AB?= =?UTF-8?q?=E6=8A=A5-=E4=BB=BB=E5=8A=A1=E8=A1=8C=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/prefDetail.vue | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/views/personnelEfficiencyManagement/performanceManagement/components/prefDetail.vue b/src/views/personnelEfficiencyManagement/performanceManagement/components/prefDetail.vue index 47a6be02..bf90ba6e 100644 --- a/src/views/personnelEfficiencyManagement/performanceManagement/components/prefDetail.vue +++ b/src/views/personnelEfficiencyManagement/performanceManagement/components/prefDetail.vue @@ -38,6 +38,8 @@ import { downloadBsEfficiencyTaskTemplate, } from '@/api/performanceManagement/dataReporting'; import { downloadFileBlob } from '@/utils/util'; +import { saveAs } from 'file-saver'; +import JSZip from 'jszip'; export default { props: { showDetail: { @@ -196,17 +198,37 @@ export default { this.loading = false; }); }, - downloadDetail() { + // 附件下载(明细) —— 打包成ZIP + async downloadDetail() { const completedTasks = this.rowData.subTasks?.filter(task => task.status == 2) || []; if (completedTasks.length === 0) { this.$message.warning('暂无可下载文件!'); return; } - completedTasks.forEach(task => { - if (task.attachLink) { - downloadFileBlob(task.attachLink, task.taskName + '.xlsx'); - } - }); + const zip = new JSZip(); + const promises = []; + try { + // 遍历所有已完成任务,加入压缩包 + completedTasks.forEach(task => { + if (task.attachLink) { + const promise = fetch(task.attachLink) + .then(res => res.blob()) + .then(blob => { + zip.file(`${task.taskName}.xlsx`, blob); + }); + promises.push(promise); + } + }); + // 等待所有文件下载完成 + await Promise.all(promises); + // 生成压缩包并下载 + const content = await zip.generateAsync({ type: 'blob' }); + saveAs(content, `${this.rowData.taskName}-明细附件.zip`); + this.$message.success('明细附件下载成功'); + } catch (error) { + console.error('明细附件下载失败:', error);s + this.$message.error('明细附件下载失败,请稍后重试'); + } }, downloadSummary() { if (!this.rowData.attachLink) {