From c8e00421b2660d096efa6b3127f7dfac213d69a5 Mon Sep 17 00:00:00 2001 From: ko1234 Date: Tue, 1 Apr 2025 10:22:13 +0800 Subject: [PATCH] =?UTF-8?q?navbar=E3=80=81=E5=91=8A=E8=AD=A6=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=80=81=E8=B3=87=E7=94=A2=E7=AE=A1=E7=90=86=E3=80=81?= =?UTF-8?q?=E9=81=8B=E7=B6=AD=E7=AE=A1=E7=90=86=E3=80=81mqtt=20=E5=8A=A0?= =?UTF-8?q?=E4=B8=8Abuilding=5Fguid=20|=20=E8=B3=87=E7=94=A2=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=B0=8F=E9=A1=9E=E8=83=BD=E4=B8=8A=E5=82=B3=E5=9C=96?= =?UTF-8?q?=E7=89=87=20|=20=E9=A6=96=E9=A0=81=E9=A1=AF=E7=A4=BA=E5=B0=8F?= =?UTF-8?q?=E9=A1=9Eicon=20|=20=E8=83=BD=E6=BA=90=E7=AE=A1=E7=90=86=20:=20?= =?UTF-8?q?=E5=8D=B3=E6=99=82=E9=9C=80=E9=87=8F=E4=B8=B2=E6=8E=A5api=20?= =?UTF-8?q?=E3=80=81=20=E5=9C=96=E8=A1=A8=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E3=80=81=E6=96=B0=E5=A2=9E=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E8=88=87=E6=99=82=E9=96=93=E5=8D=80=E9=96=93=20|=20=E7=B3=BB?= =?UTF-8?q?=E7=B5=B1=E7=9B=A3=E6=8E=A7=E5=8A=A0=E4=B8=8A=E9=83=A8=E9=96=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/alert/index.js | 8 +- src/apis/asset/index.js | 21 +- src/apis/building/index.js | 6 +- src/apis/energy/api.js | 1 + src/apis/energy/index.js | 10 + src/apis/system/index.js | 8 +- src/components/navbar/NavbarItem.vue | 8 +- .../components/AssetMainList.vue | 16 +- .../components/AssetMainListAddModal.vue | 4 + .../components/AssetSubList.vue | 49 ++-- .../components/AssetSubListAddModal.vue | 91 ++++---- .../components/AlertSetting/AlertSubList.vue | 17 +- .../dashboard/components/DashboardSysCard.vue | 15 +- .../EnergyChart/ImmediateDemandChart.vue | 216 ++++++++++-------- .../EnergyChart/IntervalBillChart.vue | 6 +- .../EnergyHistoryTable/EnergyDataCahrt.vue | 11 +- .../EnergyHistoryTable/EnergySidebar.vue | 4 +- .../history/components/HistorySearchTime.vue | 6 +- .../components/OperationSearchSubSys.vue | 16 +- src/views/setting/components/MQTTList.vue | 16 +- src/views/system/System.vue | 19 +- src/views/system/components/SystemDeptBar.vue | 7 +- 22 files changed, 345 insertions(+), 210 deletions(-) diff --git a/src/apis/alert/index.js b/src/apis/alert/index.js index edce98d..8e279e8 100644 --- a/src/apis/alert/index.js +++ b/src/apis/alert/index.js @@ -65,8 +65,12 @@ export const postOperationRecord = async (formData) => { }); }; -export const getAlertSubList = async () => { - const res = await instance.post(GET_ALERT_SUB_LIST_API, {}); +export const getAlertSubList = async ( + building_guid +) => { + const res = await instance.post(GET_ALERT_SUB_LIST_API, { + building_guid + }); return apihandler(res.code, res.data, { msg: res.msg, diff --git a/src/apis/asset/index.js b/src/apis/asset/index.js index 12a3dc1..e124482 100644 --- a/src/apis/asset/index.js +++ b/src/apis/asset/index.js @@ -31,8 +31,8 @@ import instance from "@/util/request"; import apihandler from "@/util/apihandler"; import { object } from "yup"; -export const getAssetMainList = async () => { - const res = await instance.post(GET_ASSET_MAIN_LIST_API); +export const getAssetMainList = async (building_guid) => { + const res = await instance.post(GET_ASSET_MAIN_LIST_API,{building_guid}); return apihandler(res.code, res.data, { msg: res.msg, @@ -49,11 +49,12 @@ export const deleteAssetMainItem = async (id) => { }); }; -export const postAssetMainList = async ({ id, system_key, system_value }) => { +export const postAssetMainList = async ({ id, system_key, system_value, building_guid }) => { const res = await instance.post(POST_ASSET_MAIN_LIST_API, { id, system_key, system_value, + building_guid }); return apihandler(res.code, res.data, { @@ -71,18 +72,8 @@ export const getAssetSubList = async (id) => { }); }; -export const postAssetSubList = async ({ - system_key, - system_value, - system_parent_id, - id, -}) => { - const res = await instance.post(POST_ASSET_SUB_LIST_API, { - system_key, - system_value, - system_parent_id, - id, - }); +export const postAssetSubList = async (formData) => { + const res = await instance.post(POST_ASSET_SUB_LIST_API, formData); return apihandler(res.code, res.data, { msg: res.msg, diff --git a/src/apis/building/index.js b/src/apis/building/index.js index 559820b..0c3579e 100644 --- a/src/apis/building/index.js +++ b/src/apis/building/index.js @@ -49,10 +49,8 @@ export const getAuth = async (lang) => { }); }; -export const getAllSysSidebar = async () => { - const res = await instance.post(GET_SUBAUTHPAGE_API, { - building_tag: "", - }); +export const getAllSysSidebar = async (building_guid) => { + const res = await instance.post(GET_SUBAUTHPAGE_API, {building_guid}); return apihandler(res.code, res.data, { msg: res.msg, code: res.code, diff --git a/src/apis/energy/api.js b/src/apis/energy/api.js index b10f171..9f427a0 100644 --- a/src/apis/energy/api.js +++ b/src/apis/energy/api.js @@ -12,6 +12,7 @@ export const GET_Excel_API = `/api/Energe/GetReportExcel`; export const GET_DEMAND_API = `/api/Energe/SearchDemandValue`; export const POST_ADD_DEMAND_API = `/api/Energe/AddDemandValue`; export const POST_EDIT_DEMAND_API = `/api/Energe/UpdateDemandValue`; +export const GET_REALTIME_DEMAND_API = `/api/Energe/GetRealTimeDemand`; // 碳排係數 export const GET_CARBON_API = `/api/Energe/SearchCarbonValue`; diff --git a/src/apis/energy/index.js b/src/apis/energy/index.js index 7bb4eba..1e7057c 100644 --- a/src/apis/energy/index.js +++ b/src/apis/energy/index.js @@ -8,6 +8,7 @@ import { GET_Excel_API, GET_DEMAND_API, POST_EDIT_DEMAND_API, + GET_REALTIME_DEMAND_API, GET_CARBON_API, POST_EDIT_CARBON_API, GET_TIME_ELEC_API, @@ -199,6 +200,15 @@ export const postEditCarbonValue = async ({ }); }; +export const getRealTimeDemand = async (building_guid) => { + const res = await instance.post(GET_REALTIME_DEMAND_API, { building_guid }); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; + export const getTimeElec = async (building_guid) => { const res = await instance.post(GET_TIME_ELEC_API, { building_guid }); diff --git a/src/apis/system/index.js b/src/apis/system/index.js index 4810014..900ac6d 100644 --- a/src/apis/system/index.js +++ b/src/apis/system/index.js @@ -20,13 +20,13 @@ export const getSystemFloors = async (building_tag, sub_system_tag) => { export const getSystemDevices = async ({ sub_system_tag, - building_tag, - floor_tag, + building_guid, + department_id_list, }) => { const res = await instance.post(GET_SYSTEM_DEVICE_LIST_API, { sub_system_tag, - building_tag, - floor_tag, + building_guid, + department_id_list, }); return apihandler(res.code, res.data, { diff --git a/src/components/navbar/NavbarItem.vue b/src/components/navbar/NavbarItem.vue index 2ad7d4b..245aa17 100644 --- a/src/components/navbar/NavbarItem.vue +++ b/src/components/navbar/NavbarItem.vue @@ -37,8 +37,8 @@ const authPages = computed(() => ); const open = ref(false); -const getSubMonitorPage = async (building) => { - const res = await getAllSysSidebar(); +const getSubMonitorPage = async (building_guid) => { + const res = await getAllSysSidebar(building_guid); buildingStore.mainSubSys = res.data.history_Main_Systems; menu_array.value = res.data.history_Main_Systems; }; @@ -48,7 +48,7 @@ const getSubPage = async (system_type) => { }; const showDrawer = async (authCode) => { if (authCode === "PF1") { - await getSubMonitorPage(); + await getSubMonitorPage(buildingStore.selectedBuilding.building_guid); } else if (authCode === "PF2" || authCode === "PF11") { await getSubPage(authCode === "PF2" ? "Energy" : "Setting"); } @@ -71,7 +71,7 @@ watch( () => buildingStore.selectedBuilding, (newVal) => { if (newVal !== null) { - getSubMonitorPage(newVal.building_tag); + getSubMonitorPage(newVal.building_guid); } } ); diff --git a/src/views/AssetManagement/components/AssetMainList.vue b/src/views/AssetManagement/components/AssetMainList.vue index 85e96cf..7fdfb49 100644 --- a/src/views/AssetManagement/components/AssetMainList.vue +++ b/src/views/AssetManagement/components/AssetMainList.vue @@ -5,6 +5,8 @@ import { ref, onMounted, watch, inject } from "vue"; import useSearchParam from "@/hooks/useSearchParam"; import useActiveBtn from "@/hooks/useActiveBtn"; import { useI18n } from "vue-i18n"; +import useBuildingStore from "@/stores/useBuildingStore"; +const store = useBuildingStore(); const { t } = useI18n(); const { searchParams, changeParams } = useSearchParam(); const { items, changeActiveBtn, setItems, selectedBtn } = useActiveBtn(); @@ -17,7 +19,7 @@ const formState = ref({ }); const getMainSystems = async () => { - const res = await getAssetMainList(); + const res = await getAssetMainList(store.selectedBuilding.building_guid); const cate = res.data.map((d, index) => ({ ...d, title: d.system_key, @@ -60,9 +62,15 @@ const deleteItem = async (id) => { }); }; -onMounted(() => { - getMainSystems(); -}); +watch( + () => store.selectedBuilding, + (newBuilding) => { + if (newBuilding) { + getMainSystems(); + } + }, + { immediate: true } +); watch(selectedBtn, (newValue) => { changeParams({ diff --git a/src/views/AssetManagement/components/AssetMainListAddModal.vue b/src/views/AssetManagement/components/AssetMainListAddModal.vue index 7d01386..6804bf6 100644 --- a/src/views/AssetManagement/components/AssetMainListAddModal.vue +++ b/src/views/AssetManagement/components/AssetMainListAddModal.vue @@ -3,8 +3,11 @@ import { ref, defineProps, inject } from "vue"; import * as yup from "yup"; import useFormErrorMessage from "@/hooks/useFormErrorMessage"; import { postAssetMainList } from "@/apis/asset"; +import useBuildingStore from "@/stores/useBuildingStore"; import useSearchParam from "@/hooks/useSearchParam"; import { useI18n } from "vue-i18n"; + +const storeBuild = useBuildingStore(); const { t } = useI18n(); const { openToast } = inject("app_toast"); const { searchParams, changeParams } = useSearchParam(); @@ -30,6 +33,7 @@ const onOk = async () => { const res = await postAssetMainList({ ...props.formState, id: props.formState ? props.formState.id : 0, + building_guid:storeBuild.selectedBuilding?.building_guid || null, }); if (res.isSuccess) { diff --git a/src/views/AssetManagement/components/AssetSubList.vue b/src/views/AssetManagement/components/AssetSubList.vue index c6908e7..ea7e847 100644 --- a/src/views/AssetManagement/components/AssetSubList.vue +++ b/src/views/AssetManagement/components/AssetSubList.vue @@ -45,21 +45,41 @@ watch( deep: true, } ); +const formState = ref({ + id: 0, + system_key: "", + system_value: "", + system_parent_id: 0, + file: [], +}); -const editRecord = ref(null); -// 編輯 modal -const openModal = () => { + + +const openModal = (item) => { + if (item.id) { + formState.value = { ...item }; + + if (item.device_image) { + const subFile = item + ? { + name: item.device_image, + src: item.device_image, + ext: item.device_image?.split(".")[1], + } + : {}; + formState.value.file = [subFile]; + } + } else { + formState.value = { + id: 0, + system_key: "", + system_value: "", + system_parent_id: 0, + file: [], + }; + } asset_add_sub_item.showModal(); }; -const onCancel = () => { - editRecord.value = null; - asset_add_sub_item.close(); -}; - -const edit = (item) => { - editRecord.value = item; - openModal(); -}; const deleteItem = async (id) => { openToast("warning", t("msg.sure_to_delete"), "body", async () => { @@ -83,9 +103,8 @@ const deleteItem = async (id) => {