Selaa lähdekoodia

干线协调数据统一为6条,地图绘制与菜单信息保持一致

  1. 地图干线配置(realRouteConfigs)从5条改为6条,起终点与菜单points对应,
     每条配置新增trunkId和trunkName字段
  2. 干线每条路线只取最长拆段(slice(0,1)),确保6条配置=地图6条线
  3. trunkSegments按lineIdx生成菜单项,不再按polyline数量重复计数
  4. 干线marker的road字段统一使用干线名称(如"古城南路与古城大街"),
     与菜单标题一致
  5. 菜单数据(trunkLineMenuTree)从9条删减到6条,第6条改名"张台路与湖亦路路口"
  6. 三个页面(StatusMonitoring/TrunkCoordination/SpecialSituationMonitoring)
     统一更新findTrunkMenuNode匹配逻辑,支持新的trunk_X_point_Y格式ID,
     地图点击和菜单点击使用相同弹窗ID避免重复弹窗
画安 2 viikkoa sitten
vanhempi
commit
a340fdce10

+ 30 - 26
src/components/TongzhouTrafficMap.vue

@@ -313,11 +313,12 @@ export default {
 
       const realRouteConfigs = {
         "干线协调": [
-          { start: [116.6421, 39.9272], end: [116.6825, 39.9272], color: "#13C373" },
-          { start: [116.6426, 39.9221], end: [116.6830, 39.9221], color: "#13C373" },
-          { start: [116.6432, 39.9171], end: [116.6833, 39.9171], color: "#13C373" },
-          { start: [116.6438, 39.9123], end: [116.6841, 39.9123], color: "#13C373" },
-          { start: [116.6445, 39.9075], end: [116.6846, 39.9075], color: "#13C373" }
+          { start: [116.6421, 39.9272], end: [116.6623, 39.9272], color: "#13C373", trunkId: 'trunk_1', trunkName: '古城南路与古城大街' },
+          { start: [116.6623, 39.9272], end: [116.6825, 39.9272], color: "#13C373", trunkId: 'trunk_2', trunkName: '古城西路东口南一过街' },
+          { start: [116.6426, 39.9221], end: [116.6628, 39.9221], color: "#13C373", trunkId: 'trunk_3', trunkName: '古城大街与古城北路' },
+          { start: [116.6628, 39.9221], end: [116.683, 39.9221], color: "#13C373", trunkId: 'trunk_4', trunkName: '八角北路与八角东街' },
+          { start: [116.6432, 39.9171], end: [116.66325, 39.9171], color: "#13C373", trunkId: 'trunk_5', trunkName: '古城西路与古城大街' },
+          { start: [116.66325, 39.9171], end: [116.6833, 39.9171], color: "#13C373", trunkId: 'trunk_6', trunkName: '张台路与湖亦路路口' },
         ],
         "勤务路线": [
           // 第一段:未执行(全红)— 通州大街西段,干线协调下方约600m
@@ -371,25 +372,16 @@ export default {
             path
           });
 
-          // 统计干线协调实际生成的线段数
+          // 每条路线配置对应一条干线菜单项
           if (config.name === '干线协调' && overlays.length > 0) {
-            const trunkNames = [
-              '古城南路与古城大街', '古城西路东口南一过街', '古城大街与古城北路',
-              '八角北路与八角东街', '古城西路与古城大街'
-            ];
-            const polylineCount = overlays.filter(o => o instanceof this.AMap.Polyline).length;
-            for (let s = 0; s < polylineCount; s++) {
-              const idx = trunkSegments.length + 1;
-              const name = trunkNames[idx - 1] || ('干线' + idx);
-              trunkSegments.push({
-                id: 'trunk_' + idx,
-                label: name,
-                intersections: Array.from({ length: 6 }, (_, k) => name + '_路口' + (k + 1)),
-                distances: Array.from({ length: 6 }, (_, k) => k * 1000),
-                _lineIdx: lineIdx,
-                _segmentIdx: s
-              });
-            }
+            const name = line.trunkName || ('干线' + (lineIdx + 1));
+            trunkSegments.push({
+              id: line.trunkId || ('trunk_' + (lineIdx + 1)),
+              label: name,
+              intersections: Array.from({ length: 6 }, (_, k) => name + '_路口' + (k + 1)),
+              distances: Array.from({ length: 6 }, (_, k) => k * 500),
+              _lineIdx: lineIdx
+            });
           }
 
           if (this.isComponentDestroyed || drawSeq !== this.drawSeq) return;
@@ -500,7 +492,11 @@ export default {
         return [lng + offsetVal, lat + offsetVal];
       };
 
-      const segments = this.extractMainStraightSegments(basePath);
+      const allSegments = this.extractMainStraightSegments(basePath);
+      // 干线协调每条路线只取最长的1段,保证6条配置 = 6条线
+      const segments = configName === '干线协调'
+        ? allSegments.slice(0, 1)
+        : allSegments;
       const overlays = [];
 
       segments.forEach((rawSegmentPath, segmentIdx) => {
@@ -693,10 +689,18 @@ export default {
               else if (i === indices.length - 1) markerType = 'end';
             }
 
+            // 干线协调:id 用干线编号,road 用干线名称(与菜单标题一致)
+            const markerId = (configName === '干线协调' && line.trunkId)
+              ? `${line.trunkId}_point_${i + 1}`
+              : `MOCK-${configName.charAt(0)}-${lineIdx}-${segmentIdx}-${idx}`;
+            const markerRoad = (configName === '干线协调' && line.trunkName)
+              ? line.trunkName
+              : `${configName}路口-${lineIdx}-${segmentIdx}-${idx}`;
+
             const marker = this.createTrafficLightMarker([lng, lat], {
               ...config,
-              id: `MOCK-${configName.charAt(0)}-${lineIdx}-${segmentIdx}-${idx}`,
-              road: `${configName}路口-${lineIdx}-${segmentIdx}-${idx}`
+              id: markerId,
+              road: markerRoad
             }, markerType);
             if (marker) overlays.push(marker);
           }

+ 1 - 175
src/mock/mock_data.json

@@ -30015,7 +30015,7 @@
                 },
                 {
                   "id": "trunk_6",
-                  "label": "干线6",
+                  "label": "张台路与湖亦路路口",
                   "intersections": [
                     "干线6_路口1",
                     "干线6_路口2",
@@ -30070,180 +30070,6 @@
                       "lat": 39.9171
                     }
                   ]
-                },
-                {
-                  "id": "trunk_7",
-                  "label": "干线7",
-                  "intersections": [
-                    "干线7_路口1",
-                    "干线7_路口2",
-                    "干线7_路口3",
-                    "干线7_路口4",
-                    "干线7_路口5",
-                    "干线7_路口6"
-                  ],
-                  "distances": [
-                    0,
-                    500,
-                    1000,
-                    1500,
-                    2000,
-                    2500
-                  ],
-                  "points": [
-                    {
-                      "id": "GX007001",
-                      "label": "干线7_路口1",
-                      "lng": 116.6438,
-                      "lat": 39.9123
-                    },
-                    {
-                      "id": "GX007002",
-                      "label": "干线7_路口2",
-                      "lng": 116.64783,
-                      "lat": 39.9123
-                    },
-                    {
-                      "id": "GX007003",
-                      "label": "干线7_路口3",
-                      "lng": 116.65186,
-                      "lat": 39.9123
-                    },
-                    {
-                      "id": "GX007004",
-                      "label": "干线7_路口4",
-                      "lng": 116.65589,
-                      "lat": 39.9123
-                    },
-                    {
-                      "id": "GX007005",
-                      "label": "干线7_路口5",
-                      "lng": 116.65992,
-                      "lat": 39.9123
-                    },
-                    {
-                      "id": "GX007006",
-                      "label": "干线7_路口6",
-                      "lng": 116.66395,
-                      "lat": 39.9123
-                    }
-                  ]
-                },
-                {
-                  "id": "trunk_8",
-                  "label": "干线8",
-                  "intersections": [
-                    "干线8_路口1",
-                    "干线8_路口2",
-                    "干线8_路口3",
-                    "干线8_路口4",
-                    "干线8_路口5",
-                    "干线8_路口6"
-                  ],
-                  "distances": [
-                    0,
-                    500,
-                    1000,
-                    1500,
-                    2000,
-                    2500
-                  ],
-                  "points": [
-                    {
-                      "id": "GX008001",
-                      "label": "干线8_路口1",
-                      "lng": 116.66395,
-                      "lat": 39.9123
-                    },
-                    {
-                      "id": "GX008002",
-                      "label": "干线8_路口2",
-                      "lng": 116.66798,
-                      "lat": 39.9123
-                    },
-                    {
-                      "id": "GX008003",
-                      "label": "干线8_路口3",
-                      "lng": 116.67201,
-                      "lat": 39.9123
-                    },
-                    {
-                      "id": "GX008004",
-                      "label": "干线8_路口4",
-                      "lng": 116.67604,
-                      "lat": 39.9123
-                    },
-                    {
-                      "id": "GX008005",
-                      "label": "干线8_路口5",
-                      "lng": 116.68007,
-                      "lat": 39.9123
-                    },
-                    {
-                      "id": "GX008006",
-                      "label": "干线8_路口6",
-                      "lng": 116.6841,
-                      "lat": 39.9123
-                    }
-                  ]
-                },
-                {
-                  "id": "trunk_9",
-                  "label": "干线9",
-                  "intersections": [
-                    "干线9_路口1",
-                    "干线9_路口2",
-                    "干线9_路口3",
-                    "干线9_路口4",
-                    "干线9_路口5",
-                    "干线9_路口6"
-                  ],
-                  "distances": [
-                    0,
-                    500,
-                    1000,
-                    1500,
-                    2000,
-                    2500
-                  ],
-                  "points": [
-                    {
-                      "id": "GX009001",
-                      "label": "干线9_路口1",
-                      "lng": 116.6445,
-                      "lat": 39.9075
-                    },
-                    {
-                      "id": "GX009002",
-                      "label": "干线9_路口2",
-                      "lng": 116.65252,
-                      "lat": 39.9075
-                    },
-                    {
-                      "id": "GX009003",
-                      "label": "干线9_路口3",
-                      "lng": 116.66054,
-                      "lat": 39.9075
-                    },
-                    {
-                      "id": "GX009004",
-                      "label": "干线9_路口4",
-                      "lng": 116.66856,
-                      "lat": 39.9075
-                    },
-                    {
-                      "id": "GX009005",
-                      "label": "干线9_路口5",
-                      "lng": 116.67658,
-                      "lat": 39.9075
-                    },
-                    {
-                      "id": "GX009006",
-                      "label": "干线9_路口6",
-                      "lng": 116.6846,
-                      "lat": 39.9075
-                    }
-                  ]
                 }
               ]
             }

