From babef0e2ae9932fce7c70e5e5d828d30c96008b9 Mon Sep 17 00:00:00 2001 From: ko1234 Date: Thu, 4 Sep 2025 14:04:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AA=BF=E6=95=B4=E5=84=80=E8=A1=A8=E6=9D=BF?= =?UTF-8?q?=E8=88=87=E9=9B=BB=E8=A1=A8=E5=8D=A1=E7=89=87=E7=9A=84=E9=A1=AF?= =?UTF-8?q?=E7=A4=BA=E9=82=8F=E8=BC=AF=20|=20=E6=96=B0=E5=A2=9E=E9=9B=BB?= =?UTF-8?q?=E8=A1=A8=E5=8D=A1=E7=89=87=E5=8D=B3=E6=99=82=E6=95=B8=E6=93=9A?= =?UTF-8?q?=E7=8D=B2=E5=8F=96=E8=88=87=E5=9C=96=E8=A1=A8=E9=A1=AF=E7=A4=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/forge/Forge.vue | 15 - src/hooks/baja/useSystemStatusByBaja.js | 16 - src/views/dashboard/Dashboard.vue | 54 ++- .../components/DashboardForgeOptionButton.vue | 105 ++++-- .../components/DashboardForgeOptionCard.vue | 44 +-- .../dashboardForgeCards/CookingPotCard.vue | 41 ++- .../dashboardForgeCards/MeterCard.vue | 322 +++++++++++++++++- .../dashboardForgeCards/VesselCard.vue | 21 +- 8 files changed, 490 insertions(+), 128 deletions(-) diff --git a/src/components/forge/Forge.vue b/src/components/forge/Forge.vue index 45d5310..51a602c 100644 --- a/src/components/forge/Forge.vue +++ b/src/components/forge/Forge.vue @@ -107,21 +107,6 @@ const initForge = () => { viewer.isLoadDone() ); updateForgeViewer(viewer); - - // const tree = viewer.model.getData().instanceTree; - // hideAllObjects(tree, visibleDbid.value); - // visibleDbid.value.forEach((dbid) => { - // if (dbid === 58) { - // viewer.setThemingColor(dbid, new THREE.Vector4(1, 0, 0, 1)); - // } - // }); - // 印出被點選物件的 dbid - // viewer.addEventListener( - // Autodesk.Viewing.SELECTION_CHANGED_EVENT, - // function (event) { - // console.log("你選取的 forge_dbid:", event.dbIdArray); - // } - // ); } ); viewer.addEventListener( diff --git a/src/hooks/baja/useSystemStatusByBaja.js b/src/hooks/baja/useSystemStatusByBaja.js index f8432b3..a912fbc 100644 --- a/src/hooks/baja/useSystemStatusByBaja.js +++ b/src/hooks/baja/useSystemStatusByBaja.js @@ -495,22 +495,6 @@ export default function useSystemStatusByBaja(updateHeatBarIsShow) { } }); - watch(initialData, (newValue) => { - if (newValue) { - getDevice(searchParams.value.option); - } - }); - - watch( - searchParams, - (newValue) => { - getDevice(newValue.option); - }, - { - deep: true, - } - ); - // 動態Sprites創建函數 const createSprites = async (viewer, dbId, reverse = false) => { try { diff --git a/src/views/dashboard/Dashboard.vue b/src/views/dashboard/Dashboard.vue index ff25098..44f426f 100644 --- a/src/views/dashboard/Dashboard.vue +++ b/src/views/dashboard/Dashboard.vue @@ -9,13 +9,26 @@ import DashboardElectricity from "./components/DashboardElectricity.vue"; import DashboardAlert from "./components/DashboardAlert.vue"; import DashboardForgeOptionButton from "./components/DashboardForgeOptionButton.vue"; import DashboardForgeOptionCard from "./components/DashboardForgeOptionCard.vue"; -import { getDashboardInit, getDashboardOptionRealTimeData } from "@/apis/dashboard"; +import { + getDashboardInit, + getDashboardOptionRealTimeData, +} from "@/apis/dashboard"; +import { getAssetFloorList } from "@/apis/asset"; +import { getOperationCompanyList } from "@/apis/operation"; import useSearchParams from "@/hooks/useSearchParam"; import dayjs from "dayjs"; const initialData = ref(null); const realTimeData = ref(null); const realTime = ref(null); +// 電表列表 +const meterList = ref([]); +const selectedMeter = ref(null); +// 樓層列表 +const floors = ref([]); +// 廠商列表 +const companyOptions = ref([]); + const { searchParams } = useSearchParams(); let intervalId = null; @@ -34,6 +47,11 @@ const getDevice = async (option = 1) => { option: parseInt(option), }); realTimeData.value = res.data; + if (res.data?.meterData) { + meterList.value = (res.data?.meterData || []).sort(); + } else { + meterList.value = []; + } realTime.value = dayjs().format("YYYY-MM-DD HH:mm:ss"); console.log("實時數據:", realTimeData.value); } catch (err) { @@ -41,16 +59,26 @@ const getDevice = async (option = 1) => { } }; +const getFloors = async () => { + const res = await getAssetFloorList(); + floors.value = res.data[0]?.floors.map((d) => ({ ...d, key: d.floor_guid })); +}; + +const getCompany = async () => { + const res = await getOperationCompanyList(); + companyOptions.value = res.data.map((d) => ({ ...d, key: d.id })); +}; + // 開始定時器 const startInterval = (option) => { // 清除之前的定時器 if (intervalId) { clearInterval(intervalId); } - + // 立即執行一次 getDevice(option); - + // 設定每5秒執行一次 intervalId = setInterval(() => { getDevice(option); @@ -66,7 +94,7 @@ const stopInterval = () => { }; watch( - ()=>searchParams.value.option, + () => searchParams.value.option, (newValue) => { if (newValue) { startInterval(newValue); @@ -80,6 +108,8 @@ watch( onMounted(() => { init(); + getFloors(); + getCompany(); }); onUnmounted(() => { @@ -98,9 +128,19 @@ onUnmounted(() => { - - - + + +
diff --git a/src/views/dashboard/components/DashboardForgeOptionButton.vue b/src/views/dashboard/components/DashboardForgeOptionButton.vue index 9b51f1f..636ee21 100644 --- a/src/views/dashboard/components/DashboardForgeOptionButton.vue +++ b/src/views/dashboard/components/DashboardForgeOptionButton.vue @@ -5,15 +5,18 @@ import { twMerge } from "tailwind-merge"; const props = defineProps({ initialData: Object, + meterList: Array, + selectedMeter: [String, Number, null], }); const { changeParams, searchParams } = useSearchParams(); - +const emit = defineEmits(["update:selectedMeter"]); watch( () => props.initialData, (newValue) => { if (newValue?.options[0]) { - const { option, camera_position, target_position, top } = newValue.options[0]; + const { option, camera_position, target_position, top } = + newValue.options[0]; changeParams({ option, camera_position, target_position, top }); } }, @@ -27,30 +30,80 @@ watch( v-for="option in initialData.options" :key="`option_${option.option}`" > - + +
diff --git a/src/views/dashboard/components/DashboardForgeOptionCard.vue b/src/views/dashboard/components/DashboardForgeOptionCard.vue index 3d4dd45..3ece1ef 100644 --- a/src/views/dashboard/components/DashboardForgeOptionCard.vue +++ b/src/views/dashboard/components/DashboardForgeOptionCard.vue @@ -15,16 +15,11 @@ import ValveCard from "./dashboardForgeCards/ValveCard.vue"; const { searchParams, changeParams } = useSearchParams(); const props = defineProps({ realTimeData: Object, + selectedMeter: String, + floors: Array, + companyOptions: Array, }); -const tabs = [ - { label: "生產資訊" }, - { label: "投料進度" }, - { label: "品檢" }, - { label: "流量計" }, - { label: "SIP" }, -]; - // 生產資訊卡片資料 const productionData = computed(() => { return props.realTimeData?.productionData || []; @@ -36,24 +31,9 @@ const heaterData = computed(() => { return props.realTimeData?.heaterData || []; }); -// 管理所有設備的activeTab狀態 -const deviceActiveTabs = ref(new Map()); - -// 獲取或創建設備的activeTab -const getDeviceActiveTab = (deviceName, defaultTab = "生產資訊") => { - if (!deviceActiveTabs.value.has(deviceName)) { - deviceActiveTabs.value.set(deviceName, ref(defaultTab)); - } - return deviceActiveTabs.value.get(deviceName); -}; - // 二重釜資料 const vesselsData = computed(() => { - const data = props.realTimeData?.productionData || []; - return data.map((vessel) => ({ - ...vessel, - activeTab: getDeviceActiveTab(vessel.name), - })); + return props.realTimeData?.productionData || []; }); // 加熱器資料 @@ -63,11 +43,7 @@ const heaterPotData = computed(() => { // 調理鍋資料 const cookingPotData = computed(() => { - const data = props.realTimeData?.cookingData || []; - return data.map((pot) => ({ - ...pot, - activeTab2: getDeviceActiveTab(pot.name), - })); + return props.realTimeData?.cookingData || []; }); // 冷藏室資料 @@ -78,7 +54,11 @@ const refrigerationData = computed(() => { // 電錶資料 const meterData = computed(() => { const data = props.realTimeData?.meterData || []; - return data.sort((a, b) => a.name.localeCompare(b.name)); + // 篩選出符合 selectedMeter 的資料 + const filtered = props.selectedMeter + ? data.filter((meter) => meter.main_id === props.selectedMeter) + : []; + return filtered; }); // 威鈦閥異常訊號資料 @@ -105,7 +85,6 @@ const valveData = computed(() => { v-for="(vessel, index) in vesselsData" :key="index" :vessel="vessel" - :tabs="tabs.filter(tab => tab.label !== '品檢')" />
@@ -120,7 +99,6 @@ const valveData = computed(() => { v-for="(pot, index) in cookingPotData" :key="index" :pot="pot" - :tabs="tabs" /> @@ -137,6 +115,8 @@ const valveData = computed(() => { v-for="(meter, index) in meterData" :key="index" :meter="meter" + :floors="props.floors" + :companyOptions="props.companyOptions" /> diff --git a/src/views/dashboard/components/dashboardForgeCards/CookingPotCard.vue b/src/views/dashboard/components/dashboardForgeCards/CookingPotCard.vue index 75b9da8..4833cb8 100644 --- a/src/views/dashboard/components/dashboardForgeCards/CookingPotCard.vue +++ b/src/views/dashboard/components/dashboardForgeCards/CookingPotCard.vue @@ -1,8 +1,16 @@