2 changed files with 151 additions and 1 deletions
@ -0,0 +1,110 @@
|
||||
import { BasicColumn, FormSchema, useRender } from '@/components/Table' |
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
||||
|
||||
export const columns: BasicColumn[] = [ |
||||
{ |
||||
title: '日志编号', |
||||
dataIndex: 'id', |
||||
width: 100 |
||||
}, |
||||
{ |
||||
title: '用户编号', |
||||
dataIndex: 'userId', |
||||
width: 100 |
||||
}, |
||||
{ |
||||
title: '用户类型', |
||||
dataIndex: 'userType', |
||||
width: 120, |
||||
customRender: ({ text }) => { |
||||
return useRender.renderDict(text, DICT_TYPE.USER_TYPE) |
||||
} |
||||
}, |
||||
{ |
||||
title: '应用名', |
||||
dataIndex: 'applicationName', |
||||
width: 120 |
||||
}, |
||||
{ |
||||
title: '请求方法名', |
||||
dataIndex: 'requestMethod', |
||||
width: 120 |
||||
}, |
||||
{ |
||||
title: '请求地址', |
||||
dataIndex: 'requestUrl', |
||||
width: 250 |
||||
}, |
||||
{ |
||||
title: '请求时间', |
||||
dataIndex: 'beginTime', |
||||
width: 180, |
||||
customRender: ({ text }) => { |
||||
return useRender.renderDate(text) |
||||
} |
||||
}, |
||||
{ |
||||
title: '执行时长', |
||||
dataIndex: 'duration', |
||||
width: 180, |
||||
customRender: ({ text }) => { |
||||
return useRender.renderText(text, 'ms') |
||||
} |
||||
}, |
||||
{ |
||||
title: '操作结果', |
||||
dataIndex: 'status', |
||||
width: 180, |
||||
customRender: ({ record }) => { |
||||
return useRender.renderTag(record.resultCode === 0 ? '成功' : '失败(' + record.resultMsg + ')') |
||||
} |
||||
} |
||||
] |
||||
|
||||
export const searchFormSchema: FormSchema[] = [ |
||||
{ |
||||
label: '用户编号', |
||||
field: 'userId', |
||||
component: 'Input', |
||||
colProps: { span: 8 } |
||||
}, |
||||
{ |
||||
label: '用户类型', |
||||
field: 'userType', |
||||
component: 'Select', |
||||
componentProps: { |
||||
options: getIntDictOptions(DICT_TYPE.USER_TYPE) |
||||
}, |
||||
colProps: { span: 8 } |
||||
}, |
||||
{ |
||||
label: '应用名', |
||||
field: 'applicationName', |
||||
component: 'Input', |
||||
colProps: { span: 8 } |
||||
}, |
||||
{ |
||||
label: '请求地址', |
||||
field: 'requestUrl', |
||||
component: 'Input', |
||||
colProps: { span: 8 } |
||||
}, |
||||
{ |
||||
label: '请求时间', |
||||
field: 'beginTime', |
||||
component: 'RangePicker', |
||||
colProps: { span: 8 } |
||||
}, |
||||
{ |
||||
label: '执行时长', |
||||
field: 'duration', |
||||
component: 'Input', |
||||
colProps: { span: 8 } |
||||
}, |
||||
{ |
||||
label: '结果码', |
||||
field: 'resultCode', |
||||
component: 'Input', |
||||
colProps: { span: 8 } |
||||
} |
||||
] |
@ -1,3 +1,43 @@
|
||||
<template> |
||||
<div>开发中</div> |
||||
<div> |
||||
<BasicTable @register="registerTable"> |
||||
<template #toolbar> |
||||
<a-button type="warning" @click="handleExport"> {{ t('action.export') }} </a-button> |
||||
</template> |
||||
</BasicTable> |
||||
</div> |
||||
</template> |
||||
<script lang="ts" setup name="ApiErrorLog"> |
||||
import { useI18n } from '@/hooks/web/useI18n' |
||||
import { useMessage } from '@/hooks/web/useMessage' |
||||
import { BasicTable, useTable } from '@/components/Table' |
||||
import { getApiAccessLogPage, exportApiAccessLog, ApiAccessLogExportReqVO } from '@/api/infra/apiAccessLog' |
||||
import { columns, searchFormSchema } from './apiAccessLog.data' |
||||
|
||||
const { t } = useI18n() |
||||
const { createConfirm, createMessage } = useMessage() |
||||
const [registerTable, { getForm }] = useTable({ |
||||
title: '访问日志列表', |
||||
api: getApiAccessLogPage, |
||||
columns, |
||||
formConfig: { |
||||
labelWidth: 120, |
||||
schemas: searchFormSchema |
||||
}, |
||||
useSearchForm: true, |
||||
showTableSetting: true, |
||||
showIndexColumn: false |
||||
}) |
||||
|
||||
async function handleExport() { |
||||
createConfirm({ |
||||
title: t('common.exportTitle'), |
||||
iconType: 'warning', |
||||
content: t('common.exportMessage'), |
||||
async onOk() { |
||||
await exportApiAccessLog(getForm().getFieldsValue() as ApiAccessLogExportReqVO) |
||||
createMessage.success(t('common.exportSuccessText')) |
||||
} |
||||
}) |
||||
} |
||||
</script> |
||||
|
Reference in new issue