Przeglądaj źródła

Merge branch 'cc-dev' into 'dev'

任务执行完成 准备提测

See merge request product-group-fe/sfy-safety-group/sfy-safety!80
陈昶 10 miesięcy temu
rodzic
commit
b8c4579387

+ 7 - 1
package.json

@@ -153,6 +153,12 @@
     "node": "12 || >=14"
   },
   "pnpm": {
+    "patchedDependencies": {
+      "@vue-office/docx@1.6.3": "patches/@vue-office__docx.patch",
+      "@vue-office/excel@1.7.14": "patches/@vue-office__excel.patch",
+      "@vue-office/pdf@2.0.10": "patches/@vue-office__pdf.patch",
+      "@vue-office/pptx@1.0.1": "patches/@vue-office__pptx.patch"
+    },
     "peerDependencyRules": {
       "ignoreMissing": [
         "rollup",
@@ -160,4 +166,4 @@
       ]
     }
   }
-}
+}

+ 4 - 7
src/views/disaster/disaster-control/src/util.ts

@@ -1,6 +1,7 @@
-import { TASK_STAGE_OPTIONS_DISPOSAL_MANAGEMENT, FIX_STATUS_OPTIONS } from './constant';
+import { downloadFile } from '@/views/disaster/utils';
 import type { DisasterLossDetailQuery } from '@/types/disaster-control';
 import { exportLossRecordToXML } from '@/api/disaster-control';
+import { TASK_STAGE_OPTIONS_DISPOSAL_MANAGEMENT, FIX_STATUS_OPTIONS } from './constant';
 
 // 获取任务阶段
 const getTaskStage = (taskStage: number) => {
@@ -14,14 +15,10 @@ const getfixStatus = (fixStatus: number) => {
 // 导出损失明细
 const exportLossRecord = async (data: DisasterLossDetailQuery, name: string) => {
   const res = await exportLossRecordToXML(data);
+  if (res.size === 0) return;
   const blob = new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
   const url = window.URL.createObjectURL(blob);
-  const a = document.createElement('a');
-  a.href = url;
-  a.download = `${name}损失明细.xlsx`;
-  a.click();
-  a.remove();
-  window.URL.revokeObjectURL(url);
+  downloadFile(url, `${name}损失明细`);
 };
 
 export { getTaskStage, getfixStatus, exportLossRecord };

+ 1 - 1
src/views/disaster/disaster-precaution/src/components/ViewTaskItem.vue

@@ -6,7 +6,7 @@
     <p class="title">
       被检查自查单位:<span class="content">{{ deptName }}</span>
     </p>
-    <div class="export-file" @click="exportTaskDetailToPDF(id)" v-if="taskState === TASK_STAGE.COMPLETED">
+    <div class="export-file" @click="exportTaskDetailToPDF(id, taskName)" v-if="taskState === TASK_STAGE.COMPLETED">
       <el-button type="primary">
         <template #icon>
           <img :src="ExportIcon" />

+ 3 - 6
src/views/disaster/disaster-precaution/src/utils/export-pdf.ts

@@ -2,17 +2,14 @@
  * 导出检查任务详情pdf
  */
 import { ElMessage } from 'element-plus';
+import { downloadFile } from '@/views/disaster/utils';
 import { exportTaskDetailPDF } from '@/api/disaster-precaution';
 const exportTaskDetailToPDF = async (preventInspectTaskId: number, name: string) => {
   const res = await exportTaskDetailPDF(preventInspectTaskId);
+  if (res.size === 0) return;
   const blob = new Blob([res], { type: 'application/pdf' });
   const url = window.URL.createObjectURL(blob);
-  const a = document.createElement('a');
-  a.href = url;
-  a.download = `${name}检查任务详情.pdf`;
-  a.click();
-  a.remove();
-  window.URL.revokeObjectURL(url);
+  downloadFile(url, `${name}检查任务详情`);
   ElMessage.success(`${name}检查任务详情导出成功`);
 };