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

---
 src/views/satellitetelemetry/SatelliteTelemetry.vue |  117 ++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 85 insertions(+), 32 deletions(-)

diff --git a/src/views/satellitetelemetry/SatelliteTelemetry.vue b/src/views/satellitetelemetry/SatelliteTelemetry.vue
index fc74865..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,33 +67,45 @@
 import { useFetchData } from '@/composables/fetchData';
 import { useSatelliteGridStore } from '@/stores/satellite-grid';
 
+// onMounted(() => {
+//   initDistrict();
+// });
 // 鏌ヨ闀垮畞鍖鸿鏀垮尯鍒�
-onMapMounted(()=>{
-  // eslint-disable-next-line no-undef
-  var district = new AMap.DistrictSearch({
-    extensions: "all", //杩斿洖琛屾斂鍖鸿竟鐣屽潗鏍囩瓑鍏蜂綋淇℃伅
-    level: "district", //璁剧疆鏌ヨ琛屾斂鍖虹骇鍒负鍖�
-  });
-  district.search("闀垮畞鍖�", function (status, result) {
-    var bounds = result.districtList[0].boundaries; //鑾峰彇鏈濋槼鍖虹殑杈圭晫淇℃伅
-    if (bounds) {
-      for (var i = 0; i < bounds.length; i++) {
-        //鐢熸垚琛屾斂鍖哄垝 polygon
-        // eslint-disable-next-line no-undef
-        var polygon = new AMap.Polygon({
-          map: map, //鏄剧ず璇ヨ鐩栫墿鐨勫湴鍥惧璞�
-          strokeWeight: 3, //杞粨绾垮搴�
-          path: bounds[i], //澶氳竟褰㈣疆寤撶嚎鐨勮妭鐐瑰潗鏍囨暟缁�
-          fillOpacity: 0.1, //澶氳竟褰㈠~鍏呴�忔槑搴�
-          fillColor: "#CCF3FF", //澶氳竟褰㈠~鍏呴鑹�
-          // strokeColor: "#CC66CC", //绾挎潯棰滆壊
-          strokeColor: "#0066ff", //绾挎潯棰滆壊      
-        });
-      }
-      map.setFitView(); //灏嗚鐩栫墿璋冩暣鍒板悎閫傝閲�
+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', //杩斿洖琛屾斂鍖鸿竟鐣屽潗鏍囩瓑鍏蜂綋淇℃伅
+      level: 'district' //璁剧疆鏌ヨ琛屾斂鍖虹骇鍒负鍖�
+    });
+    district.search('闀垮畞鍖�', function (status, result) {
+      var bounds = result.districtList[0].boundaries; //鑾峰彇鏈濋槼鍖虹殑杈圭晫淇℃伅
+      if (bounds) {
+        for (var i = 0; i < bounds.length; i++) {
+          //鐢熸垚琛屾斂鍖哄垝 polygon
+          // eslint-disable-next-line no-undef
+          polygon = new AMap.Polygon({
+            map: map, //鏄剧ず璇ヨ鐩栫墿鐨勫湴鍥惧璞�
+            strokeWeight: 3, //杞粨绾垮搴�
+            path: bounds[i], //澶氳竟褰㈣疆寤撶嚎鐨勮妭鐐瑰潗鏍囨暟缁�
+            fillOpacity: 0.1, //澶氳竟褰㈠~鍏呴�忔槑搴�
+            fillColor: '#CCF3FF', //澶氳竟褰㈠~鍏呴鑹�
+            // strokeColor: '#ffffff' //绾挎潯棰滆壊
+            strokeColor: '#0077ff' //绾挎潯棰滆壊
+          });
+        }
+        map.setFitView(); //灏嗚鐩栫墿璋冩暣鍒板悎閫傝閲�
+      }
+    });
   });
-})
+}
 
 const satelliteGridStore = useSatelliteGridStore();
 const { loading, fetchData } = useFetchData(10000);
@@ -93,11 +123,13 @@
 // 鏌ヨ缃戞牸淇℃伅鍜岄仴鎰熸暟鎹粍
 function onSearch(options) {
   satelliteGridStore.fetchGridCell(options.id).then(() => {
+    SatelliteProxy.clearText(mapViews);
     drawGrid(satelliteGridStore.gridInfo);
+    initDistrict()
   });
-  satelliteGridStore.fetchGridData(options.id).then(()=>{
-    max = satelliteGridStore.gridDataList.length
-    fetchGridDataDetail(satelliteGridStore.gridDataList)
+  satelliteGridStore.fetchGridData(options.id).then(() => {
+    max = satelliteGridStore.gridDataList.length;
+    // fetchGridDataDetail(satelliteGridStore.gridDataList);
   });
 }
 
@@ -131,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(
@@ -175,11 +226,13 @@
 }
 
 function handleRankClick(rankVisible) {
-  rankVisible ? map.add(mapViews.rankLayer) : map.remove(mapViews.rankLayer);
+  // rankVisible ? map.add(mapViews.rankLayer) : map.remove(mapViews.rankLayer);
+  rankVisible ? map.add(mapViews.rankTxt) : map.remove(mapViews.rankTxt);
 }
 
 function handleDataClick(dataVisible) {
-  dataVisible ? map.add(mapViews.dataLayer) : map.remove(mapViews.dataLayer);
+  // dataVisible ? map.add(mapViews.dataLayer) : map.remove(mapViews.dataLayer);
+  dataVisible ? map.add(mapViews.dataTxt) : map.remove(mapViews.dataTxt);
 }
 
 function handleColorClick(isStandardColor) {
@@ -203,7 +256,7 @@
   bottom: 10px;
   left: 0;
   right: 0;
-  color: #0066ff;
+  color: #0077ff;
 }
 
 .data-mix {

--
Gitblit v1.9.3