Quellcode durchsuchen

任务导出pdf 准备部署一版本

chauncey vor 10 Monaten
Ursprung
Commit
cc365b71b4

+ 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 };

+ 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}检查任务详情导出成功`);
 };