feat: apply new stores to UI and hope it works

This commit is contained in:
yangsy
2025-08-26 03:28:20 +08:00
parent c2ebe34a05
commit 9a050f08f6
3 changed files with 33 additions and 25 deletions

View File

@@ -4,31 +4,29 @@ import DeviceParamsConfigModal from './device-params-config-modal.vue';
import OfflineDeviceDetailModal from './offline-device-detail-modal.vue';
import type { Station } from '@/apis/domains';
import { DeviceType } from '@/enums/device-type';
import { useStationDevicesQuery } from '@/composables/query';
import { type StationAlarms, type StationDevices } from '@/composables/query';
import { ControlOutlined } from '@vicons/antd';
import { Video as VideoIcon } from '@vicons/carbon';
import axios from 'axios';
import { NCard, NStatistic, NTag, NGrid, NGi, NButton, NIcon, useThemeVars, NSpace, NTooltip } from 'naive-ui';
import { toRefs, computed, ref } from 'vue';
import { useStationAlarmsQuery } from '@/composables/query';
interface Props {
station: Station;
stationDevices: StationDevices;
stationAlarms: StationAlarms;
}
const props = defineProps<Props>();
const { station } = toRefs(props);
const { station, stationDevices, stationAlarms } = toRefs(props);
const { code, name, online } = toRefs(station.value);
const { data: stationDevices } = useStationDevicesQuery(code.value);
const { data: stationAlarms } = useStationAlarmsQuery(station.value.code);
// 计算总离线设备数量
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;
@@ -36,14 +34,14 @@ const offlineDeviceCount = computed(() => {
const deviceCount = computed(() => {
let count = 0;
Object.values(DeviceType).forEach((deviceType) => {
count += stationDevices.value?.[deviceType].length ?? 0;
count += stationDevices.value[deviceType].length;
});
return count;
});
const devicAlarmCount = computed(() => {
let count = 0;
Object.values(DeviceType).forEach((deviceType) => {
count += stationAlarms.value?.[deviceType].length ?? 0;
count += stationAlarms.value[deviceType].length;
});
return count;
});