refactor(views): 替换导出功能为 useBlobExport 钩子

使用新的 useBlobExport 组合式函数替换原有的 commonDownloadExcel 工具函数,以统一导出逻辑并支持加载状态。同时调整按钮状态绑定 exportLoading 并重构参数获取方式。
This commit is contained in:
dap
2026-01-28 19:27:17 +08:00
parent 189b86f5b7
commit 9454121963

View File

@@ -17,7 +17,7 @@ import {
postList, postList,
postRemove, postRemove,
} from '#/api/system/post'; } from '#/api/system/post';
import { commonDownloadExcel } from '#/utils/file/download'; import { useBlobExport } from '#/utils/file/export';
import DeptTree from '#/views/system/user/dept-tree.vue'; import DeptTree from '#/views/system/user/dept-tree.vue';
import { columns, querySchema } from './data'; import { columns, querySchema } from './data';
@@ -118,8 +118,14 @@ function handleMultiDelete() {
}); });
} }
function handleDownloadExcel() { const { exportBlob, exportLoading, buildExportFileName } =
commonDownloadExcel(postExport, '岗位信息', tableApi.formApi.form.values); useBlobExport(postExport);
async function handleExport() {
// 构建表单请求参数
const formValues = await tableApi.formApi.getValues();
// 文件名
const fileName = buildExportFileName('岗位数据');
exportBlob({ data: formValues, fileName });
} }
</script> </script>
@@ -137,7 +143,9 @@ function handleDownloadExcel() {
<Space> <Space>
<a-button <a-button
v-access:code="['system:post:export']" v-access:code="['system:post:export']"
@click="handleDownloadExcel" :loading="exportLoading"
:disabled="exportLoading"
@click="handleExport"
> >
{{ $t('pages.common.export') }} {{ $t('pages.common.export') }}
</a-button> </a-button>