|
|
|
|
@ -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) { |
|
|
|
|
|