From 606fbe634e9d8418d9884c49e2bb70494cbd17b2 Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Fri, 5 Sep 2025 17:01:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system/user.js | 2 +- src/utils/download.js | 26 ++++++++++++++++++++++++++ src/views/monitor/job/index.vue | 2 +- src/views/monitor/job/log.vue | 2 +- src/views/monitor/logininfor/index.vue | 2 +- src/views/monitor/operlog/index.vue | 2 +- src/views/system/config/index.vue | 2 +- src/views/system/dict/data.vue | 2 +- src/views/system/dict/index.vue | 2 +- src/views/system/post/index.vue | 2 +- src/views/system/role/index.vue | 2 +- src/views/system/user/index.vue | 2 +- 12 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 src/utils/download.js diff --git a/src/api/system/user.js b/src/api/system/user.js index 5fd1fb8..9abf556 100644 --- a/src/api/system/user.js +++ b/src/api/system/user.js @@ -130,7 +130,7 @@ export function updateAuthRole(data) { // 查询部门下拉树结构 export function deptTreeSelect() { return request({ - url: '/system/user/deptTree', + url: '/smartArchives/system/user/deptTree', method: 'get' }) } diff --git a/src/utils/download.js b/src/utils/download.js new file mode 100644 index 0000000..aba2d53 --- /dev/null +++ b/src/utils/download.js @@ -0,0 +1,26 @@ +// 下载blob文件 +export const downloadFile = ({ fileData, fileType, fileName }) => { + const blob = new Blob([fileData], { + type: fileType + }) + const link = document.createElement('a') + link.href = URL.createObjectURL(blob) + link.download = fileName + link.style.display = 'none' + document.body.appendChild(link) + link.click() + URL.revokeObjectURL(link.href) + document.body.removeChild(link) +} + +// 通用a链接下载 +export const downloadFileByUrl = (url) => { + const link = document.createElement('a') + link.href = url + link.setAttribute('download', '') + link.style.display = 'none' + document.body.appendChild(link) + link.click() + URL.revokeObjectURL(link.href) + document.body.removeChild(link) +} diff --git a/src/views/monitor/job/index.vue b/src/views/monitor/job/index.vue index 783873f..951b3c8 100644 --- a/src/views/monitor/job/index.vue +++ b/src/views/monitor/job/index.vue @@ -504,7 +504,7 @@ export default { }, /** 导出按钮操作 */ handleExport() { - this.download('monitor/job/export', { + this.download('smartArchives/monitor/job/export', { ...this.queryParams }, `job_${new Date().getTime()}.xlsx`) } diff --git a/src/views/monitor/job/log.vue b/src/views/monitor/job/log.vue index 22d4e31..6409772 100644 --- a/src/views/monitor/job/log.vue +++ b/src/views/monitor/job/log.vue @@ -286,7 +286,7 @@ export default { }, /** 导出按钮操作 */ handleExport() { - this.download('/monitor/jobLog/export', { + this.download('/smartArchives//monitor/jobLog/export', { ...this.queryParams }, `log_${new Date().getTime()}.xlsx`) } diff --git a/src/views/monitor/logininfor/index.vue b/src/views/monitor/logininfor/index.vue index f16a3dc..cc3ca63 100644 --- a/src/views/monitor/logininfor/index.vue +++ b/src/views/monitor/logininfor/index.vue @@ -236,7 +236,7 @@ export default { }, /** 导出按钮操作 */ handleExport() { - this.download('monitor/logininfor/export', { + this.download('smartArchives/monitor/logininfor/export', { ...this.queryParams }, `logininfor_${new Date().getTime()}.xlsx`) } diff --git a/src/views/monitor/operlog/index.vue b/src/views/monitor/operlog/index.vue index 6f80177..002a15e 100644 --- a/src/views/monitor/operlog/index.vue +++ b/src/views/monitor/operlog/index.vue @@ -313,7 +313,7 @@ export default { }, /** 导出按钮操作 */ handleExport() { - this.download('monitor/operlog/export', { + this.download('smartArchives/monitor/operlog/export', { ...this.queryParams }, `operlog_${new Date().getTime()}.xlsx`) } diff --git a/src/views/system/config/index.vue b/src/views/system/config/index.vue index a0794e1..73b1f77 100644 --- a/src/views/system/config/index.vue +++ b/src/views/system/config/index.vue @@ -328,7 +328,7 @@ export default { }, /** 导出按钮操作 */ handleExport() { - this.download('system/config/export', { + this.download('smartArchives/system/config/export', { ...this.queryParams }, `config_${new Date().getTime()}.xlsx`) }, diff --git a/src/views/system/dict/data.vue b/src/views/system/dict/data.vue index 2102e9e..51c25b9 100644 --- a/src/views/system/dict/data.vue +++ b/src/views/system/dict/data.vue @@ -393,7 +393,7 @@ export default { }, /** 导出按钮操作 */ handleExport() { - this.download('system/dict/data/export', { + this.download('smartArchives/system/dict/data/export', { ...this.queryParams }, `data_${new Date().getTime()}.xlsx`) } diff --git a/src/views/system/dict/index.vue b/src/views/system/dict/index.vue index ada7e07..212504d 100644 --- a/src/views/system/dict/index.vue +++ b/src/views/system/dict/index.vue @@ -331,7 +331,7 @@ export default { }, /** 导出按钮操作 */ handleExport() { - this.download('system/dict/type/export', { + this.download('smartArchives/system/dict/type/export', { ...this.queryParams }, `type_${new Date().getTime()}.xlsx`) }, diff --git a/src/views/system/post/index.vue b/src/views/system/post/index.vue index 60a1859..495e957 100644 --- a/src/views/system/post/index.vue +++ b/src/views/system/post/index.vue @@ -300,7 +300,7 @@ export default { }, /** 导出按钮操作 */ handleExport() { - this.download('system/post/export', { + this.download('smartArchives/system/post/export', { ...this.queryParams }, `post_${new Date().getTime()}.xlsx`) } diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue index ab01a4a..0218720 100644 --- a/src/views/system/role/index.vue +++ b/src/views/system/role/index.vue @@ -596,7 +596,7 @@ export default { }, /** 导出按钮操作 */ handleExport() { - this.download('system/role/export', { + this.download('smartArchives/system/role/export', { ...this.queryParams }, `role_${new Date().getTime()}.xlsx`) } diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index e3ffde9..efae506 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -518,7 +518,7 @@ export default { }, /** 导出按钮操作 */ handleExport() { - this.download('system/user/export', { + this.download('smartArchives/system/user/export', { ...this.queryParams }, `user_${new Date().getTime()}.xlsx`) },