diff --git a/src/components/device-alarm-detail-modal.vue b/src/components/dashboard-page/device-alarm-detail-modal.vue similarity index 98% rename from src/components/device-alarm-detail-modal.vue rename to src/components/dashboard-page/device-alarm-detail-modal.vue index 97b528f..fbf9d7a 100644 --- a/src/components/device-alarm-detail-modal.vue +++ b/src/components/dashboard-page/device-alarm-detail-modal.vue @@ -19,7 +19,7 @@ interface Props { const props = defineProps(); const { station, stationAlarms } = toRefs(props); -const show = defineModel('show', { required: true }); +const show = defineModel('show', { required: true, default: false }); watch(show, (newValue) => { const queryControlStore = useQueryControlStore(); diff --git a/src/components/device-params-config-modal.vue b/src/components/dashboard-page/device-params-config-modal.vue similarity index 98% rename from src/components/device-params-config-modal.vue rename to src/components/dashboard-page/device-params-config-modal.vue index fb78f7c..ca37ef9 100644 --- a/src/components/device-params-config-modal.vue +++ b/src/components/dashboard-page/device-params-config-modal.vue @@ -77,7 +77,7 @@ import { ref, toRefs, watch } from 'vue'; const props = defineProps<{ station: Station }>(); const { station } = toRefs(props); -const show = defineModel('show', { required: true }); +const show = defineModel('show', { required: true, default: false }); watch(show, (newValue) => { const queryControlStore = useQueryControlStore(); diff --git a/src/components/offline-device-detail-modal.vue b/src/components/dashboard-page/offline-device-detail-modal.vue similarity index 86% rename from src/components/offline-device-detail-modal.vue rename to src/components/dashboard-page/offline-device-detail-modal.vue index d62b1ed..29bdf3c 100644 --- a/src/components/offline-device-detail-modal.vue +++ b/src/components/dashboard-page/offline-device-detail-modal.vue @@ -5,7 +5,7 @@ import type { StationDevices } from '@/composables/query'; import { DeviceType, DeviceTypeName, getDeviceTypeVal } from '@/enums/device-type'; import { useQueryControlStore } from '@/stores/query-control'; import { NButton, NCol, NInput, NModal, NRow, NStatistic, NTree } from 'naive-ui'; -import type { TreeOption, TreeOverrideNodeClickBehavior } from 'naive-ui'; +import type { TreeOption, TreeOverrideNodeClickBehavior, TreeProps } from 'naive-ui'; import { computed, h, ref, toRefs, watch } from 'vue'; import { useRoute, useRouter } from 'vue-router'; @@ -16,13 +16,14 @@ interface Props { const props = defineProps(); const { station, stationDevices } = toRefs(props); -const show = defineModel('show', { required: true }); +const show = defineModel('show', { required: true, default: false }); const route = useRoute(); const router = useRouter(); +const queryControlStore = useQueryControlStore(); + watch(show, (newValue) => { - const queryControlStore = useQueryControlStore(); if (newValue) { console.log('对话框打开,停止轮询'); queryControlStore.disablePolling(); @@ -76,7 +77,6 @@ const treeData = computed(() => { size: 'tiny', type: 'info', onClick: () => { - const queryControlStore = useQueryControlStore(); queryControlStore.enablePolling(); const dev = device as NdmDeviceVO; router.push({ @@ -100,12 +100,32 @@ const treeData = computed(() => { }); const override: TreeOverrideNodeClickBehavior = ({ option }) => { + return 'none'; if (!option['device']) { return 'none'; } return 'default'; }; +const nodeProps: TreeProps['nodeProps'] = ({ option }) => { + return { + onDblclick: (payload: MouseEvent) => { + payload.stopPropagation(); + queryControlStore.enablePolling(); + const device = option['device'] as NdmDeviceVO; + router.push({ + path: '/device', + query: { + stationCode: station.value.code, + deviceType: getDeviceTypeVal(device.deviceType), + deviceDBId: device.id, + from: route.path, + }, + }); + }, + }; +}; + const onModalClose = () => { searchPattern.value = ''; }; @@ -134,6 +154,7 @@ const onModalClose = () => { (); const { station, stationDevices, stationAlarms } = toRefs(props); -const { code, name, online } = toRefs(station.value); // 计算总离线设备数量 const offlineDeviceCount = computed(() => { @@ -51,21 +50,21 @@ const devicAlarmCount = computed(() => { // 打开对话框 const openOfflineDeviceTreeModal = () => { - if (online.value) { + if (station.value.online) { emit('open-offline-device-detail-modal', station.value); } else { window.$message.error('当前车站离线,无法查看'); } }; const openDeviceAlarmTreeModal = () => { - if (online.value) { + if (station.value.online) { emit('open-device-alarm-detail-modal', station.value); } else { window.$message.error('当前车站离线,无法查看'); } }; const openDeviceConfigModal = () => { - if (online.value) { + if (station.value.online) { emit('open-device-params-config-modal', station.value); } else { window.$message.error('当前车站离线,无法查看'); @@ -76,11 +75,11 @@ const openDeviceConfigModal = () => { const openVideoPlatform = async () => { try { const response = await axios.get>('/minio/ndm/ndm-vimps.json'); - const vimpUrl = response.data[code.value]; + const vimpUrl = response.data[station.value.code]; if (vimpUrl) { window.open(vimpUrl, '_blank'); } else { - window.$message.warning(`未找到车站编码 ${code.value} 对应的视频平台URL`); + window.$message.warning(`未找到车站编码 ${station.value.code} 对应的视频平台URL`); return; } } catch (error) { @@ -95,11 +94,11 @@ const theme = useThemeVars();