From 63f36d6bd7ec3005f040a66b2b9d9d3dd17ffa4c Mon Sep 17 00:00:00 2001 From: Joe <1712833832@qq.com> Date: Tue, 30 Jan 2024 11:30:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E4=BF=AE=E6=94=B9=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/dutyOfficer/index.vue | 26 +++++++-- .../views/emergencyAgencies/index.vue | 15 +++++- .../views/firstResponders/index.vue | 15 +++++- .../views/jurisdictionalManagement/index.vue | 48 +++++------------ .../src/views/JiHeExpressway/utils/common.js | 53 +++++++++++++++++++ 5 files changed, 114 insertions(+), 43 deletions(-) diff --git a/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/dutyOfficer/index.vue b/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/dutyOfficer/index.vue index d8785e24..4b7db4a7 100644 --- a/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/dutyOfficer/index.vue +++ b/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/dutyOfficer/index.vue @@ -2,13 +2,13 @@
- + 机构值班表 - + @@ -111,7 +111,7 @@ import InputSearch from '@screen/components/InputSearch/index.vue'; import { searchFormList } from "./data"; import request from "@/utils/request"; import { setLoading } from "@screen/utils/index.js" -import { delay } from "@screen/utils/common"; +import { delay, exportFile } from "@screen/utils/common"; export default { name: 'DutyOfficer', @@ -170,6 +170,26 @@ export default { handleModifyDutyInformationTable(bool) { this.modifyDutyInformationTableVisible = bool; }, + handleExport() { + exportFile({ + url: "/business/shifts/export", + filename: "机构值班表", + data: { + ...this.searchData, + ...this.getPagination() + } + }); + }, + handleExportTemplate() { + exportFile({ + url: "/business/shifts/exportModel", + filename: "机构值班表面板", + data: { + ...this.searchData, + ...this.getPagination() + } + }); + }, handleSearch(data) { this.searchData = data; this.getData(); diff --git a/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/emergencyAgencies/index.vue b/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/emergencyAgencies/index.vue index c572b8e7..b1985b43 100644 --- a/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/emergencyAgencies/index.vue +++ b/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/emergencyAgencies/index.vue @@ -8,7 +8,7 @@ 新增 - + @@ -54,8 +54,9 @@ import Button from '@screen/components/Buttons/Button.vue'; import { searchFormList } from "./data"; import request from "@/utils/request"; import { setLoading } from "@screen/utils/index.js" -import { delay } from "@screen/utils/common"; +import { delay, exportFile } from "@screen/utils/common"; +// 应急机构 export default { name: 'EmergencyAgencies', inject: ['getPagination', 'setTotal'], @@ -106,6 +107,16 @@ export default { this.searchData = data; this.getData(); }, + handleExport() { + exportFile({ + url: "/business/organization/export", + filename: "应急机构", + data: { + ...this.searchData, + ...this.getPagination() + } + }); + }, async getData() { const closeLoading = setLoading(); diff --git a/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/firstResponders/index.vue b/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/firstResponders/index.vue index 59e489ae..c9d2149f 100644 --- a/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/firstResponders/index.vue +++ b/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/firstResponders/index.vue @@ -8,7 +8,7 @@ 新增 - + @@ -43,8 +43,9 @@ import ButtonGradient from '@screen/components/Buttons/ButtonGradient.vue'; import { searchFormList } from "./data"; import request from "@/utils/request"; import { setLoading } from "@screen/utils/index.js" -import { delay } from "@screen/utils/common"; +import { delay, exportFile } from "@screen/utils/common"; +// 应急人员 export default { name: 'FirstResponders', components: { @@ -98,6 +99,16 @@ export default { }) }, + handleExport() { + exportFile({ + url: "/business/employees/export", + filename: "应急人员", + data: { + ...this.searchData, + ...this.getPagination() + } + }); + }, handleSearch(data) { this.searchData = data; this.getData(); diff --git a/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/jurisdictionalManagement/index.vue b/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/jurisdictionalManagement/index.vue index 14bb764a..ec957def 100644 --- a/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/jurisdictionalManagement/index.vue +++ b/ruoyi-ui/src/views/JiHeExpressway/pages/control/event/businessDataManagement/views/jurisdictionalManagement/index.vue @@ -8,7 +8,7 @@ 新增 - + @@ -60,8 +60,9 @@ import ButtonGradient from '@screen/components/Buttons/ButtonGradient.vue'; import { searchFormList } from "./data"; import request from "@/utils/request"; import { setLoading } from "@screen/utils/index.js" -import { delay } from "@screen/utils/common"; +import { delay, exportFile } from "@screen/utils/common"; +// 辖段管理 export default { name: 'JurisdictionalManagement', components: { @@ -112,40 +113,15 @@ export default { // this.getSearchOptions(); }, methods: { - getSearchOptions() { - Promise.allSettled([ - // 岗位 - request({ - url: `/business/employees/sysPost`, - method: "post", - data: {} - }), - - // 机构 - request({ - url: `/business/employees/organization`, - method: "post", - data: {} - }) - ]) - .then(([post, organization]) => { - if (post.status === 'fulfilled' && post.value.code == 200) { - this.searchFormList[0].options.options = post.value.data.map(item => ({ - key: item.postId, - label: item.postName, - })) - } - - if (organization.status === 'fulfilled' && organization.value.code == 200) { - this.searchFormList[1].options.options = organization.value.data.map(item => ({ - key: item.id, - label: item.organizationName, - })) - } - - console.log(this.searchFormList) - - }) + handleExport() { + // exportFile({ + // url: "/business/employees/export", + // filename: "管辖路段", + // data: { + // ...this.searchData, + // ...this.getPagination() + // } + // }); }, handleSearch(data) { this.searchData = data; diff --git a/ruoyi-ui/src/views/JiHeExpressway/utils/common.js b/ruoyi-ui/src/views/JiHeExpressway/utils/common.js index b0485ccf..6503a08e 100644 --- a/ruoyi-ui/src/views/JiHeExpressway/utils/common.js +++ b/ruoyi-ui/src/views/JiHeExpressway/utils/common.js @@ -1,3 +1,56 @@ +import request from "@/utils/request"; +import { Message } from "element-ui"; + export function delay(ms = 240) { return new Promise((resolve) => setTimeout(() => resolve(void 0), ms)); } + +/** + * + * @param {{ method?: string; url: string; data?: string; type?: string; filename?: string; }} options + */ +export function exportFile({ + url, + method = "post", + data, + type = "application/vnd.ms-excel", + filename = "download", + ext = "xlsx", +} = {}) { + if (!url) return; + const loadingMessage = Message.info({ + message: `文件下载中...`, + duration: 0, + customClass: "loading-message", + iconClass: "el-icon-loading", + }); + + request({ + url, + method, + responseType: "blob", + data: { + ...data, + }, + params: { + ...data, + }, + }) + .then((result) => { + const blob = new Blob([result], { type }); + const downloadElement = document.createElement("a"); + const href = window.URL.createObjectURL(blob); + downloadElement.href = href; + downloadElement.download = result.filename || `${filename}.${ext}`; + document.body.appendChild(downloadElement); + downloadElement.click(); + document.body.removeChild(downloadElement); + window.URL.revokeObjectURL(href); + + Message.success("文件下载成功"); + }) + .catch((err) => { + Message.error("文件下载失败"); + }) + .finally(() => loadingMessage.close()); +}