mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-03-11 00:31:09 +08:00
refactor(monitor): 重构操作日志与登录日志导出功能
使用 useBlobExport 组合式函数替换 commonDownloadExcel,统一导出逻辑 移除手动构建请求参数和文件名的代码,提高代码复用性 为导出按钮添加加载状态,改善用户体验
This commit is contained in:
@@ -18,7 +18,7 @@ import {
|
||||
loginInfoRemove,
|
||||
userUnlock,
|
||||
} from '#/api/monitor/logininfo';
|
||||
import { commonDownloadExcel } from '#/utils/file/download';
|
||||
import { useBlobExport } from '#/utils/file/export';
|
||||
import { confirmDeleteModal } from '#/utils/modal';
|
||||
|
||||
import { columns, querySchema } from './data';
|
||||
@@ -134,15 +134,14 @@ async function handleUnlock() {
|
||||
tableApi.grid.clearCheckboxRow();
|
||||
}
|
||||
|
||||
function handleDownloadExcel() {
|
||||
commonDownloadExcel(
|
||||
loginInfoExport,
|
||||
'登录日志',
|
||||
tableApi.formApi.form.values,
|
||||
{
|
||||
fieldMappingTime: formOptions.fieldMappingTime,
|
||||
},
|
||||
);
|
||||
const { exportBlob, exportLoading, buildExportFileName } =
|
||||
useBlobExport(loginInfoExport);
|
||||
async function handleExport() {
|
||||
// 构建表单请求参数
|
||||
const formValues = await tableApi.formApi.getValues();
|
||||
// 文件名
|
||||
const fileName = buildExportFileName('登录日志');
|
||||
exportBlob({ data: formValues, fileName });
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -159,7 +158,9 @@ function handleDownloadExcel() {
|
||||
</a-button>
|
||||
<a-button
|
||||
v-access:code="['monitor:logininfor:export']"
|
||||
@click="handleDownloadExcel"
|
||||
:loading="exportLoading"
|
||||
:disabled="exportLoading"
|
||||
@click="handleExport"
|
||||
>
|
||||
{{ $t('pages.common.export') }}
|
||||
</a-button>
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
operLogExport,
|
||||
operLogList,
|
||||
} from '#/api/monitor/operlog';
|
||||
import { commonDownloadExcel } from '#/utils/file/download';
|
||||
import { useBlobExport } from '#/utils/file/export';
|
||||
import { confirmDeleteModal } from '#/utils/modal';
|
||||
|
||||
import { columns, querySchema } from './data';
|
||||
@@ -135,10 +135,14 @@ async function handleDelete() {
|
||||
});
|
||||
}
|
||||
|
||||
function handleDownloadExcel() {
|
||||
commonDownloadExcel(operLogExport, '操作日志', tableApi.formApi.form.values, {
|
||||
fieldMappingTime: formOptions.fieldMappingTime,
|
||||
});
|
||||
const { exportBlob, exportLoading, buildExportFileName } =
|
||||
useBlobExport(operLogExport);
|
||||
async function handleExport() {
|
||||
// 构建表单请求参数
|
||||
const formValues = await tableApi.formApi.getValues();
|
||||
// 文件名
|
||||
const fileName = buildExportFileName('操作日志');
|
||||
exportBlob({ data: formValues, fileName });
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -155,7 +159,9 @@ function handleDownloadExcel() {
|
||||
</a-button>
|
||||
<a-button
|
||||
v-access:code="['monitor:operlog:export']"
|
||||
@click="handleDownloadExcel"
|
||||
:loading="exportLoading"
|
||||
:disabled="exportLoading"
|
||||
@click="handleExport"
|
||||
>
|
||||
{{ $t('pages.common.export') }}
|
||||
</a-button>
|
||||
|
||||
Reference in New Issue
Block a user