mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-03-08 15:41:08 +08:00
refactor(views): 替换导出功能为 useBlobExport 钩子
使用新的 useBlobExport 组合式函数替换原有的 commonDownloadExcel 工具函数,以统一导出逻辑并支持加载状态。同时调整按钮状态绑定 exportLoading 并重构参数获取方式。
This commit is contained in:
@@ -17,7 +17,7 @@ import {
|
||||
postList,
|
||||
postRemove,
|
||||
} 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 { columns, querySchema } from './data';
|
||||
@@ -118,8 +118,14 @@ function handleMultiDelete() {
|
||||
});
|
||||
}
|
||||
|
||||
function handleDownloadExcel() {
|
||||
commonDownloadExcel(postExport, '岗位信息', tableApi.formApi.form.values);
|
||||
const { exportBlob, exportLoading, buildExportFileName } =
|
||||
useBlobExport(postExport);
|
||||
async function handleExport() {
|
||||
// 构建表单请求参数
|
||||
const formValues = await tableApi.formApi.getValues();
|
||||
// 文件名
|
||||
const fileName = buildExportFileName('岗位数据');
|
||||
exportBlob({ data: formValues, fileName });
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -137,7 +143,9 @@ function handleDownloadExcel() {
|
||||
<Space>
|
||||
<a-button
|
||||
v-access:code="['system:post:export']"
|
||||
@click="handleDownloadExcel"
|
||||
:loading="exportLoading"
|
||||
:disabled="exportLoading"
|
||||
@click="handleExport"
|
||||
>
|
||||
{{ $t('pages.common.export') }}
|
||||
</a-button>
|
||||
|
||||
Reference in New Issue
Block a user