refactor(query): remove unnecessary query calls and optimize global loading
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
export * from './domains';
|
export * from './domains';
|
||||||
|
|
||||||
export * from './use-line-alarm-counts-query';
|
export * from './use-line-alarms-query';
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import { LINE_ALARM_COUNTS_QUERY_KEY } from '@/constants';
|
import type { StationAlarmCounts } from './domains';
|
||||||
import { useLineAlarmCountsStore } from '@/stores/line-alarm-counts';
|
import type { Station } from '@/apis/domains';
|
||||||
|
import { postNdmDeviceAlarmLogPage } from '@/apis/requests';
|
||||||
|
import { LINE_ALARMS_QUERY_KEY } from '@/constants';
|
||||||
|
import { DeviceType, tryGetDeviceTypeVal } from '@/enums/device-type';
|
||||||
|
import { useLineAlarmsStore } from '@/stores/line-alarms';
|
||||||
import { useQueryControlStore } from '@/stores/query-control';
|
import { useQueryControlStore } from '@/stores/query-control';
|
||||||
import { useStationStore } from '@/stores/station';
|
import { useStationStore } from '@/stores/station';
|
||||||
import { isCancelledError, useMutation, useQuery } from '@tanstack/vue-query';
|
import { isCancelledError, useMutation, useQuery } from '@tanstack/vue-query';
|
||||||
|
import { runTask } from '@/utils/run-task';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { postNdmDeviceAlarmLogPage } from '@/apis/requests';
|
|
||||||
import type { Station } from '@/apis/domains';
|
|
||||||
import { DeviceType, tryGetDeviceTypeVal } from '@/enums/device-type';
|
|
||||||
import type { StationAlarmCounts } from './domains';
|
|
||||||
import { runTask } from '@/utils/run-task';
|
|
||||||
|
|
||||||
const createEmptyStationAlarmCounts = () => {
|
const createEmptyStationAlarmCounts = () => {
|
||||||
return {
|
return {
|
||||||
@@ -26,7 +26,7 @@ const createEmptyStationAlarmCounts = () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export function useLineAlarmCountsQuery() {
|
export function useLineAlarmsQuery() {
|
||||||
const stationStore = useStationStore();
|
const stationStore = useStationStore();
|
||||||
const { stationList } = storeToRefs(stationStore);
|
const { stationList } = storeToRefs(stationStore);
|
||||||
const queryControlStore = useQueryControlStore();
|
const queryControlStore = useQueryControlStore();
|
||||||
@@ -34,7 +34,7 @@ export function useLineAlarmCountsQuery() {
|
|||||||
const { mutateAsync: getStationAlarmCounts } = useStationAlarmCountsMutation();
|
const { mutateAsync: getStationAlarmCounts } = useStationAlarmCountsMutation();
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: [LINE_ALARM_COUNTS_QUERY_KEY, alarmQueryStamp],
|
queryKey: [LINE_ALARMS_QUERY_KEY, alarmQueryStamp],
|
||||||
enabled: computed(() => alarmQueryStamp.value > 0),
|
enabled: computed(() => alarmQueryStamp.value > 0),
|
||||||
staleTime: Infinity,
|
staleTime: Infinity,
|
||||||
refetchOnMount: false,
|
refetchOnMount: false,
|
||||||
@@ -58,8 +58,8 @@ interface StationAlarmCountsMutationParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function useStationAlarmCountsMutation() {
|
function useStationAlarmCountsMutation() {
|
||||||
const lineAlarmCountsStore = useLineAlarmCountsStore();
|
const lineAlarmsStore = useLineAlarmsStore();
|
||||||
const { lineAlarmCounts } = storeToRefs(lineAlarmCountsStore);
|
const { lineAlarmCounts } = storeToRefs(lineAlarmsStore);
|
||||||
|
|
||||||
return useMutation<StationAlarmCounts, Error, StationAlarmCountsMutationParams>({
|
return useMutation<StationAlarmCounts, Error, StationAlarmCountsMutationParams>({
|
||||||
mutationFn: async ({ station, signal }) => {
|
mutationFn: async ({ station, signal }) => {
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
|
import type { StationDevices } from './domains';
|
||||||
|
import { ndmClient } from '@/apis/client';
|
||||||
|
import type { Station } from '@/apis/domains';
|
||||||
|
import { LINE_DEVICES_QUERY_KEY } from '@/constants';
|
||||||
import { DeviceType } from '@/enums/device-type';
|
import { DeviceType } from '@/enums/device-type';
|
||||||
|
import { useLineDevicesStore } from '@/stores/line-devices';
|
||||||
import { useQueryControlStore } from '@/stores/query-control';
|
import { useQueryControlStore } from '@/stores/query-control';
|
||||||
import { useStationStore } from '@/stores/station';
|
import { useStationStore } from '@/stores/station';
|
||||||
import { isCancelledError, useMutation, useQuery } from '@tanstack/vue-query';
|
import { isCancelledError, useMutation, useQuery } from '@tanstack/vue-query';
|
||||||
|
import { runTask } from '@/utils/run-task';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import type { StationDevices } from './domains';
|
|
||||||
import { useLineDevicesStore } from '@/stores/line-devices';
|
|
||||||
import { LINE_DEVICES_QUERY_KEY } from '@/constants';
|
|
||||||
import { ndmClient } from '@/apis/client';
|
|
||||||
import type { Station } from '@/apis/domains';
|
|
||||||
import { runTask } from '@/utils/run-task';
|
|
||||||
|
|
||||||
const createEmptyStationDevices = (): StationDevices => {
|
const createEmptyStationDevices = (): StationDevices => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export const STATION_LIST_QUERY_KEY = 'station-list';
|
export const STATION_LIST_QUERY_KEY = 'station-list';
|
||||||
export const LINE_DEVICES_QUERY_KEY = 'line-devices';
|
export const LINE_DEVICES_QUERY_KEY = 'line-devices';
|
||||||
export const LINE_ALARM_COUNTS_QUERY_KEY = 'line-alarm-counts';
|
export const LINE_ALARMS_QUERY_KEY = 'line-alarms';
|
||||||
export const DEVICE_SNMP_LOGS_QUERY_KEY = 'device-snmp-logs';
|
export const DEVICE_SNMP_LOGS_QUERY_KEY = 'device-snmp-logs';
|
||||||
|
|||||||
@@ -10,16 +10,18 @@ function renderIcon(icon: Component): () => VNode {
|
|||||||
import type { NdmDeviceAlarmLogResultVO } from '@/apis/models';
|
import type { NdmDeviceAlarmLogResultVO } from '@/apis/models';
|
||||||
import SettingsDrawer from '@/components/global/settings-drawer.vue';
|
import SettingsDrawer from '@/components/global/settings-drawer.vue';
|
||||||
import { useStationListQuery } from '@/composables/query';
|
import { useStationListQuery } from '@/composables/query';
|
||||||
|
import { STATION_LIST_QUERY_KEY, LINE_DEVICES_QUERY_KEY, LINE_ALARMS_QUERY_KEY } from '@/constants';
|
||||||
import { useCurrentAlarmsStore } from '@/stores/current-alarms';
|
import { useCurrentAlarmsStore } from '@/stores/current-alarms';
|
||||||
import { useUserStore } from '@/stores/user';
|
import { useUserStore } from '@/stores/user';
|
||||||
import { Client as StompClient } from '@stomp/stompjs';
|
import { Client as StompClient } from '@stomp/stompjs';
|
||||||
|
import { useIsFetching } from '@tanstack/vue-query';
|
||||||
import { AlertFilled, /* AreaChartOutlined, */ FileTextFilled, HomeFilled, LogoutOutlined, SettingOutlined, VideoCameraFilled } from '@vicons/antd';
|
import { AlertFilled, /* AreaChartOutlined, */ FileTextFilled, HomeFilled, LogoutOutlined, SettingOutlined, VideoCameraFilled } from '@vicons/antd';
|
||||||
import { ChevronDown, Debug } from '@vicons/carbon';
|
import { ChevronDown, Debug } from '@vicons/carbon';
|
||||||
import type { AxiosError } from 'axios';
|
import type { AxiosError } from 'axios';
|
||||||
import { destr } from 'destr';
|
import { destr } from 'destr';
|
||||||
import { NBadge, NButton, NDropdown, NFlex, NIcon, NLayout, NLayoutContent, NLayoutFooter, NLayoutHeader, NLayoutSider, NMenu, NScrollbar, type DropdownOption, type MenuOption } from 'naive-ui';
|
import { NBadge, NButton, NDropdown, NFlex, NIcon, NLayout, NLayoutContent, NLayoutFooter, NLayoutHeader, NLayoutSider, NMenu, NScrollbar, type DropdownOption, type MenuOption } from 'naive-ui';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { h, onBeforeMount, onBeforeUnmount, onMounted, ref, watch, type Component, type VNode } from 'vue';
|
import { computed, h, onBeforeMount, onBeforeUnmount, onMounted, ref, watch, type Component, type VNode } from 'vue';
|
||||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
@@ -38,6 +40,13 @@ watch(stationListQueryError, (newStationListQueryError) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const stationListFetchingCount = useIsFetching({ queryKey: [STATION_LIST_QUERY_KEY] });
|
||||||
|
const lineDevicesFetchingCount = useIsFetching({ queryKey: [LINE_DEVICES_QUERY_KEY] });
|
||||||
|
const lineAlarmsFetchingCount = useIsFetching({ queryKey: [LINE_ALARMS_QUERY_KEY] });
|
||||||
|
const fetchingCount = computed(() => {
|
||||||
|
return stationListFetchingCount.value + lineDevicesFetchingCount.value + lineAlarmsFetchingCount.value;
|
||||||
|
});
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
userStore.userGetInfo().catch((err) => window.$message.error((err as AxiosError).message));
|
userStore.userGetInfo().catch((err) => window.$message.error((err as AxiosError).message));
|
||||||
});
|
});
|
||||||
@@ -104,7 +113,7 @@ const menuOptions = ref<MenuOption[]>([
|
|||||||
icon: renderIcon(AlertFilled),
|
icon: renderIcon(AlertFilled),
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// label: () => h(RouterLink, { to: '/statistics' }, { default: () => '设备性能统计' }),
|
// label: () => h(RouterLink, { to: '/statistics' }, { default: () => '设备数据统计' }),
|
||||||
// key: '/statistics',
|
// key: '/statistics',
|
||||||
// icon: renderIcon(AreaChartOutlined),
|
// icon: renderIcon(AreaChartOutlined),
|
||||||
// },
|
// },
|
||||||
@@ -133,13 +142,12 @@ const dropdownOptions = ref<DropdownOption[]>([
|
|||||||
key: 'logout',
|
key: 'logout',
|
||||||
icon: renderIcon(LogoutOutlined),
|
icon: renderIcon(LogoutOutlined),
|
||||||
onClick: async () => {
|
onClick: async () => {
|
||||||
await userStore
|
try {
|
||||||
.userLogout()
|
await userStore.userLogout();
|
||||||
.then(() => {
|
router.push('/login');
|
||||||
window.$loadingBar.finish();
|
} catch (_) {
|
||||||
router.push('/login');
|
window.$message.error('退出登录失败');
|
||||||
})
|
}
|
||||||
.catch(() => window.$message.error('退出登录失败'));
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -175,7 +183,10 @@ const openSettingsDrawer = () => {
|
|||||||
<NLayout :native-scrollbar="false">
|
<NLayout :native-scrollbar="false">
|
||||||
<NLayoutHeader bordered class="app-layout-header">
|
<NLayoutHeader bordered class="app-layout-header">
|
||||||
<NFlex justify="space-between" align="center" :size="8" style="width: 100%; height: 100%">
|
<NFlex justify="space-between" align="center" :size="8" style="width: 100%; height: 100%">
|
||||||
<span style="font-size: 16px; font-weight: 500; margin-left: 16px; cursor: pointer" @click="toDashboardPage">网络设备管理平台</span>
|
<NFlex>
|
||||||
|
<div style="font-size: 16px; font-weight: 500; margin-left: 16px; cursor: pointer" @click="toDashboardPage">网络设备管理平台</div>
|
||||||
|
<NButton text size="tiny" :loading="fetchingCount > 0" />
|
||||||
|
</NFlex>
|
||||||
<NFlex align="center" :size="0" style="height: 100%">
|
<NFlex align="center" :size="0" style="height: 100%">
|
||||||
<!-- <ThemeSwitch /> -->
|
<!-- <ThemeSwitch /> -->
|
||||||
<NDropdown trigger="hover" show-arrow :options="dropdownOptions" @select="selectDropdownOption">
|
<NDropdown trigger="hover" show-arrow :options="dropdownOptions" @select="selectDropdownOption">
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
import type { NdmDeviceAlarmLogResultVO } from '@/apis/models';
|
import type { NdmDeviceAlarmLogResultVO } from '@/apis/models';
|
||||||
import { ndmDeviceAlarmLogDefaultExportByTemplate, postNdmDeviceAlarmLogPage, putNdmDeviceAlarmLog } from '@/apis/requests';
|
import { ndmDeviceAlarmLogDefaultExportByTemplate, postNdmDeviceAlarmLogPage, putNdmDeviceAlarmLog } from '@/apis/requests';
|
||||||
import { renderAlarmDateCell, renderAlarmTypeCell, renderDeviceTypeCell, renderFaultLevelCell } from '@/components/helper';
|
import { renderAlarmDateCell, renderAlarmTypeCell, renderDeviceTypeCell, renderFaultLevelCell } from '@/components/helper';
|
||||||
import { FaultLevel } from '@/enums/fault-level';
|
|
||||||
import { AlarmType } from '@/enums/alarm-type';
|
import { AlarmType } from '@/enums/alarm-type';
|
||||||
import { DeviceType, DeviceTypeCode, DeviceTypeName, type DeviceTypeVal } from '@/enums/device-type';
|
import { DeviceType, DeviceTypeCode, DeviceTypeName, type DeviceTypeVal } from '@/enums/device-type';
|
||||||
|
import { FaultLevel } from '@/enums/fault-level';
|
||||||
import { useCurrentAlarmsStore } from '@/stores/current-alarms';
|
import { useCurrentAlarmsStore } from '@/stores/current-alarms';
|
||||||
import { useStationStore } from '@/stores/station';
|
import { useStationStore } from '@/stores/station';
|
||||||
import { downloadByData } from '@/utils/download';
|
import { downloadByData } from '@/utils/download';
|
||||||
|
|||||||
@@ -1,56 +1,42 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Station } from '@/apis/domains';
|
import type { Station } from '@/apis/domains';
|
||||||
import DeviceAlarmDetailModal from '@/components/dashboard-page/device-alarm-detail-modal.vue';
|
import { ndmExportDevices } from '@/apis/requests';
|
||||||
import DeviceParamsConfigModal from '@/components/dashboard-page/device-params-config-modal.vue';
|
import { useLineAlarmsQuery, useLineDevicesQuery } from '@/composables/query';
|
||||||
import OfflineDeviceDetailModal from '@/components/dashboard-page/offline-device-detail-modal.vue';
|
import { useLayoutStore } from '@/stores/layout';
|
||||||
import StationCard from '@/components/dashboard-page/station-card.vue';
|
import { useLineAlarmsStore } from '@/stores/line-alarms';
|
||||||
import { useLineAlarmCountsQuery, useLineDevicesQuery } from '@/composables/query';
|
|
||||||
import { useStationStore } from '@/stores/station';
|
|
||||||
import { useLineDevicesStore } from '@/stores/line-devices';
|
import { useLineDevicesStore } from '@/stores/line-devices';
|
||||||
|
import { useStationStore } from '@/stores/station';
|
||||||
|
import { downloadByData } from '@/utils/download';
|
||||||
|
import { useMutation } from '@tanstack/vue-query';
|
||||||
import { NGrid, NGi } from 'naive-ui';
|
import { NGrid, NGi } from 'naive-ui';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
import { useLineAlarmCountsStore } from '@/stores/line-alarm-counts';
|
|
||||||
import { useLayoutStore } from '@/stores/layout';
|
|
||||||
import DeviceStatistic from '@/components/dashboard-page/device-statistic.vue';
|
|
||||||
import { useMutation } from '@tanstack/vue-query';
|
|
||||||
import { ndmExportDevices } from '@/apis/requests';
|
|
||||||
import { downloadByData } from '@/utils/download';
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
import DeviceAlarmDetailModal from '@/components/dashboard-page/device-alarm-detail-modal.vue';
|
||||||
|
import DeviceParamsConfigModal from '@/components/dashboard-page/device-params-config-modal.vue';
|
||||||
|
import DeviceStatisticCard from '@/components/dashboard-page/device-statistic-card.vue';
|
||||||
|
import OfflineDeviceDetailModal from '@/components/dashboard-page/offline-device-detail-modal.vue';
|
||||||
|
import StationCard from '@/components/dashboard-page/station-card.vue';
|
||||||
|
|
||||||
const stationStore = useStationStore();
|
const stationStore = useStationStore();
|
||||||
const { stationList } = storeToRefs(stationStore);
|
const { stationList } = storeToRefs(stationStore);
|
||||||
const lineDevicesStore = useLineDevicesStore();
|
const lineDevicesStore = useLineDevicesStore();
|
||||||
const { lineDevices } = storeToRefs(lineDevicesStore);
|
const { lineDevices } = storeToRefs(lineDevicesStore);
|
||||||
const lineAlarmCountsStore = useLineAlarmCountsStore();
|
const lineAlarmsStore = useLineAlarmsStore();
|
||||||
const { lineAlarmCounts } = storeToRefs(lineAlarmCountsStore);
|
const { lineAlarmCounts } = storeToRefs(lineAlarmsStore);
|
||||||
|
|
||||||
const { isFetching: lineDevicesFetching, error: lineDevicesQueryError } = useLineDevicesQuery();
|
const { error: lineDevicesQueryError } = useLineDevicesQuery();
|
||||||
const { isFetching: lineAlarmCountsFetching, error: lineAlarmCountsQueryError } = useLineAlarmCountsQuery();
|
const { error: lineAlarmsQueryError } = useLineAlarmsQuery();
|
||||||
const layoutStore = useLayoutStore();
|
const layoutStore = useLayoutStore();
|
||||||
const { stationLayoutGridCols } = storeToRefs(layoutStore);
|
const { stationLayoutGridCols } = storeToRefs(layoutStore);
|
||||||
|
|
||||||
// 当设备查询或告警查询正在进行时,显示加载条
|
watch([lineDevicesQueryError, lineAlarmsQueryError], ([newLineDevicesQueryError, newLineAlarmsQueryError]) => {
|
||||||
watch(
|
|
||||||
[lineDevicesFetching, lineAlarmCountsFetching],
|
|
||||||
([devicesFetching, alarmCountsFetching]) => {
|
|
||||||
if (devicesFetching || alarmCountsFetching) {
|
|
||||||
window.$loadingBar.start();
|
|
||||||
} else {
|
|
||||||
window.$loadingBar.finish();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
immediate: true,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
watch([lineDevicesQueryError, lineAlarmCountsQueryError], ([newLineDevicesQueryError, newLineAlarmCountsQueryError]) => {
|
|
||||||
if (newLineDevicesQueryError) {
|
if (newLineDevicesQueryError) {
|
||||||
window.$message.error(newLineDevicesQueryError.message);
|
window.$message.error(newLineDevicesQueryError.message);
|
||||||
}
|
}
|
||||||
if (newLineAlarmCountsQueryError) {
|
if (newLineAlarmsQueryError) {
|
||||||
window.$message.error(newLineAlarmCountsQueryError.message);
|
window.$message.error(newLineAlarmsQueryError.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -95,7 +81,7 @@ const openDeviceParamsConfigModal = (station: Station) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<DeviceStatistic
|
<DeviceStatisticCard
|
||||||
:station-list="stationList"
|
:station-list="stationList"
|
||||||
:line-devices="lineDevices"
|
:line-devices="lineDevices"
|
||||||
:button-loading="exporting"
|
:button-loading="exporting"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { useQueryControlStore } from '@/stores/query-control';
|
||||||
import { NLayout, NLayoutContent } from 'naive-ui';
|
import { NLayout, NLayoutContent } from 'naive-ui';
|
||||||
import { onBeforeUnmount } from 'vue';
|
import { onBeforeUnmount } from 'vue';
|
||||||
import { useQueryControlStore } from '@/stores/query-control';
|
|
||||||
|
|
||||||
const queryControlStore = useQueryControlStore();
|
const queryControlStore = useQueryControlStore();
|
||||||
queryControlStore.disablePolling();
|
queryControlStore.disablePolling();
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useDeviceSelection } from '@/composables/device';
|
import { useDeviceSelection } from '@/composables/device';
|
||||||
import { useLineDevicesQuery, type LineDevices } from '@/composables/query';
|
import { useLineDevicesQuery } from '@/composables/query';
|
||||||
import { useLineDevicesStore } from '@/stores/line-devices';
|
import { useLineDevicesStore } from '@/stores/line-devices';
|
||||||
import { useStationStore } from '@/stores/station';
|
import { useStationStore } from '@/stores/station';
|
||||||
import { ChevronBack } from '@vicons/ionicons5';
|
import { ChevronBack } from '@vicons/ionicons5';
|
||||||
import { watchDebounced } from '@vueuse/core';
|
import { watchDebounced } from '@vueuse/core';
|
||||||
import { NEmpty, NIcon, NLayout, NLayoutContent, NLayoutSider, NPageHeader, NScrollbar, NSpin } from 'naive-ui';
|
import { NEmpty, NIcon, NLayout, NLayoutContent, NLayoutSider, NPageHeader, NScrollbar, NSpin } from 'naive-ui';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { onMounted, ref, watch } from 'vue';
|
import { onMounted, watch } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
import DeviceTree from '@/components/device-page/device-tree.vue';
|
import DeviceTree from '@/components/device-page/device-tree.vue';
|
||||||
import DeviceRenderer from '@/components/device-page/device-renderer.vue';
|
import DeviceRenderer from '@/components/device-page/device-renderer.vue';
|
||||||
|
|
||||||
// 数据获取
|
// 数据获取
|
||||||
const { isFetching: lineDevicesFetching, error: lineDevicesQueryError } = useLineDevicesQuery();
|
const { error: lineDevicesQueryError } = useLineDevicesQuery();
|
||||||
const stationStore = useStationStore();
|
const stationStore = useStationStore();
|
||||||
const { stationList } = storeToRefs(stationStore);
|
const { stationList } = storeToRefs(stationStore);
|
||||||
const lineDevicesStore = useLineDevicesStore();
|
const lineDevicesStore = useLineDevicesStore();
|
||||||
@@ -32,21 +32,6 @@ onMounted(() => {
|
|||||||
initFromRoute(lineDevices.value);
|
initFromRoute(lineDevices.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 加载条控制
|
|
||||||
watch(
|
|
||||||
lineDevicesFetching,
|
|
||||||
(fetching) => {
|
|
||||||
if (fetching) {
|
|
||||||
window.$loadingBar.start();
|
|
||||||
} else {
|
|
||||||
window.$loadingBar.finish();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
immediate: true,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// 当设备数据更新时,需要重新配置设备树
|
// 当设备数据更新时,需要重新配置设备树
|
||||||
watchDebounced(
|
watchDebounced(
|
||||||
lineDevices,
|
lineDevices,
|
||||||
@@ -98,11 +83,6 @@ watch(lineDevicesQueryError, (newLineDevicesQueryError) => {
|
|||||||
<DeviceRenderer :station-code="selectedStationCode" :device="selectedDevice" />
|
<DeviceRenderer :station-code="selectedStationCode" :device="selectedDevice" />
|
||||||
</NScrollbar>
|
</NScrollbar>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="lineDevicesFetching">
|
|
||||||
<div style="width: 100%; height: 100%; display: flex">
|
|
||||||
<NSpin style="margin: auto" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div style="width: 100%; height: 100%; display: flex">
|
<div style="width: 100%; height: 100%; display: flex">
|
||||||
<NEmpty description="选择设备查看诊断数据" style="margin: auto" />
|
<NEmpty description="选择设备查看诊断数据" style="margin: auto" />
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ const vimpOperationTypeOptions: SelectOption[] = [
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { NdmVimpLogResultVO } from '@/apis/models/device';
|
import type { NdmVimpLogResultVO } from '@/apis/models/device';
|
||||||
import { ndmVimpLogDefaultExportByTemplate, postNdmVimpLogPage } from '@/apis/requests';
|
import { ndmVimpLogDefaultExportByTemplate, postNdmVimpLogPage } from '@/apis/requests';
|
||||||
import { useStationListQuery } from '@/composables/query';
|
|
||||||
import { useStationStore } from '@/stores/station';
|
import { useStationStore } from '@/stores/station';
|
||||||
import { downloadByData } from '@/utils/download';
|
import { downloadByData } from '@/utils/download';
|
||||||
import { useMutation } from '@tanstack/vue-query';
|
import { useMutation } from '@tanstack/vue-query';
|
||||||
@@ -57,7 +56,6 @@ import {
|
|||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { computed, h, onMounted, reactive, ref, watch, watchEffect } from 'vue';
|
import { computed, h, onMounted, reactive, ref, watch, watchEffect } from 'vue';
|
||||||
|
|
||||||
useStationListQuery();
|
|
||||||
const stationStore = useStationStore();
|
const stationStore = useStationStore();
|
||||||
const { stationList, onlineStationList } = storeToRefs(stationStore);
|
const { stationList, onlineStationList } = storeToRefs(stationStore);
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
import type { LineAlarmCounts } from '@/composables/query';
|
|
||||||
import { defineStore } from 'pinia';
|
|
||||||
import { ref } from 'vue';
|
|
||||||
|
|
||||||
export const useLineAlarmCountsStore = defineStore('ndm-line-alarm-counts-store', () => {
|
|
||||||
const lineAlarmCounts = ref<LineAlarmCounts>({});
|
|
||||||
|
|
||||||
return {
|
|
||||||
lineAlarmCounts,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import type { LineAlarms } from '@/composables/query';
|
import type { LineAlarmCounts } from '@/composables/query';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
export const useLineAlarmsStore = defineStore('ndm-line-alarms-store', () => {
|
export const useLineAlarmsStore = defineStore('ndm-line-alarms-store', () => {
|
||||||
const lineAlarms = ref<LineAlarms>({});
|
const lineAlarmCounts = ref<LineAlarmCounts>({});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
lineAlarms,
|
lineAlarmCounts,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user