fix
This commit is contained in:
@@ -13,8 +13,8 @@ import { toRefs, computed, ref } from 'vue';
|
||||
|
||||
interface Props {
|
||||
station: Station;
|
||||
stationDevices: StationDevices;
|
||||
stationAlarms: StationAlarms;
|
||||
stationDevices?: StationDevices;
|
||||
stationAlarms?: StationAlarms;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
@@ -26,7 +26,7 @@ const { code, name, online } = toRefs(station.value);
|
||||
const offlineDeviceCount = computed(() => {
|
||||
let count = 0;
|
||||
Object.values(DeviceType).forEach((deviceType) => {
|
||||
const offlineDeviceList = stationDevices.value[deviceType].filter((device) => device.deviceStatus === '20');
|
||||
const offlineDeviceList = stationDevices.value?.[deviceType].filter((device) => device.deviceStatus === '20') ?? [];
|
||||
count += offlineDeviceList.length;
|
||||
});
|
||||
return count;
|
||||
@@ -34,14 +34,14 @@ const offlineDeviceCount = computed(() => {
|
||||
const deviceCount = computed(() => {
|
||||
let count = 0;
|
||||
Object.values(DeviceType).forEach((deviceType) => {
|
||||
count += stationDevices.value[deviceType].length;
|
||||
count += stationDevices.value?.[deviceType].length ?? 0;
|
||||
});
|
||||
return count;
|
||||
});
|
||||
const devicAlarmCount = computed(() => {
|
||||
let count = 0;
|
||||
Object.values(DeviceType).forEach((deviceType) => {
|
||||
count += stationAlarms.value[deviceType].length;
|
||||
count += stationAlarms.value?.[deviceType].length ?? 0;
|
||||
});
|
||||
return count;
|
||||
});
|
||||
|
||||
@@ -46,10 +46,10 @@ export function useStationListQuery() {
|
||||
}
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
queryClient.invalidateQueries({ queryKey: ['station-devices'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['station-alarms'] });
|
||||
// queryClient.invalidateQueries({ queryKey: ['line-devices'] });
|
||||
// queryClient.invalidateQueries({ queryKey: ['line-alarms'] });
|
||||
// queryClient.invalidateQueries({ queryKey: ['station-devices'] });
|
||||
// queryClient.invalidateQueries({ queryKey: ['station-alarms'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['line-devices'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['line-alarms'] });
|
||||
|
||||
return stations;
|
||||
},
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useStationStore } from '@/stores/station';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useLineDevicesStore } from '@/stores/line-devices';
|
||||
import { useLineAlarmsStore } from '@/stores/line-alarms';
|
||||
import { useLineAlarmsQuery, useLineDevicesQuery } from '@/composables/query';
|
||||
|
||||
const stationStore = useStationStore();
|
||||
const { stationList } = storeToRefs(stationStore);
|
||||
@@ -12,6 +13,9 @@ const lineDevicesStore = useLineDevicesStore();
|
||||
const { lineDevices } = storeToRefs(lineDevicesStore);
|
||||
const lineAlarmsStore = useLineAlarmsStore();
|
||||
const { lineAlarms } = storeToRefs(lineAlarmsStore);
|
||||
|
||||
useLineDevicesQuery();
|
||||
useLineAlarmsQuery();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -39,10 +39,6 @@ const router = createRouter({
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'debug',
|
||||
component: () => import('@/pages/debug-page.vue'),
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'NotFound',
|
||||
|
||||
Reference in New Issue
Block a user