From 3427058cd2debb4859be0c4ac9604cab168d381c Mon Sep 17 00:00:00 2001 From: ko1234 Date: Wed, 6 Aug 2025 13:48:04 +0800 Subject: [PATCH] =?UTF-8?q?MQTT=20publish=20topic=20=E5=90=8D=E7=A8=B1?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20|=20=E7=B3=BB=E7=B5=B1=E7=9B=A3=E6=8E=A7sw?= =?UTF-8?q?itch=E5=8A=9F=E8=83=BD=20|=20=E7=B8=BD=E9=83=A8=E5=9C=B0?= =?UTF-8?q?=E5=9C=96=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 7 + package.json | 3 +- src/apis/system/api.js | 3 +- src/apis/system/index.js | 14 ++ src/stores/useBuildingStore.js | 2 +- .../components/AssetTableAddModal.vue | 19 ++- .../AssetTableModalLeftInfoMQTT.vue | 4 +- .../headquarters/HeadquartersManagement.vue | 7 +- src/views/headquarters/components/SysMap.vue | 139 ++++++++++++++++++ .../headquarters/components/SysProgress.vue | 11 +- src/views/system/System.vue | 14 +- .../components/SystemInfoModalDesktop.vue | 35 +++-- 12 files changed, 221 insertions(+), 37 deletions(-) create mode 100644 src/views/headquarters/components/SysMap.vue diff --git a/package-lock.json b/package-lock.json index 1b86ebb..f5365e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "echarts": "^5.4.3", "jquery-ui": "^1.14.1", "json-schema-generator": "^2.0.6", + "leaflet": "^1.9.4", "mqtt": "^5.10.3", "pinia": "^2.1.7", "requirejs": "^2.3.6", @@ -3350,6 +3351,12 @@ "node": ">=0.10.0" } }, + "node_modules/leaflet": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.9.4.tgz", + "integrity": "sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==", + "license": "BSD-2-Clause" + }, "node_modules/libphonenumber-js": { "version": "1.10.60", "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.60.tgz", diff --git a/package.json b/package.json index 7f18668..a0fcb0c 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dev": "vite", "build": "vite build", "preview": "vite preview", - "build:staging": "vite build --mode staging" + "build:staging": "vite build --mode staging" }, "dependencies": { "@ant-design/icons-vue": "^7.0.1", @@ -24,6 +24,7 @@ "echarts": "^5.4.3", "jquery-ui": "^1.14.1", "json-schema-generator": "^2.0.6", + "leaflet": "^1.9.4", "mqtt": "^5.10.3", "pinia": "^2.1.7", "requirejs": "^2.3.6", diff --git a/src/apis/system/api.js b/src/apis/system/api.js index a57d55f..6fb0368 100644 --- a/src/apis/system/api.js +++ b/src/apis/system/api.js @@ -1,3 +1,4 @@ export const GET_SYSTEM_FLOOR_LIST_API = `/api/Device/GetFloor`; export const GET_SYSTEM_DEVICE_LIST_API = `/api/Device/GetDeviceList`; -export const GET_SYSTEM_REALTIME_API = `/api/Device/GetRealTimeData`; \ No newline at end of file +export const GET_SYSTEM_REALTIME_API = `/api/Device/GetRealTimeData`; +export const GET_SYSTEM_DEVICE_POWER_TOGGLE_API = `/api/device-events/power-toggle`; \ No newline at end of file diff --git a/src/apis/system/index.js b/src/apis/system/index.js index 900ac6d..42d6b0e 100644 --- a/src/apis/system/index.js +++ b/src/apis/system/index.js @@ -2,6 +2,7 @@ import { GET_SYSTEM_FLOOR_LIST_API, GET_SYSTEM_DEVICE_LIST_API, GET_SYSTEM_REALTIME_API, + GET_SYSTEM_DEVICE_POWER_TOGGLE_API } from "./api"; import instance from "@/util/request"; import apihandler from "@/util/apihandler"; @@ -42,3 +43,16 @@ export const getSystemRealTime = async (device_list) => { code: res.code, }); }; + +export const toggleDevicePower = async ({topic_publish, device_item_id,new_value}) => { + const res = await instance.post(GET_SYSTEM_DEVICE_POWER_TOGGLE_API, { + topic_publish, + device_item_id, + new_value, + }); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +} diff --git a/src/stores/useBuildingStore.js b/src/stores/useBuildingStore.js index 12e670c..73df0b3 100644 --- a/src/stores/useBuildingStore.js +++ b/src/stores/useBuildingStore.js @@ -84,7 +84,7 @@ const useBuildingStore = defineStore("buildingInfo", () => { // 獲取2D、3D顯示與否 const fetchDashboard2D3D = async (BuildingId) => { const res = await getDashboard2D3D(BuildingId); - showForgeArea.value = res.data.is3DEnabled; + showForgeArea.value = res.data.is3DEnabled || false; previewImageExt.value = res.data.previewImageExt || ""; }; diff --git a/src/views/AssetManagement/components/AssetTableAddModal.vue b/src/views/AssetManagement/components/AssetTableAddModal.vue index 2a9ae93..59a0f78 100644 --- a/src/views/AssetManagement/components/AssetTableAddModal.vue +++ b/src/views/AssetManagement/components/AssetTableAddModal.vue @@ -6,7 +6,9 @@ import AssetTableModalLeft from "./AssetTableModalLeft.vue"; import AssetTableModalRight from "./AssetTableModalRight.vue"; import useFormErrorMessage from "@/hooks/useFormErrorMessage"; import * as yup from "yup"; +import { useI18n } from "vue-i18n"; +const { t } = useI18n(); const { openToast } = inject("app_toast"); const { searchParams, changeParams } = useSearchParam(); @@ -75,8 +77,11 @@ const onOk = async () => { main_id: props.editRecord ? props.editRecord.main_id : 0, }); if (res.isSuccess) { + openToast("success", t("msg.send_successfully"), "#asset_add_table_item"); props.getData(); - closeModal(); + setTimeout(() => { + closeModal(); + }, 1000); } else { openToast("error", res.msg, "#asset_add_table_item"); } @@ -102,12 +107,20 @@ const closeModal = () => {