diff --git a/src/views/system/System.vue b/src/views/system/System.vue index 10cc9aa..00476a7 100644 --- a/src/views/system/System.vue +++ b/src/views/system/System.vue @@ -69,7 +69,8 @@ const getData = async () => { currentColor: dev.device_normal_point_color, spriteDbId: 10 + index, sensorTypes: dev.points.map(({ points }) => points), - floor_guid: d.floor_guid + floor_guid: d.floor_guid, + is2DActive: false })), })); diff --git a/src/views/system/SystemFloor.vue b/src/views/system/SystemFloor.vue index 48fe148..c526cc5 100644 --- a/src/views/system/SystemFloor.vue +++ b/src/views/system/SystemFloor.vue @@ -55,6 +55,8 @@ const defaultOption = (map, data = []) => { const { selectedFloor } = useSelectedFloor() +const allData = ref([]) + watch([selectedFloor, () => asset_floor_chart,], ([newValue, newChart], [oldValue]) => { if (newValue && newChart.value && oldValue?.key !== newValue.key && newValue.map_url) { asset_floor_chart.value.updateSvg( @@ -65,24 +67,27 @@ watch([selectedFloor, () => asset_floor_chart,], ([newValue, newChart], [oldValu defaultOption(newValue?.title, subscribeData.value?.filter(d => d.device_coordinate && d.floor_guid === route.params.floor_id).map(d => [...d.device_coordinate.split(","), d]) || []) ); - const allData = subscribeData.value?.filter(d => d.device_coordinate && d.floor_guid === route.params.floor_id).map(d => [...d.device_coordinate.split(","), d]) + newChart.value.chart.on("click", function (params) { console.log(params, params.data[2]) getCurrentInfoModalData(params.event, { left: params.event.offsetX , top: params.event.offsetY - }, params.data[3]) - const selected = allData.filter((d => d[2].device_number === params.data[2].device_number)) - const unSelected = allData.filter((d => d[2].device_number !== params.data[2].device_number)) - newChart.value.chart.setOption({ + }, params.data[2]) + let values = [...subscribeData.value].map(d => ({ ...d, is2DActive: d.forge_dbid === params.data[2].forge_dbid })) + subscribeData.value = values; + + const selected = allData.value.filter((d => d[2].device_number === params.data[2].device_number)) + const unSelected = allData.value.filter((d => d[2].device_number !== params.data[2].device_number)) + newChart.value.chart.setOption({ series: [ { data: unSelected }, { data: selected, } ] }) - console.log(selected, unSelected) + }); @@ -93,12 +98,19 @@ watch([selectedFloor, () => asset_floor_chart,], ([newValue, newChart], [oldValu }) watch(subscribeData, (newData) => { + let values = newData?.filter(d => d.device_coordinate && d.floor_guid === route.params.floor_id).map(d => [...d.device_coordinate.split(","), d]) + allData.value = values; if (selectedFloor.value && asset_floor_chart.value && asset_floor_chart.value.chart) { + const selected = allData.value.filter((d => d[2].is2DActive)) + const unSelected = allData.value.filter((d => !d[2].is2DActive)) asset_floor_chart.value.chart.setOption({ - series: { - data: newData.filter(d => d.device_coordinate && d.floor_guid === route.params.floor_id).map(d => [...d.device_coordinate.split(","), d]), - }, + series: [ + { data: unSelected }, { + data: selected, + } + ] }) + console.log(asset_floor_chart.value.chart.getOption()) } }, { immediate: true, diff --git a/src/views/system/components/SystemCard.vue b/src/views/system/components/SystemCard.vue index f1133bb..dae5cfa 100644 --- a/src/views/system/components/SystemCard.vue +++ b/src/views/system/components/SystemCard.vue @@ -3,12 +3,17 @@ import { computed, inject, watch } from "vue" import useSystemShowData from "@/hooks/useSystemShowData" const { getCurrentInfoModalData, selected_dbid } = inject("system_selectedDevice") +const { subscribeData } = inject("system_deviceList"); const { showData } = useSystemShowData() const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL; -const fitToView = (forge_dbid,spriteDbId) => { - selected_dbid.value=[forge_dbid,spriteDbId]; +const fitToView = (forge_dbid, spriteDbId) => { + selected_dbid.value = [forge_dbid, spriteDbId]; + console.log(subscribeData.value) + let allData = [...subscribeData.value].map(d => ({ ...d, is2DActive: d.forge_dbid === forge_dbid })) + subscribeData.value = allData; + }; @@ -25,7 +30,8 @@ const fitToView = (forge_dbid,spriteDbId) => {
- + {{ device.full_name }}
@@ -108,7 +114,7 @@ const fitToView = (forge_dbid,spriteDbId) => { z-index: 1; } -.equipment-show .item .sec02 img{ +.equipment-show .item .sec02 img { margin-right: 10px; width: 2rem !important; height: 2rem;