diff --git a/src/apis/system/api.js b/src/apis/system/api.js index 10fe396..4f79543 100644 --- a/src/apis/system/api.js +++ b/src/apis/system/api.js @@ -2,4 +2,8 @@ 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`; -export const GET_SYSTEM_CONFIG_API = `/api/GetSystemConfig`; \ No newline at end of file +export const GET_SYSTEM_CONFIG_API = `/api/GetSystemConfig`; + +export const POST_MQTT_TOPIC_API = `api/Device/MQTTTopicTest`; +export const POST_MQTT_TOPIC_STOP_API = `api/Device/MQTTTopicTestStop`; + diff --git a/src/apis/system/index.js b/src/apis/system/index.js index 8dd497a..9756bdc 100644 --- a/src/apis/system/index.js +++ b/src/apis/system/index.js @@ -2,7 +2,9 @@ import { GET_SYSTEM_FLOOR_LIST_API, GET_SYSTEM_DEVICE_LIST_API, GET_SYSTEM_REALTIME_API, - GET_SYSTEM_CONFIG_API + GET_SYSTEM_CONFIG_API, + POST_MQTT_TOPIC_API, + POST_MQTT_TOPIC_STOP_API, } from "./api"; import instance from "@/util/request"; import apihandler from "@/util/apihandler"; @@ -45,3 +47,21 @@ export const getSystemConfig = async (building_guid) => { code: res.code, }); }; + +export const postMqttTopic = async ({ iotTag, Topic }) => { + const res = await instance.post(POST_MQTT_TOPIC_API, { iotTag, Topic }); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; + +export const postMqttTopicStop = async ({ iotTag, Topic }) => { + const res = await instance.post(POST_MQTT_TOPIC_STOP_API, { iotTag, Topic }); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; diff --git a/src/config/cn.json b/src/config/cn.json index cb12296..afae1a9 100644 --- a/src/config/cn.json +++ b/src/config/cn.json @@ -48,9 +48,10 @@ "this_year": "今年", "last_year": "去年", "refrig_chart": "冷藏趨勢", - "indoor_chart": "室內趨勢", + "indoor_chart": "室內", "temperature": "温度", "humidity": "湿度", + "no_data":"无数据", "alerts_data": "异常资料" }, "history": { diff --git a/src/config/tw.json b/src/config/tw.json index dc8c178..a53d1c6 100644 --- a/src/config/tw.json +++ b/src/config/tw.json @@ -47,10 +47,11 @@ "last_month": "上月", "this_year": "今年", "last_year": "去年", - "refrig_chart": "冷藏趨勢", - "indoor_chart": "室內趨勢", + "refrig_chart": "冷藏", + "indoor_chart": "室內", "temperature": "溫度", "humidity": "濕度", + "no_data": "無資料", "alerts_data": "異常資料" }, "history": { diff --git a/src/config/us.json b/src/config/us.json index 59ea94f..99a19e9 100644 --- a/src/config/us.json +++ b/src/config/us.json @@ -47,10 +47,11 @@ "last_month": "Last month", "this_year": "This year", "last_year": "Last year", - "refrig_chart": "Refrigeration chart", - "indoor_chart": "Indoor chart", + "refrig_chart": "Refrigeration", + "indoor_chart": "Indoor", "temperature": "Temp.", "humidity": "Hum.", + "no_data":"No data", "alerts_data": "Abnormal data" }, "history": { diff --git a/src/views/AssetManagement/AssetManagement.vue b/src/views/AssetManagement/AssetManagement.vue index acf2863..0bcda6b 100644 --- a/src/views/AssetManagement/AssetManagement.vue +++ b/src/views/AssetManagement/AssetManagement.vue @@ -12,13 +12,24 @@ const { searchParams, changeParams } = useSearchParam(); const companyOptions = ref([]); const iotSchemaOptions = ref([]); const elecTypeOptions = ref([]); + +const iotSchemaTag = ref(""); const getCompany = async () => { const res = await getOperationCompanyList(); companyOptions.value = res.data.map((d) => ({ ...d, key: d.id })); }; const getIOTSchemaOptions = async (id) => { const res = await getIOTSchema(Number(id)); - iotSchemaOptions.value = res.data.map((d) => ({ ...d, key: d.id })); + const data = res.data || []; + + iotSchemaOptions.value = data.map((d) => ({ ...d, key: d.id })); + + // 取出第一筆的 tagIoT,提供給最深層元件使用 + if (data.length > 0 && data[0].tagIoT) { + iotSchemaTag.value = data[0].tagIoT; + } else { + iotSchemaTag.value = ""; + } }; const getElecType = async () => { const res = await getElecTypeList(); @@ -52,6 +63,7 @@ provide("asset_modal_options", { departmentList, floors, }); +provide("iotSchemaTag", iotSchemaTag); diff --git a/src/views/AssetManagement/components/AssetTableModalRightInfo.vue b/src/views/AssetManagement/components/AssetTableModalRightInfo.vue index a8ed3e7..6689a75 100644 --- a/src/views/AssetManagement/components/AssetTableModalRightInfo.vue +++ b/src/views/AssetManagement/components/AssetTableModalRightInfo.vue @@ -34,20 +34,23 @@ const defaultOption = (map, data = []) => { // 生成坐標數據,根據坐標值的不同設置不同顏色 const formattedData = data.map((coordinate) => { const coordString = JSON.stringify(coordinate); - + // 解析 device_coordinate 為數值陣列進行比對 let isSelected = false; if (formState.value.device_coordinate) { try { const deviceCoord = JSON.parse(formState.value.device_coordinate); // 比對數值而非字串,避免精度問題 - isSelected = coordinate.length === deviceCoord.length && - coordinate.every((val, index) => Math.abs(val - deviceCoord[index]) < 0.001); + isSelected = + coordinate.length === deviceCoord.length && + coordinate.every( + (val, index) => Math.abs(val - deviceCoord[index]) < 0.001 + ); } catch (e) { - console.warn('解析 device_coordinate 失敗:', e); + console.warn("解析 device_coordinate 失敗:", e); } } - + return { name: coordString, value: coordinate, @@ -121,15 +124,15 @@ watch( const getCoordinate = (position) => { formState.value.device_coordinate = JSON.stringify(position); }; - - \ No newline at end of file +