2024-10-17 15:16:22 +08:00
|
|
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
2024-09-26 08:40:16 +08:00
|
|
|
import type { DescItem } from '#/components/description';
|
|
|
|
|
|
|
|
import { DictEnum } from '@vben/constants';
|
|
|
|
|
|
|
|
import { Tag } from 'ant-design-vue';
|
|
|
|
|
2024-10-17 15:16:22 +08:00
|
|
|
import { type FormSchemaGetter } from '#/adapter/form';
|
2024-09-26 08:40:16 +08:00
|
|
|
import { getDictOptions } from '#/utils/dict';
|
|
|
|
import {
|
|
|
|
renderDict,
|
|
|
|
renderHttpMethodTag,
|
|
|
|
renderJsonPreview,
|
|
|
|
} from '#/utils/render';
|
|
|
|
|
|
|
|
export const querySchema: FormSchemaGetter = () => [
|
|
|
|
{
|
|
|
|
component: 'Input',
|
|
|
|
fieldName: 'title',
|
|
|
|
label: '系统模块',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: 'Input',
|
|
|
|
fieldName: 'operName',
|
|
|
|
label: '操作人员',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: 'Select',
|
|
|
|
componentProps: {
|
|
|
|
options: getDictOptions(DictEnum.SYS_OPER_TYPE),
|
|
|
|
},
|
|
|
|
fieldName: 'businessType',
|
|
|
|
label: '操作类型',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: 'Input',
|
|
|
|
fieldName: 'operIp',
|
|
|
|
label: '操作IP',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: 'Select',
|
|
|
|
componentProps: {
|
|
|
|
options: getDictOptions(DictEnum.SYS_COMMON_STATUS),
|
|
|
|
},
|
|
|
|
fieldName: 'status',
|
|
|
|
label: '状态',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
component: 'RangePicker',
|
|
|
|
fieldName: 'createTime',
|
|
|
|
label: '操作时间',
|
2024-10-05 12:12:14 +08:00
|
|
|
componentProps: {
|
|
|
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
|
|
|
},
|
2024-09-26 08:40:16 +08:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2024-10-05 12:12:14 +08:00
|
|
|
export const columns: VxeGridProps['columns'] = [
|
|
|
|
{ type: 'checkbox', width: 60 },
|
|
|
|
{ field: 'title', title: '系统模块' },
|
2024-09-26 08:40:16 +08:00
|
|
|
{
|
|
|
|
title: '操作类型',
|
2024-10-05 12:12:14 +08:00
|
|
|
field: 'businessType',
|
2024-10-07 13:21:53 +08:00
|
|
|
slots: {
|
|
|
|
default: ({ row }) => {
|
|
|
|
return renderDict(row.businessType, DictEnum.SYS_OPER_TYPE);
|
|
|
|
},
|
2024-09-26 08:40:16 +08:00
|
|
|
},
|
|
|
|
},
|
2024-10-05 12:12:14 +08:00
|
|
|
{ field: 'operName', title: '操作人员' },
|
|
|
|
{ field: 'operIp', title: 'IP地址' },
|
|
|
|
{ field: 'operLocation', title: 'IP信息' },
|
2024-09-26 08:40:16 +08:00
|
|
|
{
|
2024-10-05 12:12:14 +08:00
|
|
|
field: 'status',
|
|
|
|
title: '操作状态',
|
2024-10-07 13:21:53 +08:00
|
|
|
slots: {
|
|
|
|
default: ({ row }) => {
|
|
|
|
return renderDict(row.status, DictEnum.SYS_COMMON_STATUS);
|
|
|
|
},
|
2024-10-05 12:12:14 +08:00
|
|
|
},
|
2024-09-26 08:40:16 +08:00
|
|
|
},
|
2024-10-10 08:27:56 +08:00
|
|
|
{ field: 'operTime', title: '操作日期', sortable: true },
|
2024-09-26 08:40:16 +08:00
|
|
|
{
|
2024-10-05 12:12:14 +08:00
|
|
|
field: 'costTime',
|
2024-09-26 08:40:16 +08:00
|
|
|
title: '操作耗时',
|
2024-10-10 08:27:56 +08:00
|
|
|
sortable: true,
|
2024-10-05 12:12:14 +08:00
|
|
|
formatter({ cellValue }) {
|
|
|
|
return `${cellValue} ms`;
|
|
|
|
},
|
2024-09-26 08:40:16 +08:00
|
|
|
},
|
|
|
|
{
|
2024-10-05 12:12:14 +08:00
|
|
|
field: 'action',
|
2024-09-26 08:40:16 +08:00
|
|
|
fixed: 'right',
|
2024-10-05 12:12:14 +08:00
|
|
|
slots: { default: 'action' },
|
2024-09-26 08:40:16 +08:00
|
|
|
title: '操作',
|
2024-10-05 12:12:14 +08:00
|
|
|
width: 120,
|
2024-09-26 08:40:16 +08:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
export const descSchema: DescItem[] = [
|
|
|
|
{
|
|
|
|
field: 'operId',
|
|
|
|
label: '日志编号',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'status',
|
|
|
|
label: '操作结果',
|
|
|
|
render(value) {
|
|
|
|
return renderDict(value, DictEnum.SYS_COMMON_STATUS);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'title',
|
|
|
|
label: '操作模块',
|
|
|
|
labelMinWidth: 80,
|
|
|
|
render(value, { businessType }) {
|
|
|
|
const operType = renderDict(businessType, DictEnum.SYS_OPER_TYPE);
|
|
|
|
return (
|
|
|
|
<div class="flex items-center">
|
|
|
|
<Tag>{value}</Tag>
|
|
|
|
{operType}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'operIp',
|
|
|
|
label: '操作信息',
|
|
|
|
render(_, data) {
|
|
|
|
return `账号: ${data.operName} / ${data.deptName} / ${data.operIp} / ${data.operLocation}`;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'operUrl',
|
|
|
|
label: '请求信息',
|
|
|
|
render(_, data) {
|
|
|
|
const { operUrl, requestMethod } = data;
|
|
|
|
const methodTag = renderHttpMethodTag(requestMethod);
|
|
|
|
return (
|
|
|
|
<span>
|
|
|
|
{methodTag} {operUrl}
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'errorMsg',
|
|
|
|
label: '异常信息',
|
|
|
|
render(value) {
|
|
|
|
return <span class="font-bold text-red-600">{value}</span>;
|
|
|
|
},
|
|
|
|
show: (data) => {
|
|
|
|
return data && data.errorMsg !== '';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'method',
|
|
|
|
label: '方法',
|
|
|
|
},
|
2024-12-05 16:08:56 +08:00
|
|
|
/**
|
|
|
|
* 默认word-break: break-word;会导致json预览样式异常
|
|
|
|
*/
|
2024-09-26 08:40:16 +08:00
|
|
|
{
|
|
|
|
field: 'operParam',
|
|
|
|
label: '请求参数',
|
|
|
|
render(value) {
|
|
|
|
return (
|
2024-12-05 16:08:56 +08:00
|
|
|
<div class="max-h-[300px] overflow-y-auto break-normal">
|
2024-09-26 08:40:16 +08:00
|
|
|
{renderJsonPreview(value)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'jsonResult',
|
|
|
|
label: '响应参数',
|
|
|
|
render(value) {
|
|
|
|
return (
|
2024-12-05 16:08:56 +08:00
|
|
|
<div class="max-h-[300px] overflow-y-auto break-normal">
|
2024-09-26 08:40:16 +08:00
|
|
|
{renderJsonPreview(value)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
show(data) {
|
|
|
|
return data && data.jsonResult;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'costTime',
|
|
|
|
label: '耗时',
|
|
|
|
render(value) {
|
|
|
|
return `${value} ms`;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
field: 'operTime',
|
|
|
|
label: '操作时间',
|
|
|
|
},
|
|
|
|
];
|