|
|
@@ -226,24 +226,29 @@ export default {
|
|
|
// 处理查看逻辑
|
|
|
onAlarmView({ item, index }) {
|
|
|
console.log('点击了查看:', item);
|
|
|
- // 处理索引,确保即使点击克隆数据也能正确映射到原始12个点位
|
|
|
- const actualIndex = index % 12;
|
|
|
- // 从localStorage获取对应的位置信息
|
|
|
- const positionStr = localStorage.getItem(`pos${actualIndex + 1}`);
|
|
|
+
|
|
|
let position;
|
|
|
-
|
|
|
- if (!positionStr) {
|
|
|
- console.warn('未找到对应的位置信息,使用默认位置');
|
|
|
- // 使用默认坐标(通州区中心)
|
|
|
- position = ['116.663', '39.905'];
|
|
|
+
|
|
|
+ // 优先使用 item 自身携带的坐标(最可靠,不受索引偏移影响)
|
|
|
+ if (item.position && item.position.length === 2) {
|
|
|
+ position = [Number(item.position[0]), Number(item.position[1])];
|
|
|
} else {
|
|
|
- position = positionStr.split(',');
|
|
|
+ // 兜底:通过索引从 localStorage 查找
|
|
|
+ const actualIndex = index % 12;
|
|
|
+ const positionStr = localStorage.getItem(`pos${actualIndex + 1}`);
|
|
|
+ if (positionStr) {
|
|
|
+ const parts = positionStr.split(',');
|
|
|
+ position = [Number(parts[0]), Number(parts[1])];
|
|
|
+ } else {
|
|
|
+ console.warn('未找到对应的位置信息,使用默认位置');
|
|
|
+ position = [116.663, 39.905];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 地图联动
|
|
|
console.log(position);
|
|
|
-
|
|
|
- this.$refs.trafficMapRef.focusByLocation([Number(position[0]), Number(position[1])]);
|
|
|
+
|
|
|
+ this.$refs.trafficMapRef.focusByLocation(position);
|
|
|
|
|
|
},
|
|
|
onIntersectionRowClick({ row, index }) {
|