Files
iot-device-management-frontend/apps/web-antd/src/views/system/loginlog/data.ts

148 lines
3.1 KiB
TypeScript
Raw Normal View History

2025-04-06 10:23:57 +08:00
import type { VbenFormSchema } from '#/adapter/form';
2025-05-19 17:58:06 +08:00
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
2025-06-24 17:35:43 +08:00
import type { DescriptionItemSchema } from '#/components/description';
2025-04-06 10:23:57 +08:00
2025-06-24 17:35:43 +08:00
import { h } from 'vue';
2025-09-05 12:24:16 +08:00
import { DICT_TYPE } from '@vben/constants';
2025-06-24 17:35:43 +08:00
import { formatDateTime } from '@vben/utils';
import { DictTag } from '#/components/dict-tag';
2025-09-05 12:24:16 +08:00
import { getRangePickerDefaultProps } from '#/utils';
2025-04-22 11:25:11 +08:00
2025-04-06 10:23:57 +08:00
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'username',
label: '用户名称',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入用户名称',
},
},
{
fieldName: 'userIp',
label: '登录地址',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入登录地址',
},
},
{
fieldName: 'createTime',
label: '登录时间',
component: 'RangePicker',
componentProps: {
...getRangePickerDefaultProps(),
allowClear: true,
},
},
];
}
/** 列表的字段 */
2025-05-19 17:58:06 +08:00
export function useGridColumns(): VxeTableGridOptions['columns'] {
2025-04-06 10:23:57 +08:00
return [
{
field: 'id',
title: '日志编号',
minWidth: 100,
2025-04-06 10:23:57 +08:00
},
{
field: 'logType',
title: '操作类型',
minWidth: 120,
2025-04-06 10:23:57 +08:00
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.SYSTEM_LOGIN_TYPE },
},
},
{
field: 'username',
title: '用户名称',
minWidth: 180,
2025-04-06 10:23:57 +08:00
},
{
field: 'userIp',
title: '登录地址',
minWidth: 180,
2025-04-06 10:23:57 +08:00
},
{
field: 'userAgent',
title: '浏览器',
minWidth: 200,
2025-04-06 10:23:57 +08:00
},
{
field: 'result',
title: '登录结果',
minWidth: 120,
2025-04-06 10:23:57 +08:00
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.SYSTEM_LOGIN_RESULT },
},
},
{
field: 'createTime',
title: '登录日期',
minWidth: 180,
2025-04-06 10:23:57 +08:00
formatter: 'formatDateTime',
},
{
title: '操作',
width: 120,
2025-04-06 10:23:57 +08:00
fixed: 'right',
2025-05-19 17:58:06 +08:00
slots: { default: 'actions' },
2025-04-06 10:23:57 +08:00
},
];
}
2025-06-24 17:35:43 +08:00
/** 详情页的字段 */
export function useDetailSchema(): DescriptionItemSchema[] {
return [
{
field: 'id',
label: '日志编号',
},
{
field: 'logType',
label: '操作类型',
content: (data) => {
return h(DictTag, {
type: DICT_TYPE.SYSTEM_LOGIN_TYPE,
value: data?.logType,
});
},
},
{
field: 'username',
label: '用户名称',
},
{
field: 'userIp',
label: '登录地址',
},
{
field: 'userAgent',
label: '浏览器',
},
{
field: 'result',
label: '登录结果',
content: (data) => {
return h(DictTag, {
type: DICT_TYPE.SYSTEM_LOGIN_RESULT,
value: data?.result,
});
},
},
{
field: 'createTime',
label: '登录日期',
content: (data) => formatDateTime(data?.createTime || '') as string,
},
];
}