diff --git a/src/views/AssetManagement/components/AssetTableModalRightInfo.vue b/src/views/AssetManagement/components/AssetTableModalRightInfo.vue index f4a86c2..4ab70c0 100644 --- a/src/views/AssetManagement/components/AssetTableModalRightInfo.vue +++ b/src/views/AssetManagement/components/AssetTableModalRightInfo.vue @@ -36,14 +36,25 @@ 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); + } catch (e) { + console.warn('解析 device_coordinate 失敗:', e); + } + } + return { name: coordString, value: coordinate, itemStyle: { - color: - coordString === formState.value.device_coordinate - ? "#0000FF" - : "#b02a02", + color: isSelected ? "#0000FF" : "#b02a02", }, }; }); @@ -117,7 +128,7 @@ const getCoordinate = (position) => {