diff --git a/.env.development b/.env.development index de90992..70caef8 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,3 @@ VITE_API_BASEURL = "https://ibms-cvilux-api.production.mjmtech.com.tw" -VITE_FILE_API_BASEURL = "https://ibms-cvilux.production.mjmtech.com.tw" +VITE_FILE_API_BASEURL = "https://cgems.cvilux-group.com:8088" VITE_FORGE_BASEURL = "http://localhost:5173" \ No newline at end of file diff --git a/src/hooks/forge/useForgeSprite.js b/src/hooks/forge/useForgeSprite.js index 4e257da..f1c5398 100644 --- a/src/hooks/forge/useForgeSprite.js +++ b/src/hooks/forge/useForgeSprite.js @@ -68,7 +68,7 @@ export default function useForgeSprite() { // await viewableData.finish(); // dataVizExtn.value.addViewables(viewableData); // console.log(dataVizExtn.value); - viewableData.then( + viewableData.finish().then( () => { dataVizExtn.value.addViewables(viewableData); }, diff --git a/src/views/system/System.vue b/src/views/system/System.vue index 8f3596c..3ea8806 100644 --- a/src/views/system/System.vue +++ b/src/views/system/System.vue @@ -7,7 +7,10 @@ import ForgeForSystem from "@/components/forge/ForgeForSystem.vue"; import { getSystemDevices, getSystemRealTime } from "@/apis/system"; import SystemSubBar from './components/SystemSubBar.vue'; import SystemInfoModal from './components/SystemInfoModal.vue'; -import SystemMain from "./SystemMain.vue" +import SystemMain from "./SystemMain.vue"; +import SystemMode from './components/SystemMode.vue'; +import SystemFloor from './SystemFloor.vue'; +import { twMerge } from 'tailwind-merge'; const buildingStore = useBuildingStore() @@ -81,12 +84,17 @@ watch(raw_data, (newValue) => { const updateDataByGas = (gas) => { - const update_values = raw_data.value.map((d) => ( - { - ...d, - device_list: d.device_list.filter(({ points }) => points.some(({ points: p }) => p === gas)) - } - )) + let update_values = [] + if (gas === "all") { + update_values = raw_data.value + } else { + update_values = raw_data.value.map((d) => ( + { + ...d, + device_list: d.device_list.filter(({ points }) => points.some(({ points: p }) => p === gas)) + } + )) + } data.value = update_values subscribeData.value = getSubData(update_values); } @@ -191,13 +199,18 @@ provide("system_selectedDevice", { selectedDeviceRealtime, selectedDevice, getCu -
+
-
- - +
+ +
+ +
+ +
+
diff --git a/src/views/system/SystemFloor.vue b/src/views/system/SystemFloor.vue index fe79b61..417d39f 100644 --- a/src/views/system/SystemFloor.vue +++ b/src/views/system/SystemFloor.vue @@ -38,15 +38,15 @@ const defaultOption = (map, data = []) => ({ const { selectedFloor } = useSelectedFloor() -watch([selectedFloor, () => asset_floor_chart, subscribeData], ([newValue, newChart, newData]) => { - if (newValue && newChart.value) { +watch([selectedFloor, () => asset_floor_chart,], ([newValue, newChart], [oldValue]) => { + if (newValue && newChart.value && oldValue?.key !== newValue.key) { asset_floor_chart.value.updateSvg( { full_name: newValue?.title, path: `${FILE_BASEURL}/${newValue.map_url}`, }, - defaultOption(newValue?.title, newData.filter(d => d.device_coordinate && d.floor_guid === route.params.floor_id).map(d => [...d.device_coordinate.split(","), d])) + defaultOption(newValue?.title, 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]) @@ -60,14 +60,25 @@ watch([selectedFloor, () => asset_floor_chart, subscribeData], ([newValue, newCh immediate: true, deep: true, }) + +watch(subscribeData, (newData) => { + if (selectedFloor.value && asset_floor_chart.value) { + 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]), + }, + }) + } +}, { + immediate: true, + deep: true, +}) diff --git a/src/views/system/components/SystemFloorBar.vue b/src/views/system/components/SystemFloorBar.vue index 12f67cf..7f21eca 100644 --- a/src/views/system/components/SystemFloorBar.vue +++ b/src/views/system/components/SystemFloorBar.vue @@ -37,10 +37,10 @@ const onClick = (item) => { changeActiveBtn(item) router.push({ - name: 'sub_system', params: { - ...route.params, floor_id: item.key - }, query: { gas: route.query.gas } - }) + name: 'sub_system', params: { + ...route.params, floor_id: item.key + }, query: { ...route.query, gas: route.query.gas } + }) } diff --git a/src/views/system/components/SystemMode.vue b/src/views/system/components/SystemMode.vue new file mode 100644 index 0000000..266acc4 --- /dev/null +++ b/src/views/system/components/SystemMode.vue @@ -0,0 +1,47 @@ + + + + + \ No newline at end of file diff --git a/src/views/system/components/SystemSubBar.vue b/src/views/system/components/SystemSubBar.vue index 9006946..a5875b3 100644 --- a/src/views/system/components/SystemSubBar.vue +++ b/src/views/system/components/SystemSubBar.vue @@ -11,24 +11,39 @@ const { items, changeActiveBtn, setItems, selectedBtn } = useActiveBtn(); const route = useRoute() watch(() => buildingStore, (newValue) => { - newValue.selectedSystem?.points?.length > 0 && setItems(newValue.selectedSystem.points.map(d => ({ - title: d.full_name, - key: d.points, - active: route.query.gas ? route.query.gas === d.points : d.points === "temp", - }))) + newValue.selectedSystem?.points?.length > 0 && setItems([ + { + title: "All", + key: "all", + active: route.query.gas === "all" || !route.query.gas, + }, + ...newValue.selectedSystem.points.map(d => ({ + title: d.full_name, + key: d.points, + active: route.query.gas === d.points, + })) + ]) }, { deep: true, immediate: true }) -const { changeParams } = useSearchParam(); +const { changeParams, searchParams } = useSearchParam(); const onClick = (item) => { - changeParams({ gas: item.key }) changeActiveBtn(item) updateDataByGas(item.key) } +watch(selectedBtn, (newValue) => { + console.log(newValue) + newValue && changeParams({ ...searchParams.value, gas: newValue.key }) +}, { + deep: true, + immediate: true, + +}) +