diff --git a/src/api/common/types.ts b/src/api/common/types.ts index ca968ea3..a973cc89 100644 --- a/src/api/common/types.ts +++ b/src/api/common/types.ts @@ -14,5 +14,6 @@ export type SystemEnumKeys = | 'eRoleAlias' | 'eAuthType' | 'eSubscribeMessageType' + | 'eDeviceLogBizType' export type SystemEnum = Record diff --git a/src/api/monitor-ops/log/index.ts b/src/api/monitor-ops/log/index.ts new file mode 100644 index 00000000..3feadc3b --- /dev/null +++ b/src/api/monitor-ops/log/index.ts @@ -0,0 +1,18 @@ +import type { GetLogListParams, Log, MessageContent } from './types' +import { defHttp } from '@/utils/http/axios' + +export function getLogList(params: GetLogListParams) { + return defHttp.get>({ + url: '/device/log/page', + params, + }) +} + +export function getMessageContent(id: string) { + return defHttp.get({ + url: '/device/log/message', + params: { + id, + }, + }) +} diff --git a/src/api/monitor-ops/log/types.ts b/src/api/monitor-ops/log/types.ts new file mode 100644 index 00000000..cbf18dda --- /dev/null +++ b/src/api/monitor-ops/log/types.ts @@ -0,0 +1,25 @@ +export interface GetLogListParams extends PageParam { + productId: string + deviceSn: string + traceId: string + bizType: string + queryStartTime: string + queryEndTime: string +} + +export interface Log { + productId: string + deviceSn: string + traceId: string + messageId?: string + bizType: number + operation: string + createTime: string + code: number +} + +export interface MessageContent { + message: string + topic: string + createTime: string +} diff --git a/src/views/monitor-ops/log/MessageContentModal.vue b/src/views/monitor-ops/log/MessageContentModal.vue new file mode 100644 index 00000000..ffb1e466 --- /dev/null +++ b/src/views/monitor-ops/log/MessageContentModal.vue @@ -0,0 +1,62 @@ + + + diff --git a/src/views/monitor-ops/log/data.ts b/src/views/monitor-ops/log/data.ts new file mode 100644 index 00000000..a490f783 --- /dev/null +++ b/src/views/monitor-ops/log/data.ts @@ -0,0 +1,131 @@ +import { h } from 'vue' +import { Tag } from 'ant-design-vue' +import dayjs from 'dayjs' +import type { BasicColumn, FormSchema } from '@/components/Table' +import { getAllProducts } from '@/api/product' +import type { Product } from '@/api/product/types' +import { useSystemEnumStoreWithOut } from '@/store/modules/systemEnum' + +let productsCache: Pick[] = [] +async function getCachedProducts() { + if (productsCache.length) + return productsCache + + try { + return productsCache = await getAllProducts() + } + catch { + return [] + } +} + +const { getSystemEnumLabel, getSystemEnums } = useSystemEnumStoreWithOut() + +export const columns: BasicColumn[] = [ + { + title: '所属产品', + dataIndex: 'productId', + customRender({ value }) { + return productsCache.find(item => item.id === value)?.productName + }, + }, + { + title: '设备序列号', + dataIndex: 'deviceSn', + }, + { + title: 'TraceID', + dataIndex: 'traceId', + }, + { + title: '消息内容', + dataIndex: 'messageId', + width: 120, + }, + { + title: '业务类型', + dataIndex: 'bizType', + width: 150, + customRender({ value }) { + return h(Tag, () => getSystemEnumLabel('eDeviceLogBizType', value)) + }, + }, + { + title: '操作', + dataIndex: 'operation', + }, + { + title: '时间', + dataIndex: 'createTime', + }, + { + title: '状态', + dataIndex: 'code', + width: 120, + customRender({ value }) { + return h('b', { + style: { + color: value === 200 ? '#16a34a' : '#dc2626', + }, + }, value) + }, + }, +] + +export const searchFormSchema: FormSchema[] = [ + { + field: 'productId', + label: '所属产品', + component: 'ApiSelect', + componentProps: { + api: getCachedProducts, + valueField: 'id', + labelField: 'productName', + showSearch: true, + }, + colProps: { + span: 6, + }, + }, + { + field: 'deviceSn', + label: '设备序列号', + component: 'Input', + colProps: { + span: 6, + }, + }, + { + field: 'traceId', + label: 'TraceId', + component: 'Input', + colProps: { + span: 6, + }, + }, + { + field: 'bizType', + label: '业务类型', + component: 'Select', + componentProps: { + options: getSystemEnums('eDeviceLogBizType'), + }, + colProps: { + span: 6, + }, + }, + { + field: 'time', + label: '日志时间', + component: 'RangePicker', + componentProps: { + showTime: true, + disabledDate(current) { + return current && current > dayjs().endOf('day') + }, + }, + colProps: { + span: 6, + }, + }, +] diff --git a/src/views/monitor-ops/log/index.vue b/src/views/monitor-ops/log/index.vue new file mode 100644 index 00000000..4577b513 --- /dev/null +++ b/src/views/monitor-ops/log/index.vue @@ -0,0 +1,45 @@ + + +