refactor(客户端管理): 替换导出功能为可复用钩子

- 使用 useBlobExport 钩子替代 commonDownloadExcel 工具函数,统一导出逻辑
- 增加导出按钮的加载状态和禁用状态,提升用户体验
- 通过钩子自动构建导出文件名,简化调用代码
This commit is contained in:
dap
2026-01-28 19:34:15 +08:00
parent abb386f49d
commit 1ff118c2e0

View File

@@ -18,7 +18,7 @@ import {
clientRemove, clientRemove,
} from '#/api/system/client'; } from '#/api/system/client';
import { ApiSwitch } from '#/components/global'; import { ApiSwitch } from '#/components/global';
import { commonDownloadExcel } from '#/utils/file/download'; import { useBlobExport } from '#/utils/file/export';
import clientDrawer from './client-drawer.vue'; import clientDrawer from './client-drawer.vue';
import { columns, querySchema } from './data'; import { columns, querySchema } from './data';
@@ -104,8 +104,14 @@ function handleMultiDelete() {
}); });
} }
function handleDownloadExcel() { const { exportBlob, exportLoading, buildExportFileName } =
commonDownloadExcel(clientExport, '客户端数据', tableApi.formApi.form.values); useBlobExport(clientExport);
async function handleExport() {
// 构建表单请求参数
const formValues = await tableApi.formApi.getValues();
// 文件名
const fileName = buildExportFileName('客户端数据');
exportBlob({ data: formValues, fileName });
} }
const { hasAccessByCodes } = useAccess(); const { hasAccessByCodes } = useAccess();
@@ -124,7 +130,9 @@ async function handleChangeStatus(checked: boolean, row: Client) {
<Space> <Space>
<a-button <a-button
v-access:code="['system:client:export']" v-access:code="['system:client:export']"
@click="handleDownloadExcel" :loading="exportLoading"
:disabled="exportLoading"
@click="handleExport"
> >
{{ $t('pages.common.export') }} {{ $t('pages.common.export') }}
</a-button> </a-button>