+ 4 - 5
src/views/SpecialSituationMonitoring.vue

@@ -234,7 +234,7 @@ export default {
                 pixelY: pixel ? Math.round(pixel.y / scale) : 430,
             }
             // 干线marker点击时,从菜单数据中匹配对应干线
-            if (this.activeLeftTab === 'trunkLine' && mapData.id && String(mapData.id).startsWith('MOCK-干')) {
+            if (this.activeLeftTab === 'trunkLine' && mapData.id) {
                 const matched = this.findTrunkMenuNode(mapData.id);
                 if (matched) {
                     nodeData.id = matched.id;
@@ -476,9 +476,8 @@ export default {
             this.showTrunkLineDalogs(nodeData);
         },
         findTrunkMenuNode(markerId) {
-            const parts = markerId.split('-');
-            const lineIdx = parseInt(parts[2], 10);
-            const segmentIdx = parseInt(parts[3], 10);
+            // 从 marker ID(如 trunk_1_point_3)提取干线编号(trunk_1)
+            const trunkId = String(markerId).replace(/_point_\d+$/, '');
             const leaves = [];
             const walk = (nodes) => {
                 if (!Array.isArray(nodes)) return;
@@ -488,7 +487,7 @@ export default {
                 }
             };
             walk(this.trunkLineMenuData);
-            return leaves.find(n => n._lineIdx === lineIdx && n._segmentIdx === segmentIdx) || null;
+            return leaves.find(n => n.id === trunkId) || null;
         },
         handleTrunkMenuUpdate(segments) {
             this.trunkLineMenuData = [{

+ 4 - 5
src/views/StatusMonitoring.vue

@@ -240,7 +240,7 @@ export default {
                 pixelY: pixel ? Math.round(pixel.y / scale) : 430,
             }
             // 干线marker点击时,从菜单数据中匹配对应干线
-            if (this.activeLeftTab === 'trunkLine' && mapData.id && String(mapData.id).startsWith('MOCK-干')) {
+            if (this.activeLeftTab === 'trunkLine' && mapData.id) {
                 const matched = this.findTrunkMenuNode(mapData.id);
                 if (matched) {
                     nodeData.id = matched.id;
@@ -520,9 +520,8 @@ export default {
             this.showTrunkLineDalogs(nodeData);
         },
         findTrunkMenuNode(markerId) {
-            const parts = markerId.split('-');
-            const lineIdx = parseInt(parts[2], 10);
-            const segmentIdx = parseInt(parts[3], 10);
+            // 从 marker ID(如 trunk_1_point_3)提取干线编号(trunk_1)
+            const trunkId = String(markerId).replace(/_point_\d+$/, '');
             const leaves = [];
             const walk = (nodes) => {
                 if (!Array.isArray(nodes)) return;
@@ -532,7 +531,7 @@ export default {
                 }
             };
             walk(this.trunkLineMenuData);
-            return leaves.find(n => n._lineIdx === lineIdx && n._segmentIdx === segmentIdx) || null;
+            return leaves.find(n => n.id === trunkId) || null;
         },
         handleTrunkMenuUpdate(segments) {
             this.trunkLineMenuData = [{

+ 4 - 7
src/views/TrunkCoordination.vue

@@ -234,7 +234,7 @@ export default {
                 pixelY: pixel ? Math.round(pixel.y / scale) : 430,
             }
             // 干线marker点击时,从菜单数据中匹配对应干线
-            if (this.activeLeftTab === 'trunkLine' && mapData.id && String(mapData.id).startsWith('MOCK-干')) {
+            if (this.activeLeftTab === 'trunkLine' && mapData.id) {
                 const matched = this.findTrunkMenuNode(mapData.id);
                 if (matched) {
                     nodeData.id = matched.id;
@@ -476,11 +476,8 @@ export default {
             this.showTrunkLineDalogs(nodeData);
         },
         findTrunkMenuNode(markerId) {
-            // markerId 格式: MOCK-干-{lineIdx}-{segmentIdx}-{idx}
-            const parts = markerId.split('-');
-            const lineIdx = parseInt(parts[2], 10);
-            const segmentIdx = parseInt(parts[3], 10);
-            // 从菜单叶子节点中找 _lineIdx 和 _segmentIdx 匹配的
+            // 从 marker ID(如 trunk_1_point_3)提取干线编号(trunk_1)
+            const trunkId = String(markerId).replace(/_point_\d+$/, '');
             const leaves = [];
             const walk = (nodes) => {
                 if (!Array.isArray(nodes)) return;
@@ -490,7 +487,7 @@ export default {
                 }
             };
             walk(this.trunkLineMenuData);
-            return leaves.find(n => n._lineIdx === lineIdx && n._segmentIdx === segmentIdx) || null;
+            return leaves.find(n => n.id === trunkId) || null;
         },
         handleTrunkMenuUpdate(segments) {
             this.trunkLineMenuData = [{