From fee5d6f786c8bbe05785e82a0fb2f120394119ad Mon Sep 17 00:00:00 2001 From: z Date: Mon, 15 Jan 2024 13:51:54 +0800 Subject: [PATCH] init --- src/assets/js/asyncRouter.js | 35 ++++ src/assets/js/useDownloadBlob.js | 45 +++++ src/request/axios.js | 1 - src/request/hidden_danger_government.js | 2 + .../hazard_analysis/index.vue | 172 ++++++++++++++++++ .../hazard_analysis/view.vue | 9 + .../components/hidden_view.vue | 2 +- .../delete_inventory_management/view.vue | 2 - .../ledger/components/export_excel.vue | 169 +++++++++++++++++ .../hidden_danger_government/ledger/index.vue | 34 +++- .../hidden_danger_government/ledger/print.vue | 124 +++++++++++++ 11 files changed, 589 insertions(+), 6 deletions(-) create mode 100644 src/assets/js/useDownloadBlob.js create mode 100644 src/views/continuous_improvement/hazard_analysis/index.vue create mode 100644 src/views/continuous_improvement/hazard_analysis/view.vue create mode 100644 src/views/hidden_danger_government/ledger/components/export_excel.vue create mode 100644 src/views/hidden_danger_government/ledger/print.vue diff --git a/src/assets/js/asyncRouter.js b/src/assets/js/asyncRouter.js index 4ae4586..a39cdce 100644 --- a/src/assets/js/asyncRouter.js +++ b/src/assets/js/asyncRouter.js @@ -531,6 +531,41 @@ export default [ }, component: "hidden_danger_government/ledger/view", }, + { + path: "/hidden_danger_government/ledger/print", + meta: { + title: "打印", + activeMenu: "/hidden_danger_government/ledger", + }, + component: "hidden_danger_government/ledger/print", + }, + ], + }, + ], + }, + { + path: "/continuous_improvement", + redirect: "/continuous_improvement/hazard_analysis", + meta: { title: "持续改进", model: MODEL["1"] }, + component: "children", + children: [ + { + path: "/continuous_improvement/hazard_analysis", + meta: { title: "隐患分析", isSubMenu: false }, + component: "children", + children: [ + { + path: "", + component: "continuous_improvement/hazard_analysis/index", + }, + { + path: "/continuous_improvement/hazard_analysis/view", + meta: { + title: "查看", + activeMenu: "/continuous_improvement/hazard_analysis", + }, + component: "continuous_improvement/hazard_analysis/view", + }, ], }, ], diff --git a/src/assets/js/useDownloadBlob.js b/src/assets/js/useDownloadBlob.js new file mode 100644 index 0000000..e2a0578 --- /dev/null +++ b/src/assets/js/useDownloadBlob.js @@ -0,0 +1,45 @@ +import { ElLoading, ElMessage } from "element-plus"; +import dayjs from "dayjs"; +import axios from "axios"; + +export default function useDownloadBlob( + url, + option = { + name: dayjs().format("YYYY-MM-DD HH:mm:ss"), + type: "application/vnd.ms-excel", + } +) { + return new Promise((resolve, reject) => { + const loading = ElLoading.service({ + lock: true, + text: "加载中...", + background: "rgba(0, 0, 0, 0.5)", + }); + axios + .get(url, { responseType: "blob" }) + .then((resData) => { + if (resData.data.type === "application/json") { + throw new Error("导出失败"); + } + const blob = new Blob([resData.data], { + type: option.type, + }); + const downloadElement = document.createElement("a"); + const href = window.URL.createObjectURL(blob); + downloadElement.style.display = "none"; + downloadElement.href = href; + downloadElement.download = option.name; + document.body.appendChild(downloadElement); + downloadElement.click(); + document.body.removeChild(downloadElement); + window.URL.revokeObjectURL(href); + loading.close(); + resolve(resData); + }) + .catch((err) => { + ElMessage.error("导出失败"); + loading.close(); + reject(err); + }); + }); +} diff --git a/src/request/axios.js b/src/request/axios.js index 46eb051..a33bb85 100644 --- a/src/request/axios.js +++ b/src/request/axios.js @@ -46,7 +46,6 @@ axios.interceptors.response.use( return config; }, (error) => { - console.log(error); if (error && error.response) { switch (error.response.status) { case 0: diff --git a/src/request/hidden_danger_government.js b/src/request/hidden_danger_government.js index 360534d..2af0331 100644 --- a/src/request/hidden_danger_government.js +++ b/src/request/hidden_danger_government.js @@ -13,3 +13,5 @@ export const setHiddenDangerCancelMajorHazards = (params) => post("/hidden/editHIDDENLEVEL", params); // 重大隐患管理取消重大隐患 export const setHiddenDangerConfirmMajorHazards = (params) => post("/hidden/editISCONFIRM", params); // 重大隐患管理确认重大隐患 +export const getHiddenDangerPrintList = (params) => + post("/hidden/listAllToPrint", params); // 隐患打印列表 diff --git a/src/views/continuous_improvement/hazard_analysis/index.vue b/src/views/continuous_improvement/hazard_analysis/index.vue new file mode 100644 index 0000000..4d8ea3e --- /dev/null +++ b/src/views/continuous_improvement/hazard_analysis/index.vue @@ -0,0 +1,172 @@ + + + + + diff --git a/src/views/continuous_improvement/hazard_analysis/view.vue b/src/views/continuous_improvement/hazard_analysis/view.vue new file mode 100644 index 0000000..f7c6703 --- /dev/null +++ b/src/views/continuous_improvement/hazard_analysis/view.vue @@ -0,0 +1,9 @@ + + + + + diff --git a/src/views/hazard_investigation/checklist_inspection_status/components/hidden_view.vue b/src/views/hazard_investigation/checklist_inspection_status/components/hidden_view.vue index 1ee2a45..2931929 100644 --- a/src/views/hazard_investigation/checklist_inspection_status/components/hidden_view.vue +++ b/src/views/hazard_investigation/checklist_inspection_status/components/hidden_view.vue @@ -194,7 +194,7 @@ -