reactor:【system 系统管理】infra 的 apiErrorLog 进一步统一代码风格
parent
cec3b7ab1e
commit
58ed3bfc2e
|
@ -77,14 +77,17 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
{
|
{
|
||||||
field: 'id',
|
field: 'id',
|
||||||
title: '日志编号',
|
title: '日志编号',
|
||||||
|
minWidth: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'userId',
|
field: 'userId',
|
||||||
title: '用户编号',
|
title: '用户编号',
|
||||||
|
minWidth: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'userType',
|
field: 'userType',
|
||||||
title: '用户类型',
|
title: '用户类型',
|
||||||
|
minWidth: 120,
|
||||||
cellRender: {
|
cellRender: {
|
||||||
name: 'CellDict',
|
name: 'CellDict',
|
||||||
props: { type: DICT_TYPE.USER_TYPE },
|
props: { type: DICT_TYPE.USER_TYPE },
|
||||||
|
@ -93,27 +96,33 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
{
|
{
|
||||||
field: 'applicationName',
|
field: 'applicationName',
|
||||||
title: '应用名',
|
title: '应用名',
|
||||||
|
minWidth: 150,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'requestMethod',
|
field: 'requestMethod',
|
||||||
title: '请求方法',
|
title: '请求方法',
|
||||||
|
minWidth: 80,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'requestUrl',
|
field: 'requestUrl',
|
||||||
title: '请求地址',
|
title: '请求地址',
|
||||||
|
minWidth: 200,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'exceptionTime',
|
field: 'exceptionTime',
|
||||||
title: '异常发生时间',
|
title: '异常发生时间',
|
||||||
|
minWidth: 180,
|
||||||
formatter: 'formatDateTime',
|
formatter: 'formatDateTime',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'exceptionName',
|
field: 'exceptionName',
|
||||||
title: '异常名',
|
title: '异常名',
|
||||||
|
minWidth: 180,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'processStatus',
|
field: 'processStatus',
|
||||||
title: '处理状态',
|
title: '处理状态',
|
||||||
|
minWidth: 120,
|
||||||
cellRender: {
|
cellRender: {
|
||||||
name: 'CellDict',
|
name: 'CellDict',
|
||||||
props: { type: DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS },
|
props: { type: DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS },
|
||||||
|
@ -121,7 +130,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: 200,
|
minWidth: 200,
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
slots: { default: 'actions' },
|
slots: { default: 'actions' },
|
||||||
},
|
},
|
||||||
|
|
|
@ -25,7 +25,7 @@ const [DetailModal, detailModalApi] = useVbenModal({
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,14 +42,20 @@ function handleDetail(row: InfraApiErrorLogApi.ApiErrorLog) {
|
||||||
|
|
||||||
/** 处理已处理 / 已忽略的操作 */
|
/** 处理已处理 / 已忽略的操作 */
|
||||||
async function handleProcess(id: number, processStatus: number) {
|
async function handleProcess(id: number, processStatus: number) {
|
||||||
confirm({
|
await confirm({
|
||||||
content: `确认标记为${InfraApiErrorLogProcessStatusEnum.DONE ? '已处理' : '已忽略'}?`,
|
content: `确认标记为${InfraApiErrorLogProcessStatusEnum.DONE ? '已处理' : '已忽略'}?`,
|
||||||
}).then(async () => {
|
|
||||||
await updateApiErrorLogStatus(id, processStatus);
|
|
||||||
// 关闭并提示
|
|
||||||
message.success($t('ui.actionMessage.operationSuccess'));
|
|
||||||
onRefresh();
|
|
||||||
});
|
});
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: '正在处理中...',
|
||||||
|
duration: 0,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await updateApiErrorLogStatus(id, processStatus);
|
||||||
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
@ -73,6 +79,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
},
|
},
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
},
|
},
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
refresh: true,
|
refresh: true,
|
||||||
|
@ -88,7 +95,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
<DocAlert title="系统日志" url="https://doc.iocoder.cn/system-log/" />
|
<DocAlert title="系统日志" url="https://doc.iocoder.cn/system-log/" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<DetailModal @success="onRefresh" />
|
<DetailModal @success="handleRefresh" />
|
||||||
<Grid table-title="API 错误日志列表">
|
<Grid table-title="API 错误日志列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
|
@ -116,6 +123,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
{
|
{
|
||||||
label: '已处理',
|
label: '已处理',
|
||||||
type: 'link',
|
type: 'link',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
auth: ['infra:api-error-log:update-status'],
|
auth: ['infra:api-error-log:update-status'],
|
||||||
ifShow:
|
ifShow:
|
||||||
row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT,
|
row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT,
|
||||||
|
@ -128,6 +136,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
{
|
{
|
||||||
label: '已忽略',
|
label: '已忽略',
|
||||||
type: 'link',
|
type: 'link',
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
auth: ['infra:api-error-log:update-status'],
|
auth: ['infra:api-error-log:update-status'],
|
||||||
ifShow:
|
ifShow:
|
||||||
row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT,
|
row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT,
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { InfraApiErrorLogApi } from '#/api/infra/api-error-log';
|
|
||||||
|
|
||||||
import { useAccess } from '@vben/access';
|
|
||||||
import { DICT_TYPE, InfraApiErrorLogProcessStatusEnum } from '@vben/constants';
|
import { DICT_TYPE, InfraApiErrorLogProcessStatusEnum } from '@vben/constants';
|
||||||
import { getDictOptions } from '@vben/hooks';
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
import { getRangePickerDefaultProps } from '#/utils';
|
import { getRangePickerDefaultProps } from '#/utils';
|
||||||
|
|
||||||
const { hasAccessByCodes } = useAccess();
|
|
||||||
|
|
||||||
/** 列表的搜索表单 */
|
/** 列表的搜索表单 */
|
||||||
export function useGridFormSchema(): VbenFormSchema[] {
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
return [
|
return [
|
||||||
|
@ -68,9 +64,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 列表的字段 */
|
/** 列表的字段 */
|
||||||
export function useGridColumns<T = InfraApiErrorLogApi.ApiErrorLog>(
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
onActionClick: OnActionClickFn<T>,
|
|
||||||
): VxeTableGridOptions['columns'] {
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
field: 'id',
|
field: 'id',
|
||||||
|
@ -127,46 +121,10 @@ export function useGridColumns<T = InfraApiErrorLogApi.ApiErrorLog>(
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'operation',
|
|
||||||
title: '操作',
|
title: '操作',
|
||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
align: 'center',
|
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
cellRender: {
|
slots: { default: 'actions' },
|
||||||
attrs: {
|
|
||||||
nameField: 'id',
|
|
||||||
nameTitle: 'API错误日志',
|
|
||||||
onClick: onActionClick,
|
|
||||||
},
|
|
||||||
name: 'CellOperation',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
code: 'detail',
|
|
||||||
text: '详情',
|
|
||||||
show: hasAccessByCodes(['infra:api-error-log:query']),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'done',
|
|
||||||
text: '已处理',
|
|
||||||
show: (row: InfraApiErrorLogApi.ApiErrorLog) => {
|
|
||||||
return (
|
|
||||||
row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT &&
|
|
||||||
hasAccessByCodes(['infra:api-error-log:update-status'])
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'ignore',
|
|
||||||
text: '已忽略',
|
|
||||||
show: (row: InfraApiErrorLogApi.ApiErrorLog) => {
|
|
||||||
return (
|
|
||||||
row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT &&
|
|
||||||
hasAccessByCodes(['infra:api-error-log:update-status'])
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type {
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
OnActionClickParams,
|
|
||||||
VxeTableGridOptions,
|
|
||||||
} from '#/adapter/vxe-table';
|
|
||||||
import type { InfraApiErrorLogApi } from '#/api/infra/api-error-log';
|
import type { InfraApiErrorLogApi } from '#/api/infra/api-error-log';
|
||||||
|
|
||||||
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
import { InfraApiErrorLogProcessStatusEnum } from '@vben/constants';
|
import { InfraApiErrorLogProcessStatusEnum } from '@vben/constants';
|
||||||
import { Download } from '@vben/icons';
|
|
||||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||||
|
|
||||||
import { ElButton, ElMessage } from 'element-plus';
|
import { ElLoading, ElMessage } from 'element-plus';
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import {
|
import {
|
||||||
exportApiErrorLog,
|
exportApiErrorLog,
|
||||||
getApiErrorLogPage,
|
getApiErrorLogPage,
|
||||||
|
@ -29,51 +25,35 @@ const [DetailModal, detailModalApi] = useVbenModal({
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 导出表格 */
|
/** 导出表格 */
|
||||||
async function onExport() {
|
async function handleExport() {
|
||||||
const data = await exportApiErrorLog(await gridApi.formApi.getValues());
|
const data = await exportApiErrorLog(await gridApi.formApi.getValues());
|
||||||
downloadFileFromBlobPart({ fileName: 'API 错误日志.xls', source: data });
|
downloadFileFromBlobPart({ fileName: 'API 错误日志.xls', source: data });
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查看 API 错误日志详情 */
|
/** 查看 API 错误日志详情 */
|
||||||
function onDetail(row: InfraApiErrorLogApi.ApiErrorLog) {
|
function handleDetail(row: InfraApiErrorLogApi.ApiErrorLog) {
|
||||||
detailModalApi.setData(row).open();
|
detailModalApi.setData(row).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 处理已处理 / 已忽略的操作 */
|
/** 处理已处理 / 已忽略的操作 */
|
||||||
async function onProcess(id: number, processStatus: number) {
|
async function handleProcess(id: number, processStatus: number) {
|
||||||
confirm({
|
await confirm({
|
||||||
content: `确认标记为${InfraApiErrorLogProcessStatusEnum.DONE ? '已处理' : '已忽略'}?`,
|
content: `确认标记为${InfraApiErrorLogProcessStatusEnum.DONE ? '已处理' : '已忽略'}?`,
|
||||||
}).then(async () => {
|
|
||||||
await updateApiErrorLogStatus(id, processStatus);
|
|
||||||
// 关闭并提示
|
|
||||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
|
||||||
onRefresh();
|
|
||||||
});
|
});
|
||||||
}
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: '正在处理中...',
|
||||||
/** 表格操作按钮的回调函数 */
|
});
|
||||||
function onActionClick({
|
try {
|
||||||
code,
|
await updateApiErrorLogStatus(id, processStatus);
|
||||||
row,
|
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||||
}: OnActionClickParams<InfraApiErrorLogApi.ApiErrorLog>) {
|
handleRefresh();
|
||||||
switch (code) {
|
} finally {
|
||||||
case 'detail': {
|
loadingInstance.close();
|
||||||
onDetail(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'done': {
|
|
||||||
onProcess(row.id, InfraApiErrorLogProcessStatusEnum.DONE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'ignore': {
|
|
||||||
onProcess(row.id, InfraApiErrorLogProcessStatusEnum.IGNORE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +62,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
schema: useGridFormSchema(),
|
schema: useGridFormSchema(),
|
||||||
},
|
},
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: useGridColumns(onActionClick),
|
columns: useGridColumns(),
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
keepSource: true,
|
keepSource: true,
|
||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
|
@ -98,6 +78,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
},
|
},
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
},
|
},
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
refresh: true,
|
refresh: true,
|
||||||
|
@ -113,18 +94,62 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
<DocAlert title="系统日志" url="https://doc.iocoder.cn/system-log/" />
|
<DocAlert title="系统日志" url="https://doc.iocoder.cn/system-log/" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<DetailModal @success="onRefresh" />
|
<DetailModal @success="handleRefresh" />
|
||||||
<Grid table-title="API 错误日志列表">
|
<Grid table-title="API 错误日志列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<ElButton
|
<TableAction
|
||||||
type="primary"
|
:actions="[
|
||||||
class="ml-2"
|
{
|
||||||
@click="onExport"
|
label: $t('ui.actionTitle.export'),
|
||||||
v-access:code="['infra:api-error-log:export']"
|
type: 'primary',
|
||||||
>
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
<Download class="size-5" />
|
auth: ['infra:api-error-log:export'],
|
||||||
{{ $t('ui.actionTitle.export') }}
|
onClick: handleExport,
|
||||||
</ElButton>
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.detail'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.VIEW,
|
||||||
|
auth: ['infra:api-error-log:query'],
|
||||||
|
onClick: handleDetail.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '已处理',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
auth: ['infra:api-error-log:update-status'],
|
||||||
|
ifShow:
|
||||||
|
row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT,
|
||||||
|
onClick: handleProcess.bind(
|
||||||
|
null,
|
||||||
|
row.id,
|
||||||
|
InfraApiErrorLogProcessStatusEnum.DONE,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '已忽略',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['infra:api-error-log:update-status'],
|
||||||
|
ifShow:
|
||||||
|
row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT,
|
||||||
|
onClick: handleProcess.bind(
|
||||||
|
null,
|
||||||
|
row.id,
|
||||||
|
InfraApiErrorLogProcessStatusEnum.IGNORE,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
||||||
|
|
Loading…
Reference in New Issue