This commit is contained in:
yangsy
2025-08-26 04:20:44 +08:00
parent 9a050f08f6
commit b17e7b589a
4 changed files with 13 additions and 13 deletions

View File

@@ -13,8 +13,8 @@ import { toRefs, computed, ref } from 'vue';
interface Props { interface Props {
station: Station; station: Station;
stationDevices: StationDevices; stationDevices?: StationDevices;
stationAlarms: StationAlarms; stationAlarms?: StationAlarms;
} }
const props = defineProps<Props>(); const props = defineProps<Props>();
@@ -26,7 +26,7 @@ const { code, name, online } = toRefs(station.value);
const offlineDeviceCount = computed(() => { const offlineDeviceCount = computed(() => {
let count = 0; let count = 0;
Object.values(DeviceType).forEach((deviceType) => { 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; count += offlineDeviceList.length;
}); });
return count; return count;
@@ -34,14 +34,14 @@ const offlineDeviceCount = computed(() => {
const deviceCount = computed(() => { const deviceCount = computed(() => {
let count = 0; let count = 0;
Object.values(DeviceType).forEach((deviceType) => { Object.values(DeviceType).forEach((deviceType) => {
count += stationDevices.value[deviceType].length; count += stationDevices.value?.[deviceType].length ?? 0;
}); });
return count; return count;
}); });
const devicAlarmCount = computed(() => { const devicAlarmCount = computed(() => {
let count = 0; let count = 0;
Object.values(DeviceType).forEach((deviceType) => { Object.values(DeviceType).forEach((deviceType) => {
count += stationAlarms.value[deviceType].length; count += stationAlarms.value?.[deviceType].length ?? 0;
}); });
return count; return count;
}); });

View File

@@ -46,10 +46,10 @@ export function useStationListQuery() {
} }
const queryClient = useQueryClient(); const queryClient = useQueryClient();
queryClient.invalidateQueries({ queryKey: ['station-devices'] }); // queryClient.invalidateQueries({ queryKey: ['station-devices'] });
queryClient.invalidateQueries({ queryKey: ['station-alarms'] }); // queryClient.invalidateQueries({ queryKey: ['station-alarms'] });
// queryClient.invalidateQueries({ queryKey: ['line-devices'] }); queryClient.invalidateQueries({ queryKey: ['line-devices'] });
// queryClient.invalidateQueries({ queryKey: ['line-alarms'] }); queryClient.invalidateQueries({ queryKey: ['line-alarms'] });
return stations; return stations;
}, },

View File

@@ -5,6 +5,7 @@ import { useStationStore } from '@/stores/station';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { useLineDevicesStore } from '@/stores/line-devices'; import { useLineDevicesStore } from '@/stores/line-devices';
import { useLineAlarmsStore } from '@/stores/line-alarms'; import { useLineAlarmsStore } from '@/stores/line-alarms';
import { useLineAlarmsQuery, useLineDevicesQuery } from '@/composables/query';
const stationStore = useStationStore(); const stationStore = useStationStore();
const { stationList } = storeToRefs(stationStore); const { stationList } = storeToRefs(stationStore);
@@ -12,6 +13,9 @@ const lineDevicesStore = useLineDevicesStore();
const { lineDevices } = storeToRefs(lineDevicesStore); const { lineDevices } = storeToRefs(lineDevicesStore);
const lineAlarmsStore = useLineAlarmsStore(); const lineAlarmsStore = useLineAlarmsStore();
const { lineAlarms } = storeToRefs(lineAlarmsStore); const { lineAlarms } = storeToRefs(lineAlarmsStore);
useLineDevicesQuery();
useLineAlarmsQuery();
</script> </script>
<template> <template>

View File

@@ -39,10 +39,6 @@ const router = createRouter({
}, },
], ],
}, },
{
path: 'debug',
component: () => import('@/pages/debug-page.vue'),
},
{ {
path: '/:pathMatch(.*)*', path: '/:pathMatch(.*)*',
name: 'NotFound', name: 'NotFound',