refactor: 替换角色导出功能为 useBlobExport 钩子

将 commonDownloadExcel 替换为 useBlobExport 钩子以统一导出逻辑,
并添加导出时的加载状态控制,提升用户体验。
This commit is contained in:
dap
2026-01-28 19:25:12 +08:00
parent bfb2287b2e
commit 189b86f5b7

View File

@@ -26,7 +26,7 @@ import {
roleRemove,
} from '#/api/system/role';
import { ApiSwitch } from '#/components/global';
import { commonDownloadExcel } from '#/utils/file/download';
import { useBlobExport } from '#/utils/file/export';
import { columns, querySchema } from './data';
import roleAuthModal from './role-auth-modal.vue';
@@ -119,10 +119,14 @@ function handleMultiDelete() {
});
}
function handleDownloadExcel() {
commonDownloadExcel(roleExport, '角色数据', tableApi.formApi.form.values, {
fieldMappingTime: formOptions.fieldMappingTime,
});
const { exportBlob, exportLoading, buildExportFileName } =
useBlobExport(roleExport);
async function handleExport() {
// 构建表单请求参数
const formValues = await tableApi.formApi.getValues();
// 文件名
const fileName = buildExportFileName('角色数据');
exportBlob({ data: formValues, fileName });
}
const { hasAccessByCodes, hasAccessByRoles } = useAccess();
@@ -158,7 +162,9 @@ async function handleChangeStatus(checked: boolean, row: Role) {
<Space>
<a-button
v-access:code="['system:role:export']"
@click="handleDownloadExcel"
:loading="exportLoading"
:disabled="exportLoading"
@click="handleExport"
>
{{ $t('pages.common.export') }}
</a-button>