From 703f1730b8533f9da40853d79ae1cc8db8751d45 Mon Sep 17 00:00:00 2001 From: root <13910913995@163.com> Date: Fri, 26 Jun 2026 18:06:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E4=BA=86=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E6=8A=A5=E5=91=8A=E7=9A=84=E6=9F=A5=E8=AF=A2=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/platform.ts | 7 +- frontend/src/types/platform.ts | 19 +++- frontend/src/utils/alarmEvent.ts | 73 ++++++++++++++ frontend/src/views/aiQuantity/index.vue | 27 +++--- frontend/src/views/analogQuantity/index.vue | 24 ++--- frontend/src/views/eventReport/index.vue | 102 +++++++++++--------- frontend/src/views/switchQuantity/index.vue | 25 +++-- frontend/src/websocket/client.ts | 12 +++ 8 files changed, 190 insertions(+), 99 deletions(-) create mode 100644 frontend/src/utils/alarmEvent.ts diff --git a/frontend/src/api/platform.ts b/frontend/src/api/platform.ts index 0ac11de..dad17f4 100644 --- a/frontend/src/api/platform.ts +++ b/frontend/src/api/platform.ts @@ -2,6 +2,7 @@ import { http } from './http' import type { AiAlarmSettingItem, AlarmEvent, + AlarmHistoryQuery, ApiResponse, ChannelConfigPayload, DeviceConfigPayload, @@ -53,8 +54,8 @@ export async function fetchSystemConfig(): Promise { return response.data.data } -export async function fetchAlarmHistory(pageOrParams: number | any = 1, size = 20): Promise { - let params: any +export async function fetchAlarmHistory(pageOrParams: number | AlarmHistoryQuery = 1, size = 20): Promise { + let params: AlarmHistoryQuery if (typeof pageOrParams === 'number') { params = { page: pageOrParams, size } } else { @@ -128,4 +129,4 @@ export async function saveSystemConfig(payload: SystemConfigPayload): Promise> { const response = await http.post>('/config/device/password', payload) return response.data -} \ No newline at end of file +} diff --git a/frontend/src/types/platform.ts b/frontend/src/types/platform.ts index a912540..1273f55 100644 --- a/frontend/src/types/platform.ts +++ b/frontend/src/types/platform.ts @@ -49,12 +49,21 @@ export interface DeviceStatus { export interface AlarmEvent { id?: number - alarm_type: string - time: string - no: string - type: string + event_time: string + line_code: number + event_type: number + event_code: number + event_value: number content: string - level: string +} + +export interface AlarmHistoryQuery { + page?: number + size?: number + line_code?: number + event_type?: number + start_time?: string + end_time?: string } export interface ApiResponse { diff --git a/frontend/src/utils/alarmEvent.ts b/frontend/src/utils/alarmEvent.ts new file mode 100644 index 0000000..0cbc9cb --- /dev/null +++ b/frontend/src/utils/alarmEvent.ts @@ -0,0 +1,73 @@ +export function getAlarmBelongText(lineCode: number): string { + if (lineCode === 0) { + return '装置' + } + return `线路${lineCode}` +} + +export function getEventTypeName(eventType: number): string { + switch (eventType) { + case 1: + return '保护类' + case 2: + return '动作类' + case 3: + return '报警类' + case 4: + return '操作类' + case 5: + return 'AI越限类' + default: + return `未知类型(${eventType})` + } +} + +export function getEventCodeName(eventType: number, eventCode: number): string { + if (eventType === 1) { + if (eventCode === 1) { + return 'PT断线' + } + if (eventCode === 2) { + return 'CT断线' + } + return `保护事件${eventCode}` + } + + if (eventType === 2) { + return `第${eventCode}路状态变化` + } + + if (eventType === 3) { + if (eventCode === 1) { + return '过压' + } + if (eventCode === 2) { + return '过流' + } + if (eventCode === 3) { + return '频率越限' + } + return `报警事件${eventCode}` + } + + if (eventType === 4) { + return eventCode > 0 ? `界面操作${eventCode}` : '界面操作' + } + + if (eventType === 5) { + return `AI通道${eventCode}越限` + } + + return `未定义代码(${eventCode})` +} + +export function getEventDisplayName(eventType: number, eventCode: number): string { + return `${getEventTypeName(eventType)} / ${getEventCodeName(eventType, eventCode)}` +} + +export function formatAlarmEventValue(eventType: number, eventValue: number): string { + if (eventType === 2) { + return eventValue === 0 ? '分' : '合' + } + return String(eventValue) +} diff --git a/frontend/src/views/aiQuantity/index.vue b/frontend/src/views/aiQuantity/index.vue index 2b561fa..ceafa41 100644 --- a/frontend/src/views/aiQuantity/index.vue +++ b/frontend/src/views/aiQuantity/index.vue @@ -2,6 +2,7 @@ import { computed, onMounted, ref } from 'vue' import { usePlatformStore } from '../../stores/platform' import {fetchChannelConfig} from '@/api/platform' +import { formatAlarmEventValue, getAlarmBelongText, getEventDisplayName } from '@/utils/alarmEvent' const { state, bootstrap } = usePlatformStore() const channelConfig = ref>({}) @@ -33,24 +34,20 @@ function formatTime(dateStr: string): string { const seconds = String(date.getSeconds()).padStart(2, '0') return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}` } + const tableData = computed(() => { const alarms = state.alarms || [] const firstThree = alarms.slice(0, 1) return firstThree.map(list => { - const reslist: any = {} - if (list.alarm_type == 'line_alarm') { - reslist.name = `线路${list?.no || 1}` - } else if (list.alarm_type == 'ai_alarm') { - reslist.name = `通道${list?.no || 1}` - } else if (list.alarm_type == 'operate_alarm') { - reslist.name = '' + return { + id: list.id || 0, + name: getAlarmBelongText(list.line_code), + typeName: getEventDisplayName(list.event_type, list.event_code), + eventCode: list.event_code, + eventValue: formatAlarmEventValue(list.event_type, list.event_value), + content: list.content, + time: list.event_time ? formatTime(list.event_time) : '', } - reslist.typeName = list.type - reslist.content = list.content - reslist.time = list.time ? formatTime(list.time) : '' - reslist.level = list.level || '' - reslist.id = list.id || '0' - return reslist }) }) function init(){ @@ -108,7 +105,7 @@ onMounted(() => {
{{ index + 1 }}
{{ item.name }}
{{ item.typeName }}
-
{{ item.level }}
+
{{ item.eventValue }}
{{ item.content }}
{{ item.time }}
@@ -216,4 +213,4 @@ onMounted(() => { } } } - \ No newline at end of file + diff --git a/frontend/src/views/analogQuantity/index.vue b/frontend/src/views/analogQuantity/index.vue index fbe0f0f..69533df 100644 --- a/frontend/src/views/analogQuantity/index.vue +++ b/frontend/src/views/analogQuantity/index.vue @@ -2,6 +2,7 @@ import { ref, computed, onMounted } from 'vue' import { usePlatformStore } from '../../stores/platform' import type { ValueGroup } from '../../types/platform' +import { formatAlarmEventValue, getAlarmBelongText, getEventDisplayName } from '@/utils/alarmEvent' const { state, bootstrap } = usePlatformStore() const lineList = ref([ @@ -121,20 +122,15 @@ const tableData = computed(() => { const alarms = state.alarms || [] const firstThree = alarms.slice(0, 1) return firstThree.map(list => { - const reslist: any = {} - if (list.alarm_type == 'line_alarm') { - reslist.name = `线路${list?.no || 1}` - } else if (list.alarm_type == 'ai_alarm') { - reslist.name = `通道${list?.no || 1}` - } else if (list.alarm_type == 'operate_alarm') { - reslist.name = '' + return { + id: list.id || 0, + name: getAlarmBelongText(list.line_code), + typeName: getEventDisplayName(list.event_type, list.event_code), + eventCode: list.event_code, + eventValue: formatAlarmEventValue(list.event_type, list.event_value), + content: list.content, + time: list.event_time ? formatTime(list.event_time) : '', } - reslist.typeName = list.type - reslist.content = list.content - reslist.time = list.time ? formatTime(list.time) : '' - reslist.level = list.level || '' - reslist.id = list.id || '0' - return reslist }) }) @@ -218,7 +214,7 @@ onMounted(() => {
{{ index + 1 }}
{{ item.name }}
{{ item.typeName }}
-
{{ item.level }}
+
{{ item.eventValue }}
{{ item.content }}
{{ item.time }}
diff --git a/frontend/src/views/eventReport/index.vue b/frontend/src/views/eventReport/index.vue index 8c185f8..ebf4081 100644 --- a/frontend/src/views/eventReport/index.vue +++ b/frontend/src/views/eventReport/index.vue @@ -1,35 +1,65 @@