Files
iot-device-management-frontend/apps/web-antd/src/views/system/operatelog/index.vue

106 lines
2.6 KiB
Vue
Raw Normal View History

2025-04-06 10:44:23 +08:00
<script lang="ts" setup>
2025-04-22 11:25:11 +08:00
import type {
OnActionClickParams,
VxeTableGridOptions,
} from '#/adapter/vxe-table';
2025-04-06 10:44:23 +08:00
import type { SystemOperateLogApi } from '#/api/system/operate-log';
import { Page, useVbenModal } from '@vben/common-ui';
import { Download } from '@vben/icons';
2025-04-22 11:25:11 +08:00
import { Button } from 'ant-design-vue';
2025-04-06 10:44:23 +08:00
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { exportOperateLog, getOperateLogPage } from '#/api/system/operate-log';
2025-04-22 11:25:11 +08:00
import { DocAlert } from '#/components/doc-alert';
import { $t } from '#/locales';
2025-04-06 10:44:23 +08:00
import { downloadByData } from '#/utils/download';
import { useGridColumns, useGridFormSchema } from './data';
2025-04-22 11:25:11 +08:00
import Detail from './modules/detail.vue';
2025-04-06 10:44:23 +08:00
const [DetailModal, detailModalApi] = useVbenModal({
connectedComponent: Detail,
destroyOnClose: true,
});
/** 刷新表格 */
function onRefresh() {
gridApi.query();
}
/** 导出表格 */
async function onExport() {
const data = await exportOperateLog(await gridApi.formApi.getValues());
downloadByData(data, '操作日志.xls');
}
/** 查看操作日志详情 */
2025-04-22 22:10:33 +08:00
function onDetail(row: SystemOperateLogApi.OperateLog) {
2025-04-06 10:44:23 +08:00
detailModalApi.setData(row).open();
}
/** 表格操作按钮的回调函数 */
function onActionClick({
code,
row,
2025-04-22 22:10:33 +08:00
}: OnActionClickParams<SystemOperateLogApi.OperateLog>) {
2025-04-06 10:44:23 +08:00
switch (code) {
case 'detail': {
onDetail(row);
2025-04-06 10:44:23 +08:00
break;
}
}
}
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
},
gridOptions: {
columns: useGridColumns(onActionClick),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getOperateLogPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
toolbarConfig: {
refresh: { code: 'query' },
search: true,
},
2025-04-22 22:10:33 +08:00
} as VxeTableGridOptions<SystemOperateLogApi.OperateLog>,
2025-04-06 10:44:23 +08:00
});
</script>
<template>
<Page auto-content-height>
<DocAlert title="系统日志" url="https://doc.iocoder.cn/system-log/" />
<DetailModal @success="onRefresh" />
<Grid table-title="操作日志列表">
<template #toolbar-tools>
2025-04-22 11:25:11 +08:00
<Button
type="primary"
class="ml-2"
@click="onExport"
v-access:code="['system:operate-log:export']"
>
2025-04-06 10:44:23 +08:00
<Download class="size-5" />
{{ $t('ui.actionTitle.export') }}
</Button>
</template>
</Grid>
</Page>
</template>