From a0ac379b28daeac8deddfae34f0015935a811bac Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期五, 07 二月 2025 17:39:47 +0800
Subject: [PATCH] 修改细分网格的展示逻辑

---
 src/stores/satellite-grid.js                        |    2 
 src/views/satellitetelemetry/SatelliteTelemetry.vue |   56 ++++++++++++++++++++++++++--
 src/api/index.js                                    |    3 +
 src/utils/map/grid.js                               |    2 
 src/views/satellitetelemetry/SatelliteProxy.js      |   19 +++++++--
 5 files changed, 71 insertions(+), 11 deletions(-)

diff --git a/src/api/index.js b/src/api/index.js
index e90dd06..48b2de8 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -10,7 +10,8 @@
 }
 
 if (debug) {
-  ip1 = 'http://192.168.0.138:8084/';
+  // ip1 = 'http://192.168.0.138:8084/';
+  ip1 = 'http://localhost:8084/';
 }
 
 const $http = axios.create({
diff --git a/src/stores/satellite-grid.js b/src/stores/satellite-grid.js
index 6f73012..ef778cd 100644
--- a/src/stores/satellite-grid.js
+++ b/src/stores/satellite-grid.js
@@ -12,7 +12,7 @@
   // 鍘熷缃戞牸鏁版嵁缁�
   const gridDataList = computed(() => {
     return allGridDataList.value.filter((v) => {
-      return v.type == 0;
+      return v.type != 1;
     });
   });
   // 铻嶅悎缃戞牸鏁版嵁缁�
diff --git a/src/utils/map/grid.js b/src/utils/map/grid.js
index 7f37bf6..a3d8d08 100644
--- a/src/utils/map/grid.js
+++ b/src/utils/map/grid.js
@@ -224,7 +224,7 @@
         textViews[i].setPosition(p.lnglat_GD);
         textViews[i].setText(p.data);
       });
