From abb386f49d8a9e1751645dac54487d2f1b4b3766 Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Wed, 28 Jan 2026 19:33:25 +0800 Subject: [PATCH] =?UTF-8?q?refactor(monitor):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97=E4=B8=8E=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=AF=BC=E5=87=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用 useBlobExport 组合式函数替换 commonDownloadExcel,统一导出逻辑 移除手动构建请求参数和文件名的代码,提高代码复用性 为导出按钮添加加载状态,改善用户体验 --- .../src/views/monitor/logininfor/index.vue | 23 ++++++++++--------- .../src/views/monitor/operlog/index.vue | 18 ++++++++++----- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/apps/web-antd/src/views/monitor/logininfor/index.vue b/apps/web-antd/src/views/monitor/logininfor/index.vue index 996a0c7a..54d270cb 100644 --- a/apps/web-antd/src/views/monitor/logininfor/index.vue +++ b/apps/web-antd/src/views/monitor/logininfor/index.vue @@ -18,7 +18,7 @@ import { loginInfoRemove, userUnlock, } from '#/api/monitor/logininfo'; -import { commonDownloadExcel } from '#/utils/file/download'; +import { useBlobExport } from '#/utils/file/export'; import { confirmDeleteModal } from '#/utils/modal'; import { columns, querySchema } from './data'; @@ -134,15 +134,14 @@ async function handleUnlock() { tableApi.grid.clearCheckboxRow(); } -function handleDownloadExcel() { - commonDownloadExcel( - loginInfoExport, - '登录日志', - tableApi.formApi.form.values, - { - fieldMappingTime: formOptions.fieldMappingTime, - }, - ); +const { exportBlob, exportLoading, buildExportFileName } = + useBlobExport(loginInfoExport); +async function handleExport() { + // 构建表单请求参数 + const formValues = await tableApi.formApi.getValues(); + // 文件名 + const fileName = buildExportFileName('登录日志'); + exportBlob({ data: formValues, fileName }); } @@ -159,7 +158,9 @@ function handleDownloadExcel() { {{ $t('pages.common.export') }} diff --git a/apps/web-antd/src/views/monitor/operlog/index.vue b/apps/web-antd/src/views/monitor/operlog/index.vue index e2165f4b..19064723 100644 --- a/apps/web-antd/src/views/monitor/operlog/index.vue +++ b/apps/web-antd/src/views/monitor/operlog/index.vue @@ -21,7 +21,7 @@ import { operLogExport, operLogList, } from '#/api/monitor/operlog'; -import { commonDownloadExcel } from '#/utils/file/download'; +import { useBlobExport } from '#/utils/file/export'; import { confirmDeleteModal } from '#/utils/modal'; import { columns, querySchema } from './data'; @@ -135,10 +135,14 @@ async function handleDelete() { }); } -function handleDownloadExcel() { - commonDownloadExcel(operLogExport, '操作日志', tableApi.formApi.form.values, { - fieldMappingTime: formOptions.fieldMappingTime, - }); +const { exportBlob, exportLoading, buildExportFileName } = + useBlobExport(operLogExport); +async function handleExport() { + // 构建表单请求参数 + const formValues = await tableApi.formApi.getValues(); + // 文件名 + const fileName = buildExportFileName('操作日志'); + exportBlob({ data: formValues, fileName }); } @@ -155,7 +159,9 @@ function handleDownloadExcel() { {{ $t('pages.common.export') }}