人效管理-绩效管理-绩效填报-任务行详情

dev-scheduling
ysn 1 month ago
parent c4e80f3fa5
commit 76fd83bd2c
  1. 26
      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;
}
const zip = new JSZip();
const promises = [];
try {
//
completedTasks.forEach(task => {
if (task.attachLink) {
downloadFileBlob(task.attachLink, task.taskName + '.xlsx');
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) {

Loading…
Cancel
Save