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 = () => {