feat(导出): 重构导出功能并添加国际化支持

- 新增通用的 `useBlobExport` 组合式函数,封装导出逻辑,支持加载状态和取消操作
- 在用户管理页面使用新的导出函数替换原有的 `commonDownloadExcel` 调用
- 添加中英文国际化文案,包括导出标题、加载提示和取消提示
- 为通用页面文案补充“取消”按钮的翻译
This commit is contained in:
dap
2026-01-28 14:47:59 +08:00
parent 157fb22820
commit 703cdf4125
6 changed files with 106 additions and 9 deletions

View File

@@ -24,7 +24,7 @@ import {
userStatusChange,
} from '#/api/system/user';
import ApiSwitch from '#/components/global/api-switch.vue';
import { commonDownloadExcel } from '#/utils/file/download';
import { useBlobExport } from '#/utils/file/export';
import { columns, querySchema } from './data';
import DeptTree from './dept-tree.vue';
@@ -156,10 +156,14 @@ function handleMultiDelete() {
});
}
function handleDownloadExcel() {
commonDownloadExcel(userExport, '用户管理', tableApi.formApi.form.values, {
fieldMappingTime: formOptions.fieldMappingTime,
});
const { exportBlob, exportLoading, buildExportFileName } =
useBlobExport(userExport);
async function handleExport() {
// 构建表单请求参数
const formValues = await tableApi.formApi.getValues();
// 文件名
const fileName = buildExportFileName('用户信息');
exportBlob({ data: formValues, fileName });
}
const [UserInfoModal, userInfoModalApi] = useVbenModal({
@@ -202,7 +206,6 @@ function handleMenuClick(key: string, row: any) {
}
async function handleChangeStatus(checked: boolean, row: User) {
console.log(checked);
await userStatusChange({
userId: row.userId,
status: checked ? EnableStatus.Enable : EnableStatus.Disable,
@@ -224,7 +227,9 @@ async function handleChangeStatus(checked: boolean, row: User) {
<Space>
<a-button
v-access:code="['system:user:export']"
@click="handleDownloadExcel"
:loading="exportLoading"
:disabled="exportLoading"
@click="handleExport"
>
{{ $t('pages.common.export') }}
</a-button>