-      return textViews;
+      return { textViews };
     } else {
       const _textViews = [];
       points.forEach((p) => {
diff --git a/src/views/satellitetelemetry/SatelliteProxy.js b/src/views/satellitetelemetry/SatelliteProxy.js
index 7b7f8cf..51334eb 100644
--- a/src/views/satellitetelemetry/SatelliteProxy.js
+++ b/src/views/satellitetelemetry/SatelliteProxy.js
@@ -14,8 +14,19 @@
 }
 
 function clearText(mapViews) {
-  if (mapViews && typeof mapViews.textViews === 'object') {
-    map.remove(mapViews.textViews);
+  if (mapViews) {
+    if (typeof mapViews.dataTxt === 'object') {
+      map.remove(mapViews.dataTxt);      
+    }
+    if (typeof mapViews.dataLayer === 'object') {
+      map.remove(mapViews.dataLayer);      
+    }
+    if (typeof mapViews.rankTxt === 'object') {
+      map.remove(mapViews.rankTxt);      
+    }
+    if (typeof mapViews.rankLayer === 'object') {
+      map.remove(mapViews.rankLayer);      
+    }
   }
 }
 
@@ -23,8 +34,8 @@
 function drawPolyline(gridInfo) {
   // 缁樺埗缃戞牸
   const points = gridInfo.map((v) => {
-    // return calculate.wgs84_To_Gcj02(v.longitude, v.latitude);
-    return [v.longitude, v.latitude];
+    return calculate.wgs84_To_Gcj02(v.longitude, v.latitude);
+    // return [v.longitude, v.latitude];
   });
   // const gridPoints = gridMapUtil.parseGridPoint(points);
   // console.log('gridPoints:', gridPoints);
diff --git a/src/views/satellitetelemetry/SatelliteTelemetry.vue b/src/views/satellitetelemetry/SatelliteTelemetry.vue
index 66ed9cc..bcbba00 100644
--- a/src/views/satellitetelemetry/SatelliteTelemetry.vue
+++ b/src/views/satellitetelemetry/SatelliteTelemetry.vue
@@ -1,6 +1,24 @@
 <template>
   <el-row class="wrap">
     <el-col span="2">
+      <!-- <div class="p-events-auto">
+        <el-button
+          type="primary"
+          class="el-button-custom"
+          size="small"
+          @click="previousGrid"
+        >
+          涓婁竴涓�
+        </el-button>
+        <el-button
+          type="primary"
+          class="el-button-custom"
+          size="small"
+          @click="nextGrid"
+        >
+          涓嬩竴涓�
+        </el-button>
+      </div> -->
       <el-row>
         <SatelliteManage
           v-show="show"
@@ -41,7 +59,7 @@
 import marks from '@/utils/map/marks';
 import grid from '@/utils/map/grid';
 
-import { ref } from 'vue';
+import { ref, onMounted } from 'vue';
 import gridApi from '@/api/gridApi';
 import SatelliteManage from './component/SatelliteManage.vue';
 import SatelliteDataMix from './component/SatelliteDataMix.vue';
@@ -49,9 +67,19 @@
 import { useFetchData } from '@/composables/fetchData';
 import { useSatelliteGridStore } from '@/stores/satellite-grid';
 
+// onMounted(() => {
+//   initDistrict();
+// });
 // 鏌ヨ闀垮畞鍖鸿鏀垮尯鍒�
+let polygon;
 function initDistrict() {
   onMapMounted(() => {
+    if (polygon) {
+      map.remove(polygon);
+      map.add(polygon);
+      map.setFitView();
+      return
+    }
     // eslint-disable-next-line no-undef
     var district = new AMap.DistrictSearch({
       extensions: 'all', //杩斿洖琛屾斂鍖鸿竟鐣屽潗鏍囩瓑鍏蜂綋淇℃伅
@@ -63,7 +91,7 @@
         for (var i = 0; i < bounds.length; i++) {
           //鐢熸垚琛屾斂鍖哄垝 polygon
           // eslint-disable-next-line no-undef
-          var polygon = new AMap.Polygon({
+          polygon = new AMap.Polygon({
             map: map, //鏄剧ず璇ヨ鐩栫墿鐨勫湴鍥惧璞�
             strokeWeight: 3, //杞粨绾垮搴�
             path: bounds[i], //澶氳竟褰㈣疆寤撶嚎鐨勮妭鐐瑰潗鏍囨暟缁�
@@ -95,8 +123,9 @@
 // 鏌ヨ缃戞牸淇℃伅鍜岄仴鎰熸暟鎹粍
 function onSearch(options) {
   satelliteGridStore.fetchGridCell(options.id).then(() => {
+    SatelliteProxy.clearText(mapViews);
     drawGrid(satelliteGridStore.gridInfo);
-    initDistrict();
+    initDistrict()
   });
   satelliteGridStore.fetchGridData(options.id).then(() => {
     max = satelliteGridStore.gridDataList.length;
@@ -134,11 +163,30 @@
 function drawGrid(gridInfo) {
   SatelliteProxy.clearAll(mapViews);
   mapViews = SatelliteProxy.drawPolyline(gridInfo);
+  // mapViews = SatelliteProxy.drawPolyline([gridInfo[0]]);
+}
+
+let index = 0;
+function previousGrid() {
+  index--;
+  if (index < 0) {
+    index = 0;
+  }
+  SatelliteProxy.clearAll(mapViews);
+  mapViews = SatelliteProxy.drawPolyline([satelliteGridStore.gridInfo[index]]);
+}
+
+function nextGrid() {
+  index++;
+  if (index > satelliteGridStore.gridInfo.length - 1) {
+    index = satelliteGridStore.gridInfo.length - 1;
+  }
+  SatelliteProxy.clearAll(mapViews);
+  mapViews = SatelliteProxy.drawPolyline([satelliteGridStore.gridInfo[index]]);
 }
 
 // 缁樺埗缃戞牸閬ユ劅鏁版嵁鍊煎拰缃戞牸棰滆壊
 function drawTextAndColor(gridData) {
-  // SatelliteProxy.clearText(mapViews);
   // 鏂囨湰鏍囪
   const { textViews: dataTxt, labelsLayer: dataLayer } =
     SatelliteProxy.drawDataText(

--
Gitblit v1.9.3