103 lines
2.6 KiB
TypeScript
103 lines
2.6 KiB
TypeScript
import type { VxeGridProps } from '@vben/plugins/vxe-table';
|
|
|
|
export interface AdminLog {
|
|
id: number;
|
|
admin_id: number;
|
|
admin_name: string;
|
|
module: string;
|
|
controller: string;
|
|
action: string;
|
|
method: string;
|
|
url: string;
|
|
params: string;
|
|
ip: string;
|
|
user_agent: string;
|
|
result: 'success' | 'failed';
|
|
message?: string;
|
|
create_time: string;
|
|
}
|
|
|
|
export interface LogForm {
|
|
id?: number;
|
|
admin_id: number;
|
|
admin_name: string;
|
|
module: string;
|
|
controller: string;
|
|
action: string;
|
|
method: string;
|
|
url: string;
|
|
params: string;
|
|
ip: string;
|
|
user_agent: string;
|
|
result: string;
|
|
message?: string;
|
|
}
|
|
|
|
export const resultOptions = [
|
|
{ label: '成功', value: 'success' },
|
|
{ label: '失败', value: 'failed' },
|
|
];
|
|
|
|
export const methodOptions = [
|
|
{ label: 'GET', value: 'GET' },
|
|
{ label: 'POST', value: 'POST' },
|
|
{ label: 'PUT', value: 'PUT' },
|
|
{ label: 'DELETE', value: 'DELETE' },
|
|
{ label: 'PATCH', value: 'PATCH' },
|
|
];
|
|
|
|
export const resultColorMap = {
|
|
success: 'success',
|
|
failed: 'error',
|
|
};
|
|
|
|
export const gridOptions: VxeGridProps<AdminLog> = {
|
|
columns: [
|
|
{ type: 'checkbox', width: 50 },
|
|
{ field: 'admin_name', title: '管理员', width: 120 },
|
|
{ field: 'module', title: '模块', width: 100 },
|
|
{ field: 'controller', title: '控制器', width: 120 },
|
|
{ field: 'action', title: '操作', width: 100 },
|
|
{ field: 'method', title: '方法', width: 80 },
|
|
{ field: 'url', title: 'URL', minWidth: 200, showOverflow: true },
|
|
{ field: 'ip', title: 'IP地址', width: 120 },
|
|
{ field: 'result', title: '结果', width: 80, formatter: ({ cellValue }) => {
|
|
const colorMap = { success: 'success', failed: 'error' };
|
|
const color = colorMap[cellValue] || 'default';
|
|
return `<span class="ant-tag ant-tag-${color}">${cellValue === 'success' ? '成功' : '失败'}</span>`;
|
|
} },
|
|
{ field: 'create_time', title: '操作时间', width: 180 },
|
|
{
|
|
field: 'action',
|
|
fixed: 'right',
|
|
title: '操作',
|
|
width: 100,
|
|
cellRender: {
|
|
name: 'CellOperation',
|
|
attrs: {
|
|
onClick: (code: string, row: AdminLog) => {
|
|
// This will be handled in the component
|
|
},
|
|
options: [
|
|
{ code: 'view', text: '查看详情', icon: 'ant-design:eye-outlined' },
|
|
],
|
|
},
|
|
},
|
|
},
|
|
],
|
|
height: 'auto',
|
|
keepSource: true,
|
|
pagerConfig: {
|
|
enabled: true,
|
|
pageSize: 20,
|
|
pageSizes: [10, 20, 50, 100],
|
|
},
|
|
toolbarConfig: {
|
|
custom: true,
|
|
export: true,
|
|
// import: true,
|
|
print: true,
|
|
refresh: true,
|
|
zoom: true,
|
|
},
|
|
}; |