From 5b1ff9749d6e0176283f3cb30158c283d2bd0334 Mon Sep 17 00:00:00 2001 From: ko1234 Date: Fri, 24 Jan 2025 16:01:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=B5=B1=E7=9B=A3=E6=8E=A7:=202D?= =?UTF-8?q?=E5=9C=93=E9=BB=9Ebug=E4=BF=AE=E6=AD=A3=20|=20=E8=83=BD?= =?UTF-8?q?=E6=BA=90=E7=AE=A1=E7=90=86:=20=E6=97=A5=E5=A0=B1=E8=A1=A8?= =?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/apis/energy/api.js | 2 + src/apis/energy/index.js | 24 +++ .../EnergyReport/EnergyReportSearch.vue | 6 +- .../EnergyReport/EnergyReportTable.vue | 80 +++++++- src/views/system/System.vue | 21 +- src/views/system/SystemFloor.vue | 192 ++++++++++++------ src/views/system/components/SystemCard.vue | 4 - 7 files changed, 235 insertions(+), 94 deletions(-) diff --git a/src/apis/energy/api.js b/src/apis/energy/api.js index 5931055..d9a94ba 100644 --- a/src/apis/energy/api.js +++ b/src/apis/energy/api.js @@ -5,3 +5,5 @@ export const GET_TAI_POWER_API = `/api/Energe/GetTaipower`; export const GET_SIDEBAR_API = `/api/Energe/GetEnergySideBar`; export const GET_SEARCH_API = `/api/Energe/GetFilter`; +export const GET_REPORT_API = `/api/Energe/GetReport`; + diff --git a/src/apis/energy/index.js b/src/apis/energy/index.js index 927e72b..a615b03 100644 --- a/src/apis/energy/index.js +++ b/src/apis/energy/index.js @@ -4,6 +4,7 @@ import { GET_TAI_POWER_API, GET_SIDEBAR_API, GET_SEARCH_API, + GET_REPORT_API, } from "./api"; import instance from "@/util/request"; import apihandler from "@/util/apihandler"; @@ -52,3 +53,26 @@ export const getEnergySearch = async (type) => { code: res.code, }); }; + +export const getReport = async ({ + department, + elecType, + floor, + start_time, + end_time, + type, +}) => { + const res = await instance.post(GET_REPORT_API, { + department, + elecType, + floor, + start_time, + end_time, + type, + }); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; diff --git a/src/views/energyManagement/components/EnergyReport/EnergyReportSearch.vue b/src/views/energyManagement/components/EnergyReport/EnergyReportSearch.vue index aa5a7aa..55096a9 100644 --- a/src/views/energyManagement/components/EnergyReport/EnergyReportSearch.vue +++ b/src/views/energyManagement/components/EnergyReport/EnergyReportSearch.vue @@ -8,7 +8,7 @@ import { getAssetFloorList, getElecTypeList, } from "@/apis/asset"; -import { getAccountUserList } from "@/apis/account"; +import { getReport } from "@/apis/energy"; import { useI18n } from "vue-i18n"; const { t } = useI18n(); const route = useRoute(); @@ -78,7 +78,7 @@ const getFloor = async () => { const onSearch = async () => { loading.value = true; - const res = await getAccountUserList(formState.value); + const res = await getReport(formState.value); tableData.value = res.data; loading.value = false; }; @@ -114,7 +114,7 @@ watch( watch( () => route.params.type, (newVal) => { - formState.value.type = newVal; + formState.value.type = Number(newVal); }, { immediate: true } ); diff --git a/src/views/energyManagement/components/EnergyReport/EnergyReportTable.vue b/src/views/energyManagement/components/EnergyReport/EnergyReportTable.vue index 8f2e893..75076c8 100644 --- a/src/views/energyManagement/components/EnergyReport/EnergyReportTable.vue +++ b/src/views/energyManagement/components/EnergyReport/EnergyReportTable.vue @@ -1,33 +1,91 @@ - + \ No newline at end of file diff --git a/src/views/system/System.vue b/src/views/system/System.vue index abea7f9..dca1f24 100644 --- a/src/views/system/System.vue +++ b/src/views/system/System.vue @@ -157,12 +157,17 @@ const updateCurrentFloor = (floor) => { const realtimeData = ref([]) const timeId = ref(null) -const getAllDeviceRealtime = () => { - timeId.value = setInterval(async () => { - const res = await getSystemRealTime(subscribeData.value.map(d => d.device_number)) - console.log(res.data) - realtimeData.value = res.data - }, 10000) +const getAllDeviceRealtime = async () => { + // 立即執行一次 + const fetchData = async () => { + const res = await getSystemRealTime(subscribeData.value.map(d => d.device_number)); + console.log(res.data); + realtimeData.value = res.data; + }; + await fetchData(); // 立即執行一次 + + // 然後設定每 10 秒更新一次 + timeId.value = setInterval(fetchData, 10000); } watch(subscribeData, (newValue) => { @@ -206,9 +211,7 @@ const getCurrentInfoModalData = async (e, position, value) => { : "", }; } - - const immediateRes = await getSystemRealTime([value.device_number]); - realtimeData.value = immediateRes.data; + } const mobile = isMobile(e); selectedDevice.value = { diff --git a/src/views/system/SystemFloor.vue b/src/views/system/SystemFloor.vue index a7153b8..e3eb0c0 100644 --- a/src/views/system/SystemFloor.vue +++ b/src/views/system/SystemFloor.vue @@ -1,14 +1,16 @@ - + diff --git a/src/views/system/components/SystemCard.vue b/src/views/system/components/SystemCard.vue index dae5cfa..75d15c7 100644 --- a/src/views/system/components/SystemCard.vue +++ b/src/views/system/components/SystemCard.vue @@ -10,10 +10,6 @@ const FILE_BASEURL = import.meta.env.VITE_FILE_API_BASEURL; 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; - };