| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- import type { SmartColumn, SmartSearchFormSchema } from '@/components/SmartTable';
- import dayjs from 'dayjs';
- export type LoginIdent = 'LOGIN_LOG' | 'INTERFACE_LOG';
- /**
- * 获取表格列表
- * @param ident 标识位
- */
- export const getTableColumns = (ident: LoginIdent): SmartColumn[] => {
- return tableColumns.filter((item) => {
- return item.ident === undefined || item.ident.includes(ident);
- }) as SmartColumn[];
- };
- const tableColumns: Array<SmartColumn & { ident?: LoginIdent[] }> = [
- {
- type: 'seq',
- width: 80,
- },
- {
- title: '{system.views.log.title.operation}',
- field: 'operation',
- minWidth: 200,
- },
- {
- title: '{system.views.log.title.logSource}',
- field: 'logSource',
- width: 180,
- },
- {
- title: '{system.views.log.title.createUserId}',
- field: 'createBy',
- width: 120,
- },
- {
- title: '{system.views.log.title.ip}',
- field: 'ip',
- width: 160,
- },
- {
- title: '{system.views.log.title.operationType}',
- field: 'operationType',
- headerAlign: 'left',
- align: 'center',
- width: 120,
- ident: ['INTERFACE_LOG'],
- },
- {
- title: '{system.views.log.title.requestPath}',
- field: 'requestPath',
- width: 200,
- ident: ['INTERFACE_LOG'],
- },
- {
- title: '{system.views.log.title.statusCode}',
- field: 'statusCode',
- width: 120,
- headerAlign: 'left',
- align: 'center',
- slots: {
- default: 'table-statusCode',
- },
- sortable: true,
- },
- {
- title: '{system.views.log.title.method}',
- field: 'method',
- width: 200,
- ident: ['INTERFACE_LOG'],
- },
- {
- title: '{system.views.log.title.useTime}',
- field: 'useTime',
- width: 140,
- headerAlign: 'left',
- align: 'center',
- sortable: true,
- slots: {
- default: 'table-useTime',
- },
- ident: ['INTERFACE_LOG'],
- },
- {
- title: '{system.views.log.title.createTime}',
- field: 'createTime',
- width: 180,
- sortable: true,
- },
- {
- title: '{common.table.operation}',
- field: 'table-operation',
- width: 100,
- fixed: 'right',
- slots: {
- default: 'table-operation',
- },
- },
- ];
- const logSourceEnum = [
- {
- value: '10',
- enumName: 'AUTO_POINTCUT',
- label: 'system.views.log.title.logSourceAuto',
- ident: ['INTERFACE_LOG'],
- },
- {
- value: '20',
- enumName: 'MANUAL',
- label: 'system.views.log.title.logSourceManual',
- ident: ['INTERFACE_LOG'],
- },
- {
- value: '30',
- enumName: 'LOGIN',
- label: 'system.views.log.title.logSourceLoginSuccess',
- ident: ['LOGIN_LOG'],
- },
- {
- value: '40',
- enumName: 'LOGOUT',
- label: 'system.views.log.title.logSourceLogout',
- ident: ['LOGIN_LOG'],
- },
- {
- value: '50',
- enumName: 'LOGIN_FAIL',
- label: 'system.views.log.title.logSourceLoginFail',
- ident: ['LOGIN_LOG'],
- },
- ];
- export const getLogSourceEnum = (ident: LoginIdent, t: Function) => {
- return logSourceEnum
- .filter((item) => item.ident === undefined || item.ident.includes(ident))
- .map((item) => {
- return {
- value: item.value,
- label: t(item.label),
- };
- });
- };
- const operationTypeEnum = [
- {
- value: 'ADD',
- label: 'system.views.log.title.operationTypeAdd',
- },
- {
- value: 'DELETE',
- label: 'system.views.log.title.operationTypeDelete',
- },
- {
- value: 'UPDATE',
- label: 'system.views.log.title.operationTypeUpdate',
- },
- {
- value: 'QUERY',
- label: 'system.views.log.title.operationTypeQuery',
- },
- ];
- export const getOperationTypeEnum = (t: Function) => {
- return operationTypeEnum.map((item) => {
- return {
- label: t(item.label),
- value: item.value,
- };
- });
- };
- /**
- * 获取搜索表单
- * @param t
- * @param ident
- */
- export const getSearchFormSchemas = (t: Function, ident: LoginIdent) => {
- const schemas: Array<SmartSearchFormSchema & { ident?: LoginIdent[] }> = [
- {
- label: t('system.views.log.title.operation'),
- field: 'operation',
- component: 'Input',
- searchSymbol: 'like',
- },
- {
- label: t('system.views.log.title.logSource'),
- field: 'logSource',
- component: 'Select',
- componentProps: {
- mode: 'multiple',
- style: { width: '200px' },
- options: getLogSourceEnum(ident, t),
- },
- searchSymbol: 'in',
- },
- {
- label: t('system.views.log.title.statusCode'),
- field: 'statusCode',
- component: 'Input',
- searchSymbol: '=',
- componentProps: {
- style: { width: '120px' },
- },
- },
- {
- label: t('system.views.log.title.createTime'),
- field: 'createTime',
- component: 'RangePicker',
- searchSymbol: 'between',
- componentProps: {
- style: { width: '340px' },
- showTime: {
- defaultValue: [dayjs('00:00:00', 'HH:mm:ss')],
- },
- },
- },
- {
- label: t('system.views.log.title.operationType'),
- field: 'operationType',
- component: 'Select',
- searchSymbol: '=',
- ident: ['INTERFACE_LOG'],
- componentProps: {
- optionLabelProp: 'children',
- mode: 'multiple',
- style: { width: '120px' },
- options: getOperationTypeEnum(t),
- },
- },
- ];
- return schemas.filter((item) => item.ident === undefined || item.ident.includes(ident));
- };
|