2 changed files with 123 additions and 1 deletions
@ -1,3 +1,43 @@
|
||||
<template> |
||||
<div>index</div> |
||||
<div> |
||||
<BasicTable @register="registerTable"> |
||||
<template #toolbar> |
||||
<a-button type="warning" @click="handleExport"> 导出 </a-button> |
||||
</template> |
||||
</BasicTable> |
||||
</div> |
||||
</template> |
||||
<script lang="ts" setup name="Post"> |
||||
import { BasicTable, useTable } from '@/components/Table' |
||||
import { LoginLogReqVO, exportLoginLogApi, getLoginLogPageApi } from '@/api/system/loginLog' |
||||
import { columns, searchFormSchema } from './loginLog.data' |
||||
import { useI18n } from '@/hooks/web/useI18n' |
||||
import { useMessage } from '@/hooks/web/useMessage' |
||||
|
||||
const { t } = useI18n() |
||||
const { createConfirm, createMessage } = useMessage() |
||||
const [registerTable, { getForm }] = useTable({ |
||||
title: '登录日志列表', |
||||
api: getLoginLogPageApi, |
||||
columns, |
||||
formConfig: { |
||||
labelWidth: 120, |
||||
schemas: searchFormSchema |
||||
}, |
||||
useSearchForm: true, |
||||
showTableSetting: true, |
||||
showIndexColumn: false |
||||
}) |
||||
|
||||
async function handleExport() { |
||||
createConfirm({ |
||||
title: '导出', |
||||
iconType: 'warning', |
||||
content: '是否要导出数据?', |
||||
async onOk() { |
||||
await exportLoginLogApi(getForm().getFieldsValue() as LoginLogReqVO) |
||||
createMessage.success(t('common.exportSuccessText')) |
||||
} |
||||
}) |
||||
} |
||||
</script> |
||||
|
@ -0,0 +1,82 @@
|
||||
import { BasicColumn, FormSchema, useRender } from '@/components/Table' |
||||
import { DICT_TYPE } from '@/utils/dict' |
||||
|
||||
export const columns: BasicColumn[] = [ |
||||
{ |
||||
title: '访问编号', |
||||
dataIndex: 'id', |
||||
width: 100 |
||||
}, |
||||
{ |
||||
title: '日志类型', |
||||
dataIndex: 'logType', |
||||
width: 120, |
||||
customRender: ({ text }) => { |
||||
return useRender.renderDict(text, DICT_TYPE.SYSTEM_LOGIN_TYPE) |
||||
} |
||||
}, |
||||
{ |
||||
title: '用户名称', |
||||
dataIndex: 'username', |
||||
width: 120 |
||||
}, |
||||
{ |
||||
title: '登录地址', |
||||
dataIndex: 'userIp', |
||||
width: 120 |
||||
}, |
||||
{ |
||||
title: 'userAgent', |
||||
dataIndex: 'userAgent', |
||||
width: 400 |
||||
}, |
||||
{ |
||||
title: '结果', |
||||
dataIndex: 'result', |
||||
width: 180, |
||||
customRender: ({ text }) => { |
||||
return useRender.renderDict(text, DICT_TYPE.SYSTEM_LOGIN_RESULT) |
||||
} |
||||
}, |
||||
{ |
||||
title: '登录日期', |
||||
dataIndex: 'loginTime', |
||||
width: 180, |
||||
customRender: ({ text }) => { |
||||
return useRender.renderDate(text) |
||||
} |
||||
} |
||||
] |
||||
|
||||
export const searchFormSchema: FormSchema[] = [ |
||||
{ |
||||
label: '登录地址', |
||||
field: 'userIp', |
||||
component: 'Input', |
||||
colProps: { span: 8 } |
||||
}, |
||||
{ |
||||
label: '用户名称', |
||||
field: 'username', |
||||
component: 'Input', |
||||
colProps: { span: 8 } |
||||
}, |
||||
{ |
||||
label: '结果', |
||||
field: 'result', |
||||
component: 'Select', |
||||
componentProps: { |
||||
options: [ |
||||
{ label: '成功', value: 'true', key: 'true' }, |
||||
{ label: '失败', value: 'false', key: 'false' } |
||||
] |
||||
}, |
||||
colProps: { span: 8 } |
||||
}, |
||||
{ |
||||
label: '登录时间', |
||||
field: 'createTime', |
||||
component: 'RangePicker', |
||||
colProps: { span: 8 } |
||||
} |
||||
] |
Reference in new issue