refactor: tryGetDeviceTypeVal
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { NdmDeviceResultVO } from '@/apis/models';
|
||||
import { DeviceType, getDeviceTypeVal, type DeviceTypeVal } from '@/enums/device-type';
|
||||
import { DeviceType, tryGetDeviceTypeVal, type DeviceTypeVal } from '@/enums/device-type';
|
||||
import { ref, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import type { LineDevices } from '../query';
|
||||
@@ -39,7 +39,10 @@ export function useDeviceSelection() {
|
||||
const selectDevice = (device: NdmDeviceResultVO, stationCode: string) => {
|
||||
selectedDevice.value = device;
|
||||
selectedStationCode.value = stationCode;
|
||||
selectedDeviceType.value = getDeviceTypeVal(device.deviceType);
|
||||
const deviceTypeVal = tryGetDeviceTypeVal(device.deviceType);
|
||||
if (!!deviceTypeVal) {
|
||||
selectedDeviceType.value = deviceTypeVal;
|
||||
}
|
||||
};
|
||||
|
||||
const syncToRoute = () => {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { computed } from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { postNdmDeviceAlarmLogPage } from '@/apis/requests';
|
||||
import type { Station } from '@/apis/domains';
|
||||
import { DeviceType, getDeviceTypeVal } from '@/enums/device-type';
|
||||
import { DeviceType, tryGetDeviceTypeVal } from '@/enums/device-type';
|
||||
import type { StationAlarmCounts } from './domains';
|
||||
import { runTask } from '@/utils/run-task';
|
||||
|
||||
@@ -88,7 +88,10 @@ function useStationAlarmCountsMutation() {
|
||||
signal,
|
||||
);
|
||||
for (const alarm of alarmList) {
|
||||
stationAlarmCounts[getDeviceTypeVal(alarm.deviceType)]++;
|
||||
const deviceTypeVal = tryGetDeviceTypeVal(alarm.deviceType);
|
||||
if (deviceTypeVal) {
|
||||
stationAlarmCounts[deviceTypeVal]++;
|
||||
}
|
||||
}
|
||||
stationAlarmCounts.unclassified = parseInt(total);
|
||||
return stationAlarmCounts;
|
||||
|
||||
Reference in New Issue
Block a user