fix(station-page): keep polling when open modal
This commit is contained in:
@@ -10,12 +10,11 @@ import {
|
|||||||
type StationAlarmCounts,
|
type StationAlarmCounts,
|
||||||
} from '@/apis';
|
} from '@/apis';
|
||||||
import { AlarmType, DeviceType, DeviceTypeCode, DeviceTypeName, FaultLevel, type DeviceTypeVal } from '@/enums';
|
import { AlarmType, DeviceType, DeviceTypeCode, DeviceTypeName, FaultLevel, type DeviceTypeVal } from '@/enums';
|
||||||
import { useQueryControlStore } from '@/stores';
|
|
||||||
import { downloadByData } from '@/utils';
|
import { downloadByData } from '@/utils';
|
||||||
import { useMutation } from '@tanstack/vue-query';
|
import { useMutation } from '@tanstack/vue-query';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { NButton, NCol, NDataTable, NModal, NRow, NSpace, NStatistic, NTag, type DataTableColumns, type DataTableProps, type DataTableRowData, type PaginationProps } from 'naive-ui';
|
import { NButton, NCol, NDataTable, NModal, NRow, NSpace, NStatistic, NTag, type DataTableColumns, type DataTableProps, type DataTableRowData, type PaginationProps } from 'naive-ui';
|
||||||
import { computed, h, reactive, ref, toRefs, watch } from 'vue';
|
import { computed, h, reactive, ref, toRefs } from 'vue';
|
||||||
import { renderAlarmDateCell, renderDeviceTypeCell, renderAlarmTypeCell, renderFaultLevelCell } from '../helper';
|
import { renderAlarmDateCell, renderDeviceTypeCell, renderAlarmTypeCell, renderFaultLevelCell } from '../helper';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -27,17 +26,6 @@ const props = defineProps<Props>();
|
|||||||
const { station, stationAlarmCounts } = toRefs(props);
|
const { station, stationAlarmCounts } = toRefs(props);
|
||||||
const show = defineModel<boolean>('show', { required: true, default: false });
|
const show = defineModel<boolean>('show', { required: true, default: false });
|
||||||
|
|
||||||
watch(show, (newValue) => {
|
|
||||||
const queryControlStore = useQueryControlStore();
|
|
||||||
if (newValue) {
|
|
||||||
console.log('对话框打开,停止轮询');
|
|
||||||
queryControlStore.disablePolling();
|
|
||||||
} else {
|
|
||||||
console.log('对话框关闭,开启轮询');
|
|
||||||
queryControlStore.enablePolling();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const alarmCount = computed(() => stationAlarmCounts.value?.unclassified ?? 0);
|
const alarmCount = computed(() => stationAlarmCounts.value?.unclassified ?? 0);
|
||||||
|
|
||||||
const classifiedAlarmCounts = computed(() => {
|
const classifiedAlarmCounts = computed(() => {
|
||||||
|
|||||||
@@ -69,10 +69,9 @@ const getItemSuffix = (name: string) => {
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { postDefParameterPage, putDefParameter, type Station } from '@/apis';
|
import { postDefParameterPage, putDefParameter, type Station } from '@/apis';
|
||||||
import { useQueryControlStore } from '@/stores';
|
|
||||||
import { useMutation } from '@tanstack/vue-query';
|
import { useMutation } from '@tanstack/vue-query';
|
||||||
import { NForm, NFormItemGi, NGrid, NInputNumber, NModal, NTabPane, NTabs, NTimePicker, NSpin, NFlex } from 'naive-ui';
|
import { NForm, NFormItemGi, NGrid, NInputNumber, NModal, NTabPane, NTabs, NTimePicker, NSpin, NFlex } from 'naive-ui';
|
||||||
import { ref, toRefs, watch } from 'vue';
|
import { ref, toRefs } from 'vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
station?: Station;
|
station?: Station;
|
||||||
@@ -80,18 +79,6 @@ const props = defineProps<{
|
|||||||
const { station } = toRefs(props);
|
const { station } = toRefs(props);
|
||||||
const show = defineModel<boolean>('show', { required: true });
|
const show = defineModel<boolean>('show', { required: true });
|
||||||
|
|
||||||
const queryControlStore = useQueryControlStore();
|
|
||||||
|
|
||||||
watch(show, (newValue) => {
|
|
||||||
if (newValue) {
|
|
||||||
console.log('对话框打开,停止轮询');
|
|
||||||
queryControlStore.disablePolling();
|
|
||||||
} else {
|
|
||||||
console.log('对话框关闭,开启轮询');
|
|
||||||
queryControlStore.enablePolling();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const tabPanes = [
|
const tabPanes = [
|
||||||
{
|
{
|
||||||
tab: '交换机阈值',
|
tab: '交换机阈值',
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { NdmDeviceVO, Station, StationDevices } from '@/apis';
|
import type { NdmDeviceVO, Station, StationDevices } from '@/apis';
|
||||||
import { DeviceType, DeviceTypeName, tryGetDeviceTypeVal } from '@/enums';
|
import { DeviceType, DeviceTypeName, tryGetDeviceTypeVal } from '@/enums';
|
||||||
import { useQueryControlStore } from '@/stores';
|
|
||||||
import { NButton, NCol, NInput, NModal, NRow, NStatistic, NTree, type TreeOption, type TreeOverrideNodeClickBehavior, type TreeProps } from 'naive-ui';
|
import { NButton, NCol, NInput, NModal, NRow, NStatistic, NTree, type TreeOption, type TreeOverrideNodeClickBehavior, type TreeProps } from 'naive-ui';
|
||||||
import { computed, h, ref, toRefs, watch } from 'vue';
|
import { computed, h, ref, toRefs } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -18,18 +17,6 @@ const show = defineModel<boolean>('show', { required: true, default: false });
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const queryControlStore = useQueryControlStore();
|
|
||||||
|
|
||||||
watch(show, (newValue) => {
|
|
||||||
if (newValue) {
|
|
||||||
console.log('对话框打开,停止轮询');
|
|
||||||
queryControlStore.disablePolling();
|
|
||||||
} else {
|
|
||||||
console.log('对话框关闭,开启轮询');
|
|
||||||
queryControlStore.enablePolling();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const searchPattern = ref('');
|
const searchPattern = ref('');
|
||||||
const searchFilter: (pattern: string, node: TreeOption) => boolean = (pattern, node) => {
|
const searchFilter: (pattern: string, node: TreeOption) => boolean = (pattern, node) => {
|
||||||
const device = node['device'] as NdmDeviceVO | undefined;
|
const device = node['device'] as NdmDeviceVO | undefined;
|
||||||
@@ -74,7 +61,6 @@ const treeData = computed<TreeOption[]>(() => {
|
|||||||
size: 'tiny',
|
size: 'tiny',
|
||||||
type: 'info',
|
type: 'info',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
queryControlStore.enablePolling();
|
|
||||||
const dev = device as NdmDeviceVO;
|
const dev = device as NdmDeviceVO;
|
||||||
router.push({
|
router.push({
|
||||||
path: '/device',
|
path: '/device',
|
||||||
@@ -108,7 +94,6 @@ const nodeProps: TreeProps['nodeProps'] = ({ option }) => {
|
|||||||
return {
|
return {
|
||||||
onDblclick: (payload: MouseEvent) => {
|
onDblclick: (payload: MouseEvent) => {
|
||||||
payload.stopPropagation();
|
payload.stopPropagation();
|
||||||
queryControlStore.enablePolling();
|
|
||||||
const device = option['device'] as NdmDeviceVO;
|
const device = option['device'] as NdmDeviceVO;
|
||||||
router.push({
|
router.push({
|
||||||
path: '/device',
|
path: '/device',
|
||||||
|
|||||||
Reference in New Issue
Block a user