From d88dfe3c85a6fae48d96da44969c518b529a5b17 Mon Sep 17 00:00:00 2001 From: "MJM_2025_05\\polly" Date: Mon, 11 Aug 2025 11:22:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=A5=20systemConfig=20=E5=88=A4?= =?UTF-8?q?=E6=96=B7=20Dashboard=20=E5=B7=A6=E4=B8=8A=E7=94=9F=E7=94=A2?= =?UTF-8?q?=E6=8C=87=E6=A8=99=E9=A1=AF=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/dashboard/Dashboard.vue | 73 +++++---- .../dashboard/components/DashboardIndoor.vue | 1 + .../dashboard/components/DashboardProduct.vue | 53 ++++++- .../components/DashboardProductComplete.vue | 138 ++++++++++++------ .../dashboard/components/DashboardRefrig.vue | 5 +- 5 files changed, 191 insertions(+), 79 deletions(-) diff --git a/src/views/dashboard/Dashboard.vue b/src/views/dashboard/Dashboard.vue index 45978fb..0cc75c5 100644 --- a/src/views/dashboard/Dashboard.vue +++ b/src/views/dashboard/Dashboard.vue @@ -15,19 +15,22 @@ import useBuildingStore from "@/stores/useBuildingStore"; import { getSystemDevices, getSystemRealTime } from "@/apis/system"; import DashboardRefrig from "./components/DashboardRefrig.vue"; const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL; -const buildingStore = useBuildingStore() +const buildingStore = useBuildingStore(); const subscribeData = ref([]); const systemData = ref({}); let intervalId = null; +const productVisible = ref(false); // 產品產量儀表是否顯示 +const productCompleteVisible = ref(false); // 今日達成率是否顯示 + // 開始定時器 const startInterval = () => { // 清除之前的定時器(如果存在) if (intervalId) { clearInterval(intervalId); } - + // 每5秒呼叫一次 getData intervalId = setInterval(() => { getData(); @@ -37,29 +40,32 @@ const startInterval = () => { const getData = async () => { const res = await getSystemDevices({ building_guid: buildingStore.selectedBuilding?.building_guid, - }) + }); + + subscribeData.value = res.data; + console.log("devices", subscribeData.value); - subscribeData.value = res.data - console.log("devices", subscribeData.value) - // 轉換資料格式 const transformedData = {}; - - subscribeData.value.forEach(floor => { + + subscribeData.value.forEach((floor) => { if (floor.device_list && floor.device_list.length > 0) { const fullUrl = floor.floor_map_name; const uuid = fullUrl ? fullUrl.replace(/\.svg$/, "") : ""; - transformedData[uuid] = floor.device_list.map(device => { + transformedData[uuid] = floor.device_list.map((device) => { // 解析座標 - const coordinates = JSON.parse(device.device_coordinate || '[0,0]'); + const coordinates = JSON.parse(device.device_coordinate || "[0,0]"); const x = coordinates[0]; const y = coordinates[1]; - + // 決定設備狀態和顏色 let state = "Online"; let bgColor = device.device_normal_color; - - if (device.device_status === "Offline" || device.device_status === null) { + + if ( + device.device_status === "Offline" || + device.device_status === null + ) { state = "Offline"; bgColor = device.device_close_color; } @@ -80,7 +86,9 @@ const getData = async () => { points: device.points || [], floor: floor.full_name, state: state, - icon: device.device_image ? `${FILE_BASEURL}/upload/device_icon/${device.device_image}` : '', + icon: device.device_image + ? `${FILE_BASEURL}/upload/device_icon/${device.device_image}` + : "", bgColor: bgColor, Online_color: device.device_normal_color, Offline_color: device.device_close_color, @@ -92,15 +100,15 @@ const getData = async () => { buying_date: device.buying_date, created_at: device.created_at, bgSize: 50, - } + }, ]; }); } }); - + console.log("transformedData", transformedData); systemData.value = transformedData; -} +}; watch( () => buildingStore.selectedBuilding, @@ -111,7 +119,7 @@ watch( } }, { - immediate: true + immediate: true, } ); @@ -126,29 +134,38 @@ onUnmounted(() => {