diff --git a/apps/web-antd/src/views/infra/apiAccessLog/data.ts b/apps/web-antd/src/views/infra/apiAccessLog/data.ts index 9f4235303..d392df16f 100644 --- a/apps/web-antd/src/views/infra/apiAccessLog/data.ts +++ b/apps/web-antd/src/views/infra/apiAccessLog/data.ts @@ -1,5 +1,6 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { InfraApiAccessLogApi } from '#/api/infra/api-access-log'; import type { DescriptionItemSchema } from '#/components/description'; import { h } from 'vue'; @@ -180,7 +181,7 @@ export function useDetailSchema(): DescriptionItemSchema[] { { field: 'userType', label: '用户类型', - content: (data) => { + content: (data: InfraApiAccessLogApi.ApiAccessLog) => { return h(DictTag, { type: DICT_TYPE.USER_TYPE, value: data.userType, @@ -189,23 +190,25 @@ export function useDetailSchema(): DescriptionItemSchema[] { }, { field: 'userIp', - label: '用户IP', + label: '用户 IP', }, { field: 'userAgent', - label: '用户UA', + label: '用户 UA', }, { - field: 'requestMethod', label: '请求信息', - content: (data) => { - return `${data.requestMethod} ${data.requestUrl}`; + content: (data: InfraApiAccessLogApi.ApiAccessLog) => { + if (data?.requestMethod && data?.requestUrl) { + return `${data.requestMethod} ${data.requestUrl}`; + } + return ''; }, }, { field: 'requestParams', label: '请求参数', - content: (data) => { + content: (data: InfraApiAccessLogApi.ApiAccessLog) => { if (data.requestParams) { return h(JsonViewer, { value: JSON.parse(data.requestParams), @@ -220,23 +223,29 @@ export function useDetailSchema(): DescriptionItemSchema[] { label: '请求结果', }, { - field: 'beginTime', label: '请求时间', - content: (data) => { - return `${formatDateTime(data?.beginTime)} ~ ${formatDateTime(data?.endTime)}`; + content: (data: InfraApiAccessLogApi.ApiAccessLog) => { + if (data?.beginTime && data?.endTime) { + return `${formatDateTime(data.beginTime)} ~ ${formatDateTime(data.endTime)}`; + } + return ''; }, }, { - field: 'duration', label: '请求耗时', + content: (data: InfraApiAccessLogApi.ApiAccessLog) => { + return data?.duration ? `${data.duration} ms` : ''; + }, }, { - field: 'resultCode', label: '操作结果', - content: (data) => { - return data.resultCode === 0 - ? '成功' - : `失败 | ${data.resultCode} | ${data.resultMsg}`; + content: (data: InfraApiAccessLogApi.ApiAccessLog) => { + if (data?.resultCode === 0) { + return '正常'; + } else if (data && data.resultCode > 0) { + return `失败 | ${data.resultCode} | ${data.resultMsg}`; + } + return ''; }, }, { @@ -250,11 +259,12 @@ export function useDetailSchema(): DescriptionItemSchema[] { { field: 'operateType', label: '操作类型', - content: (data) => - h(DictTag, { + content: (data: InfraApiAccessLogApi.ApiAccessLog) => { + return h(DictTag, { type: DICT_TYPE.INFRA_OPERATE_TYPE, value: data?.operateType, - }), + }); + }, }, ]; } diff --git a/apps/web-antd/src/views/infra/apiAccessLog/modules/detail.vue b/apps/web-antd/src/views/infra/apiAccessLog/modules/detail.vue index c641304e4..061684f37 100644 --- a/apps/web-antd/src/views/infra/apiAccessLog/modules/detail.vue +++ b/apps/web-antd/src/views/infra/apiAccessLog/modules/detail.vue @@ -11,6 +11,15 @@ import { useDetailSchema } from '../data'; const formData = ref(); +const [Descriptions] = useDescription({ + componentProps: { + bordered: true, + column: 1, + class: 'mx-4', + }, + schema: useDetailSchema(), +}); + const [Modal, modalApi] = useVbenModal({ async onOpenChange(isOpen: boolean) { if (!isOpen) { @@ -30,15 +39,6 @@ const [Modal, modalApi] = useVbenModal({ } }, }); - -const [Description] = useDescription({ - componentProps: { - bordered: true, - column: 1, - class: 'mx-4', - }, - schema: useDetailSchema(), -}); diff --git a/apps/web-antd/src/views/infra/apiErrorLog/data.ts b/apps/web-antd/src/views/infra/apiErrorLog/data.ts index 89f886ee3..d716a42a7 100644 --- a/apps/web-antd/src/views/infra/apiErrorLog/data.ts +++ b/apps/web-antd/src/views/infra/apiErrorLog/data.ts @@ -1,5 +1,6 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { InfraApiErrorLogApi } from '#/api/infra/api-error-log'; import type { DescriptionItemSchema } from '#/components/description'; import { h } from 'vue'; @@ -9,8 +10,6 @@ import { DICT_TYPE, InfraApiErrorLogProcessStatusEnum } from '@vben/constants'; import { getDictOptions } from '@vben/hooks'; import { formatDateTime } from '@vben/utils'; -import { Textarea } from 'ant-design-vue'; - import { DictTag } from '#/components/dict-tag'; import { getRangePickerDefaultProps } from '#/utils'; @@ -130,7 +129,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { }, { title: '操作', - minWidth: 200, + minWidth: 220, fixed: 'right', slots: { default: 'actions' }, }, @@ -159,7 +158,7 @@ export function useDetailSchema(): DescriptionItemSchema[] { { field: 'userType', label: '用户类型', - content: (data) => { + content: (data: InfraApiErrorLogApi.ApiErrorLog) => { return h(DictTag, { type: DICT_TYPE.USER_TYPE, value: data.userType, @@ -168,23 +167,26 @@ export function useDetailSchema(): DescriptionItemSchema[] { }, { field: 'userIp', - label: '用户IP', + label: '用户 IP', }, { field: 'userAgent', - label: '用户UA', + label: '用户 UA', }, { field: 'requestMethod', label: '请求信息', - content: (data) => { - return `${data.requestMethod} ${data.requestUrl}`; + content: (data: InfraApiErrorLogApi.ApiErrorLog) => { + if (data?.requestMethod && data?.requestUrl) { + return `${data.requestMethod} ${data.requestUrl}`; + } + return ''; }, }, { field: 'requestParams', label: '请求参数', - content: (data) => { + content: (data: InfraApiErrorLogApi.ApiErrorLog) => { if (data.requestParams) { return h(JsonViewer, { value: JSON.parse(data.requestParams), @@ -197,8 +199,8 @@ export function useDetailSchema(): DescriptionItemSchema[] { { field: 'exceptionTime', label: '异常时间', - content: (data) => { - return formatDateTime(data?.exceptionTime) as string; + content: (data: InfraApiErrorLogApi.ApiErrorLog) => { + return formatDateTime(data?.exceptionTime || '') as string; }, }, { @@ -208,17 +210,24 @@ export function useDetailSchema(): DescriptionItemSchema[] { { field: 'exceptionStackTrace', label: '异常堆栈', - content: (data) => { - return h(Textarea, { - value: data.exceptionStackTrace, - rows: 20, - }); + hidden: (data: InfraApiErrorLogApi.ApiErrorLog) => + !data?.exceptionStackTrace, + content: (data: InfraApiErrorLogApi.ApiErrorLog) => { + if (data?.exceptionStackTrace) { + return h('textarea', { + value: data.exceptionStackTrace, + style: + 'width: 100%; min-height: 200px; max-height: 400px; resize: vertical;', + readonly: true, + }); + } + return ''; }, }, { field: 'processStatus', label: '处理状态', - content: (data) => { + content: (data: InfraApiErrorLogApi.ApiErrorLog) => { return h(DictTag, { type: DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS, value: data?.processStatus, @@ -228,12 +237,14 @@ export function useDetailSchema(): DescriptionItemSchema[] { { field: 'processUserId', label: '处理人', + hidden: (data: InfraApiErrorLogApi.ApiErrorLog) => !data?.processUserId, }, { field: 'processTime', label: '处理时间', - content: (data) => { - return formatDateTime(data?.processTime) as string; + hidden: (data: InfraApiErrorLogApi.ApiErrorLog) => !data?.processTime, + content: (data: InfraApiErrorLogApi.ApiErrorLog) => { + return formatDateTime(data?.processTime || '') as string; }, }, ]; diff --git a/apps/web-antd/src/views/infra/apiErrorLog/modules/detail.vue b/apps/web-antd/src/views/infra/apiErrorLog/modules/detail.vue index b58a41eb6..1e80fa37a 100644 --- a/apps/web-antd/src/views/infra/apiErrorLog/modules/detail.vue +++ b/apps/web-antd/src/views/infra/apiErrorLog/modules/detail.vue @@ -11,6 +11,15 @@ import { useDetailSchema } from '../data'; const formData = ref(); +const [Descriptions] = useDescription({ + componentProps: { + bordered: true, + column: 1, + class: 'mx-4', + }, + schema: useDetailSchema(), +}); + const [Modal, modalApi] = useVbenModal({ async onOpenChange(isOpen: boolean) { if (!isOpen) { @@ -30,24 +39,15 @@ const [Modal, modalApi] = useVbenModal({ } }, }); - -const [Description] = useDescription({ - componentProps: { - bordered: true, - column: 1, - class: 'mx-4', - }, - schema: useDetailSchema(), -}); diff --git a/apps/web-antd/src/views/infra/job/data.ts b/apps/web-antd/src/views/infra/job/data.ts index ef38a68b4..213a95b95 100644 --- a/apps/web-antd/src/views/infra/job/data.ts +++ b/apps/web-antd/src/views/infra/job/data.ts @@ -1,5 +1,6 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { InfraJobApi } from '#/api/infra/job'; import type { DescriptionItemSchema } from '#/components/description'; import { h, markRaw } from 'vue'; @@ -173,7 +174,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { ]; } -/** 详情的配置 */ +/** 详情页的字段 */ export function useDetailSchema(): DescriptionItemSchema[] { return [ { @@ -187,11 +188,12 @@ export function useDetailSchema(): DescriptionItemSchema[] { { field: 'status', label: '任务状态', - content: (data) => - h(DictTag, { + content: (data: InfraJobApi.Job) => { + return h(DictTag, { type: DICT_TYPE.INFRA_JOB_STATUS, value: data?.status, - }), + }); + }, }, { field: 'handlerName', @@ -203,23 +205,25 @@ export function useDetailSchema(): DescriptionItemSchema[] { }, { field: 'cronExpression', - label: 'CRON 表达式', + label: 'Cron 表达式', }, { field: 'retryCount', label: '重试次数', }, { - field: 'retryInterval', label: '重试间隔', + content: (data: InfraJobApi.Job) => { + return data?.retryInterval ? `${data.retryInterval} 毫秒` : '无间隔'; + }, }, { - field: 'monitorTimeout', label: '监控超时时间', - content: (data) => - data?.monitorTimeout && data.monitorTimeout > 0 + content: (data: InfraJobApi.Job) => { + return data?.monitorTimeout && data.monitorTimeout > 0 ? `${data.monitorTimeout} 毫秒` - : '未开启', + : '未开启'; + }, }, { field: 'nextTimes', diff --git a/apps/web-antd/src/views/infra/job/logger/data.ts b/apps/web-antd/src/views/infra/job/logger/data.ts index d6eabd487..d12e7ac56 100644 --- a/apps/web-antd/src/views/infra/job/logger/data.ts +++ b/apps/web-antd/src/views/infra/job/logger/data.ts @@ -1,5 +1,6 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { InfraJobLogApi } from '#/api/infra/job-log'; import type { DescriptionItemSchema } from '#/components/description'; import { h } from 'vue'; @@ -127,7 +128,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { ]; } -/** 详情的配置 */ +/** 详情页的字段 */ export function useDetailSchema(): DescriptionItemSchema[] { return [ { @@ -153,23 +154,29 @@ export function useDetailSchema(): DescriptionItemSchema[] { { field: 'beginTime', label: '执行时间', - }, - { - field: 'endTime', - label: '结束时间', + content: (data: InfraJobLogApi.JobLog) => { + if (data?.beginTime && data?.endTime) { + return `${formatDateTime(data.beginTime)} ~ ${formatDateTime(data.endTime)}`; + } + return ''; + }, }, { field: 'duration', label: '执行时长', + content: (data: InfraJobLogApi.JobLog) => { + return data?.duration ? `${data.duration} 毫秒` : ''; + }, }, { field: 'status', label: '任务状态', - content: (data) => - h(DictTag, { + content: (data: InfraJobLogApi.JobLog) => { + return h(DictTag, { type: DICT_TYPE.INFRA_JOB_LOG_STATUS, value: data?.status, - }), + }); + }, }, { field: 'result', diff --git a/apps/web-antd/src/views/infra/job/logger/modules/detail.vue b/apps/web-antd/src/views/infra/job/logger/modules/detail.vue index be17bb4b6..aa20203cb 100644 --- a/apps/web-antd/src/views/infra/job/logger/modules/detail.vue +++ b/apps/web-antd/src/views/infra/job/logger/modules/detail.vue @@ -12,6 +12,15 @@ import { useDetailSchema } from '../data'; const formData = ref(); +const [Descriptions] = useDescription({ + componentProps: { + bordered: true, + column: 1, + class: 'mx-4', + }, + schema: useDetailSchema(), +}); + const [Modal, modalApi] = useVbenModal({ async onOpenChange(isOpen: boolean) { if (!isOpen) { @@ -31,15 +40,6 @@ const [Modal, modalApi] = useVbenModal({ } }, }); - -const [Description] = useDescription({ - componentProps: { - bordered: true, - column: 1, - class: 'mx-4', - }, - schema: useDetailSchema(), -}); diff --git a/apps/web-ele/src/views/infra/apiAccessLog/data.ts b/apps/web-ele/src/views/infra/apiAccessLog/data.ts index 7de0cf46d..93d736ee9 100644 --- a/apps/web-ele/src/views/infra/apiAccessLog/data.ts +++ b/apps/web-ele/src/views/infra/apiAccessLog/data.ts @@ -1,9 +1,16 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { InfraApiAccessLogApi } from '#/api/infra/api-access-log'; +import type { DescriptionItemSchema } from '#/components/description'; +import { h } from 'vue'; + +import { JsonViewer } from '@vben/common-ui'; import { DICT_TYPE } from '@vben/constants'; import { getDictOptions } from '@vben/hooks'; +import { formatDateTime } from '@vben/utils'; +import { DictTag } from '#/components/dict-tag'; import { getRangePickerDefaultProps } from '#/utils'; /** 列表的搜索表单 */ @@ -151,3 +158,113 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { }, ]; } + +/** 详情页的字段 */ +export function useDetailSchema(): DescriptionItemSchema[] { + return [ + { + field: 'id', + label: '日志编号', + }, + { + field: 'traceId', + label: '链路追踪', + }, + { + field: 'applicationName', + label: '应用名', + }, + { + field: 'userId', + label: '用户Id', + }, + { + field: 'userType', + label: '用户类型', + content: (data: InfraApiAccessLogApi.ApiAccessLog) => { + return h(DictTag, { + type: DICT_TYPE.USER_TYPE, + value: data.userType, + }); + }, + }, + { + field: 'userIp', + label: '用户 IP', + }, + { + field: 'userAgent', + label: '用户 UA', + }, + { + label: '请求信息', + content: (data: InfraApiAccessLogApi.ApiAccessLog) => { + if (data?.requestMethod && data?.requestUrl) { + return `${data.requestMethod} ${data.requestUrl}`; + } + return ''; + }, + }, + { + field: 'requestParams', + label: '请求参数', + content: (data: InfraApiAccessLogApi.ApiAccessLog) => { + if (data.requestParams) { + return h(JsonViewer, { + value: JSON.parse(data.requestParams), + previewMode: true, + }); + } + return ''; + }, + }, + { + field: 'responseBody', + label: '请求结果', + }, + { + label: '请求时间', + content: (data: InfraApiAccessLogApi.ApiAccessLog) => { + if (data?.beginTime && data?.endTime) { + return `${formatDateTime(data.beginTime)} ~ ${formatDateTime(data.endTime)}`; + } + return ''; + }, + }, + { + label: '请求耗时', + content: (data: InfraApiAccessLogApi.ApiAccessLog) => { + return data?.duration ? `${data.duration} ms` : ''; + }, + }, + { + label: '操作结果', + content: (data: InfraApiAccessLogApi.ApiAccessLog) => { + if (data?.resultCode === 0) { + return '正常'; + } else if (data && data.resultCode > 0) { + return `失败 | ${data.resultCode} | ${data.resultMsg}`; + } + return ''; + }, + }, + { + field: 'operateModule', + label: '操作模块', + }, + { + field: 'operateName', + label: '操作名', + }, + { + field: 'operateType', + label: '操作类型', + content: (data: InfraApiAccessLogApi.ApiAccessLog) => { + return h(DictTag, { + type: DICT_TYPE.INFRA_OPERATE_TYPE, + value: data?.operateType, + }); + }, + }, + ]; +} diff --git a/apps/web-ele/src/views/infra/apiAccessLog/modules/detail.vue b/apps/web-ele/src/views/infra/apiAccessLog/modules/detail.vue index f6a24aa25..4ea4ad9b3 100644 --- a/apps/web-ele/src/views/infra/apiAccessLog/modules/detail.vue +++ b/apps/web-ele/src/views/infra/apiAccessLog/modules/detail.vue @@ -1,18 +1,28 @@ - diff --git a/apps/web-ele/src/views/infra/apiErrorLog/data.ts b/apps/web-ele/src/views/infra/apiErrorLog/data.ts index 54d4362d6..8201f1206 100644 --- a/apps/web-ele/src/views/infra/apiErrorLog/data.ts +++ b/apps/web-ele/src/views/infra/apiErrorLog/data.ts @@ -1,9 +1,16 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { InfraApiErrorLogApi } from '#/api/infra/api-error-log'; +import type { DescriptionItemSchema } from '#/components/description'; +import { h } from 'vue'; + +import { JsonViewer } from '@vben/common-ui'; import { DICT_TYPE, InfraApiErrorLogProcessStatusEnum } from '@vben/constants'; import { getDictOptions } from '@vben/hooks'; +import { formatDateTime } from '@vben/utils'; +import { DictTag } from '#/components/dict-tag'; import { getRangePickerDefaultProps } from '#/utils'; /** 列表的搜索表单 */ @@ -122,9 +129,123 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { }, { title: '操作', - minWidth: 200, + minWidth: 220, fixed: 'right', slots: { default: 'actions' }, }, ]; } + +/** 详情页的字段 */ +export function useDetailSchema(): DescriptionItemSchema[] { + return [ + { + field: 'id', + label: '日志编号', + }, + { + field: 'traceId', + label: '链路追踪', + }, + { + field: 'applicationName', + label: '应用名', + }, + { + field: 'userId', + label: '用户Id', + }, + { + field: 'userType', + label: '用户类型', + content: (data: InfraApiErrorLogApi.ApiErrorLog) => { + return h(DictTag, { + type: DICT_TYPE.USER_TYPE, + value: data.userType, + }); + }, + }, + { + field: 'userIp', + label: '用户 IP', + }, + { + field: 'userAgent', + label: '用户 UA', + }, + { + field: 'requestMethod', + label: '请求信息', + content: (data: InfraApiErrorLogApi.ApiErrorLog) => { + if (data?.requestMethod && data?.requestUrl) { + return `${data.requestMethod} ${data.requestUrl}`; + } + return ''; + }, + }, + { + field: 'requestParams', + label: '请求参数', + content: (data: InfraApiErrorLogApi.ApiErrorLog) => { + if (data.requestParams) { + return h(JsonViewer, { + value: JSON.parse(data.requestParams), + previewMode: true, + }); + } + return ''; + }, + }, + { + field: 'exceptionTime', + label: '异常时间', + content: (data: InfraApiErrorLogApi.ApiErrorLog) => { + return formatDateTime(data?.exceptionTime || '') as string; + }, + }, + { + field: 'exceptionName', + label: '异常名', + }, + { + field: 'exceptionStackTrace', + label: '异常堆栈', + hidden: (data: InfraApiErrorLogApi.ApiErrorLog) => + !data?.exceptionStackTrace, + content: (data: InfraApiErrorLogApi.ApiErrorLog) => { + if (data?.exceptionStackTrace) { + return h('textarea', { + value: data.exceptionStackTrace, + style: + 'width: 100%; min-height: 200px; max-height: 400px; resize: vertical;', + readonly: true, + }); + } + return ''; + }, + }, + { + field: 'processStatus', + label: '处理状态', + content: (data: InfraApiErrorLogApi.ApiErrorLog) => { + return h(DictTag, { + type: DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS, + value: data?.processStatus, + }); + }, + }, + { + field: 'processUserId', + label: '处理人', + hidden: (data: InfraApiErrorLogApi.ApiErrorLog) => !data?.processUserId, + }, + { + field: 'processTime', + label: '处理时间', + hidden: (data: InfraApiErrorLogApi.ApiErrorLog) => !data?.processTime, + content: (data: InfraApiErrorLogApi.ApiErrorLog) => { + return formatDateTime(data?.processTime || '') as string; + }, + }, + ]; +} diff --git a/apps/web-ele/src/views/infra/apiErrorLog/modules/detail.vue b/apps/web-ele/src/views/infra/apiErrorLog/modules/detail.vue index ed7e317c6..a6472579c 100644 --- a/apps/web-ele/src/views/infra/apiErrorLog/modules/detail.vue +++ b/apps/web-ele/src/views/infra/apiErrorLog/modules/detail.vue @@ -1,18 +1,28 @@ -