From d0adb869daa6589932619d419c6d7440e4e7dce4 Mon Sep 17 00:00:00 2001 From: yangsy Date: Tue, 30 Sep 2025 15:09:12 +0800 Subject: [PATCH] refactor: tryGetDeviceTypeVal --- .../dashboard-page/device-alarm-detail-modal.vue | 6 ++++-- .../offline-device-detail-modal.vue | 6 +++--- .../current-diag-card/device-header-card.vue | 11 ++++++++--- .../device-alarm-history-diag-card.vue | 6 ++++-- src/components/device-page/device-renderer.vue | 6 +++--- src/components/device-page/device-tree.vue | 7 ++++--- src/composables/device/use-device-selection.ts | 7 +++++-- .../query/alarm/use-line-alarm-counts-query.ts | 7 +++++-- src/enums/device-type.ts | 15 ++++++++++++--- src/pages/alarm-page.vue | 6 ++++-- src/stores/line-devices.ts | 16 ++++++++++++++++ 11 files changed, 68 insertions(+), 25 deletions(-) diff --git a/src/components/dashboard-page/device-alarm-detail-modal.vue b/src/components/dashboard-page/device-alarm-detail-modal.vue index f9401a4..b8b72d8 100644 --- a/src/components/dashboard-page/device-alarm-detail-modal.vue +++ b/src/components/dashboard-page/device-alarm-detail-modal.vue @@ -5,7 +5,7 @@ import { ndmDeviceAlarmLogDefaultExportByTemplate, postNdmDeviceAlarmLogPage } f import type { StationAlarmCounts } from '@/composables/query'; import { FaultLevel } from '@/enums/fault-level'; import { AlarmType } from '@/enums/alarm-type'; -import { DeviceType, DeviceTypeCode, DeviceTypeName, getDeviceTypeVal, type DeviceTypeVal } from '@/enums/device-type'; +import { DeviceType, DeviceTypeCode, DeviceTypeName, tryGetDeviceTypeVal, type DeviceTypeVal } from '@/enums/device-type'; import { useQueryControlStore } from '@/stores/query-control'; import { downloadByData } from '@/utils/download'; import { useMutation } from '@tanstack/vue-query'; @@ -57,7 +57,9 @@ const tableColumns: DataTableColumns = [ title: '设备类型', key: 'deviceType', render: (rowData) => { - return DeviceTypeName[getDeviceTypeVal(rowData.deviceType)]; + const deviceTypeVal = tryGetDeviceTypeVal(rowData.deviceType); + if (!deviceTypeVal) return '-'; + return DeviceTypeName[deviceTypeVal]; }, filter: true, filterMultiple: true, diff --git a/src/components/dashboard-page/offline-device-detail-modal.vue b/src/components/dashboard-page/offline-device-detail-modal.vue index 78fedfb..409b824 100644 --- a/src/components/dashboard-page/offline-device-detail-modal.vue +++ b/src/components/dashboard-page/offline-device-detail-modal.vue @@ -2,7 +2,7 @@ import type { Station } from '@/apis/domains'; import type { NdmDeviceVO } from '@/apis/models'; import type { StationDevices } from '@/composables/query'; -import { DeviceType, DeviceTypeName, getDeviceTypeVal } from '@/enums/device-type'; +import { DeviceType, DeviceTypeName, tryGetDeviceTypeVal } from '@/enums/device-type'; import { useQueryControlStore } from '@/stores/query-control'; import { NButton, NCol, NInput, NModal, NRow, NStatistic, NTree } from 'naive-ui'; import type { TreeOption, TreeOverrideNodeClickBehavior, TreeProps } from 'naive-ui'; @@ -83,7 +83,7 @@ const treeData = computed(() => { path: '/device', query: { stationCode: station.value?.code, - deviceType: getDeviceTypeVal(dev.deviceType), + deviceType: tryGetDeviceTypeVal(dev.deviceType), deviceDBId: dev.id, from: route.path, }, @@ -117,7 +117,7 @@ const nodeProps: TreeProps['nodeProps'] = ({ option }) => { path: '/device', query: { stationCode: station.value?.code, - deviceType: getDeviceTypeVal(device.deviceType), + deviceType: tryGetDeviceTypeVal(device.deviceType), deviceDBId: device.id, from: route.path, }, diff --git a/src/components/device-page/device-card/current-diag-card/device-header-card.vue b/src/components/device-page/device-card/current-diag-card/device-header-card.vue index aefab1c..4856433 100644 --- a/src/components/device-page/device-card/current-diag-card/device-header-card.vue +++ b/src/components/device-page/device-card/current-diag-card/device-header-card.vue @@ -1,6 +1,6 @@