From 35d67ad71c5e08cb1056b86571b7b144ec82774c Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Wed, 28 Jan 2026 19:36:41 +0800 Subject: [PATCH] =?UTF-8?q?refactor(views):=20=E6=9B=BF=E6=8D=A2=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=8A=9F=E8=83=BD=E4=B8=BA=E7=BB=84=E5=90=88=E5=BC=8F?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=BB=A5=E6=8F=90=E5=8D=87=E5=A4=8D=E7=94=A8?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将租户套餐和租户管理页面的导出功能从 commonDownloadExcel 工具函数迁移至 useBlobExport 组合式函数。此重构统一了导出逻辑,自动处理加载状态和文件名构建,并移除了手动控制台日志语句,提高了代码的可维护性和一致性。 --- .../src/views/system/tenant/index.vue | 17 +++++++++++----- .../src/views/system/tenantPackage/index.vue | 20 +++++++++++-------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/apps/web-antd/src/views/system/tenant/index.vue b/apps/web-antd/src/views/system/tenant/index.vue index 8df85fed..a8db5c56 100644 --- a/apps/web-antd/src/views/system/tenant/index.vue +++ b/apps/web-antd/src/views/system/tenant/index.vue @@ -26,7 +26,7 @@ import { } from '#/api/system/tenant'; import { ApiSwitch } from '#/components/global'; import { useTenantStore } from '#/store/tenant'; -import { commonDownloadExcel } from '#/utils/file/download'; +import { useBlobExport } from '#/utils/file/export'; import { columns, querySchema } from './data'; import tenantDrawer from './tenant-drawer.vue'; @@ -122,8 +122,14 @@ function handleMultiDelete() { }); } -function handleDownloadExcel() { - commonDownloadExcel(tenantExport, '租户数据', tableApi.formApi.form.values); +const { exportBlob, exportLoading, buildExportFileName } = + useBlobExport(tenantExport); +async function handleExport() { + // 构建表单请求参数 + const formValues = await tableApi.formApi.getValues(); + // 文件名 + const fileName = buildExportFileName('租户数据'); + exportBlob({ data: formValues, fileName }); } /** @@ -159,7 +165,6 @@ function handleSyncTenantConfig() { } async function handleChangeStatus(checked: boolean, row: Tenant) { - console.log(checked); await tenantStatusChange({ id: row.id, tenantId: row.tenantId, @@ -208,7 +213,9 @@ const handleMenuClick: DropdownEmits['menuClick'] = (e) => { {{ $t('pages.common.export') }} diff --git a/apps/web-antd/src/views/system/tenantPackage/index.vue b/apps/web-antd/src/views/system/tenantPackage/index.vue index 4a573414..0ac2c3bb 100644 --- a/apps/web-antd/src/views/system/tenantPackage/index.vue +++ b/apps/web-antd/src/views/system/tenantPackage/index.vue @@ -20,7 +20,7 @@ import { packageRemove, } from '#/api/system/tenant-package'; import { ApiSwitch } from '#/components/global'; -import { commonDownloadExcel } from '#/utils/file/download'; +import { useBlobExport } from '#/utils/file/export'; import { columns, querySchema } from './data'; import tenantPackageDrawer from './tenant-package-drawer.vue'; @@ -104,12 +104,14 @@ function handleMultiDelete() { }); } -function handleDownloadExcel() { - commonDownloadExcel( - packageExport, - '租户套餐数据', - tableApi.formApi.form.values, - ); +const { exportBlob, exportLoading, buildExportFileName } = + useBlobExport(packageExport); +async function handleExport() { + // 构建表单请求参数 + const formValues = await tableApi.formApi.getValues(); + // 文件名 + const fileName = buildExportFileName('租户套餐数据'); + exportBlob({ data: formValues, fileName }); } /** @@ -137,7 +139,9 @@ async function handleChangeStatus(checked: boolean, row: TenantPackage) { {{ $t('pages.common.export') }}