Forráskód Böngészése

修复故障报警点击查看不居中的问题和报警列表数据编号显示错误的问题;

画安 3 hete%!(EXTRA string=óta)
szülő
commit
c486035dd4

+ 1 - 1
src/components/ui/AlarmMessageList.vue

@@ -7,7 +7,7 @@
         <div class="alarm-item" v-for="(item, index) in listData" :key="item.id + '-' + index">
             <div class="item-header">
                 <span class="title" :class="getTitleClass(item.type)">
-                    {{index + 1}}.{{ item.title }}
+                    {{ (item._originalIndex != null ? item._originalIndex : index) + 1 }}.{{ item.title }}
                 </span>
                 <span class="time" v-if="item.time">{{ item.time }}</span>
             </div>

+ 8 - 3
src/components/ui/SeamlessScroll.vue

@@ -25,14 +25,19 @@ export default {
     scrollData() {
       if (this.data && this.data.length > this.limit) {
         this.isScrollable = true;
+        const original = this.data.map((item, index) => ({
+          ...item,
+          _originalIndex: index
+        }));
         const clone = JSON.parse(JSON.stringify(this.data)).map((item, index) => ({
           ...item,
-          _clone_id: `clone_${Date.now()}_${index}`
+          _clone_id: `clone_${Date.now()}_${index}`,
+          _originalIndex: index
         }));
-        return [...this.data, ...clone];
+        return [...original, ...clone];
       }
       this.isScrollable = false;
-      return this.data; 
+      return this.data.map((item, index) => ({ ...item, _originalIndex: index }));
     }
   },
   // 加入 mounted 钩子,确保 DOM 绝对渲染完毕再测算

+ 17 - 12
src/views/Home.vue

@@ -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 }) {