feat: get alarms from all stations
This commit is contained in:
@@ -1,37 +1,27 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import StationCard from '@/components/station-card.vue';
|
||||
import { NGrid, NGi } from 'naive-ui';
|
||||
import { useStationStore } from '@/stores/station';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { DeviceType } from '@/enums/device-type';
|
||||
import { useLineDevicesQuery } from '@/composables/query/use-line-devices-query';
|
||||
import { useLineAlarmsQuery } from '@/composables/query/use-line-alarms-query';
|
||||
|
||||
const stationStore = useStationStore();
|
||||
const { stationList } = storeToRefs(stationStore);
|
||||
|
||||
// 模拟数据
|
||||
const stations = ref(
|
||||
Array.from({ length: 32 }).map((_, i) => ({
|
||||
code: `${i}`,
|
||||
name: `浦东1号2号航站楼${i + 1}`,
|
||||
online: Math.random() > 0.5,
|
||||
offlineDeviceCount: Math.floor(Math.random() * 20),
|
||||
alarmCount: Math.floor(Math.random() * 10),
|
||||
})),
|
||||
);
|
||||
|
||||
// 获取所有在线车站的设备数据
|
||||
// 获取所有车站的设备数据
|
||||
const { data: lineDevices } = useLineDevicesQuery();
|
||||
// 获取所有车站的设备告警数据
|
||||
const { data: lineAlarms } = useLineAlarmsQuery();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NGrid :cols="8" :x-gap="6" :y-gap="6" style="padding: 8px">
|
||||
<NGi v-for="(station, i) in stationList" :key="station.name">
|
||||
<NGi v-for="station in stationList" :key="station.name">
|
||||
<StationCard
|
||||
:station="station"
|
||||
:alarm-count="stations[i].alarmCount"
|
||||
:ndm-device-list="
|
||||
:station-devices="
|
||||
lineDevices?.[station.code] ?? {
|
||||
[DeviceType.Camera]: [],
|
||||
[DeviceType.Decoder]: [],
|
||||
@@ -43,7 +33,19 @@ const { data: lineDevices } = useLineDevicesQuery();
|
||||
[DeviceType.VideoServer]: [],
|
||||
}
|
||||
"
|
||||
:ndm-device-alarm-log-list="[]"
|
||||
:station-alarms="
|
||||
lineAlarms?.[station.code] ?? {
|
||||
[DeviceType.Camera]: { occurred: [], recovered: [] },
|
||||
[DeviceType.Decoder]: { occurred: [], recovered: [] },
|
||||
[DeviceType.Keyboard]: { occurred: [], recovered: [] },
|
||||
[DeviceType.MediaServer]: { occurred: [], recovered: [] },
|
||||
[DeviceType.Nvr]: { occurred: [], recovered: [] },
|
||||
[DeviceType.SecurityBox]: { occurred: [], recovered: [] },
|
||||
[DeviceType.Switch]: { occurred: [], recovered: [] },
|
||||
[DeviceType.VideoServer]: { occurred: [], recovered: [] },
|
||||
unclassified: { occurred: [], recovered: [] },
|
||||
}
|
||||
"
|
||||
/>
|
||||
</NGi>
|
||||
</NGrid>
|
||||
|
||||
Reference in New Issue
Block a user