mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-04-04 12:03:22 +08:00
refactor: 替换角色导出功能为 useBlobExport 钩子
将 commonDownloadExcel 替换为 useBlobExport 钩子以统一导出逻辑, 并添加导出时的加载状态控制,提升用户体验。
This commit is contained in:
@@ -26,7 +26,7 @@ import {
|
|||||||
roleRemove,
|
roleRemove,
|
||||||
} from '#/api/system/role';
|
} from '#/api/system/role';
|
||||||
import { ApiSwitch } from '#/components/global';
|
import { ApiSwitch } from '#/components/global';
|
||||||
import { commonDownloadExcel } from '#/utils/file/download';
|
import { useBlobExport } from '#/utils/file/export';
|
||||||
|
|
||||||
import { columns, querySchema } from './data';
|
import { columns, querySchema } from './data';
|
||||||
import roleAuthModal from './role-auth-modal.vue';
|
import roleAuthModal from './role-auth-modal.vue';
|
||||||
@@ -119,10 +119,14 @@ function handleMultiDelete() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDownloadExcel() {
|
const { exportBlob, exportLoading, buildExportFileName } =
|
||||||
commonDownloadExcel(roleExport, '角色数据', tableApi.formApi.form.values, {
|
useBlobExport(roleExport);
|
||||||
fieldMappingTime: formOptions.fieldMappingTime,
|
async function handleExport() {
|
||||||
});
|
// 构建表单请求参数
|
||||||
|
const formValues = await tableApi.formApi.getValues();
|
||||||
|
// 文件名
|
||||||
|
const fileName = buildExportFileName('角色数据');
|
||||||
|
exportBlob({ data: formValues, fileName });
|
||||||
}
|
}
|
||||||
|
|
||||||
const { hasAccessByCodes, hasAccessByRoles } = useAccess();
|
const { hasAccessByCodes, hasAccessByRoles } = useAccess();
|
||||||
@@ -158,7 +162,9 @@ async function handleChangeStatus(checked: boolean, row: Role) {
|
|||||||
<Space>
|
<Space>
|
||||||
<a-button
|
<a-button
|
||||||
v-access:code="['system:role:export']"
|
v-access:code="['system:role:export']"
|
||||||
@click="handleDownloadExcel"
|
:loading="exportLoading"
|
||||||
|
:disabled="exportLoading"
|
||||||
|
@click="handleExport"
|
||||||
>
|
>
|
||||||
{{ $t('pages.common.export') }}
|
{{ $t('pages.common.export') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
|
|||||||
Reference in New Issue
Block a user