Browse Source

耕保现状分析上图效果丢失版本回滚

lkk 8 months ago
parent
commit
4a3e908468
1 changed files with 21 additions and 21 deletions
  1. 21 21
      src/views/farmlandProtection/components/fxjg.vue

+ 21 - 21
src/views/farmlandProtection/components/fxjg.vue

@@ -47,10 +47,9 @@
       </div>
       <div>
         <pie
-          class="echart"
-          :style="`height: ${200 + edata.length * 10}px`"
+          :class="`echart${edata.length <= 6 ? '' : '_vertical'}`"
           unit="㎡"
-          @echartClick="(name) => echartClick(name, item.value)"
+          @echartClick="(name) => echartClick(name)"
           :ref="`echartRef`"
         ></pie>
       </div>
@@ -118,6 +117,8 @@ export default {
   methods: {
     download() {},
     resultDeatils(val, mxbsm) {
+      // viewer.entities.removeAll();
+      viewer.dataSources.removeAll();
       let obj = {
         bsm: this.fxjgObj.bsm,
         mxbsm: mxbsm,
@@ -130,7 +131,6 @@ export default {
       QueryGdbhJg({ bsm: this.fxjgObj.bsm }).then((res) => {
         let data = [];
         if (res.statuscode == 200) {
-          console.log(res, ":resresres");
           if (res.data.sandiao.mx_data.length) {
             res.data.sandiao.mx_data.forEach((el) => {
               data.push({
@@ -156,20 +156,17 @@ export default {
         }
       });
     },
-    echartClick(name, { iseyes }) {
-      console.log(name, ":name");
-      // this.reset();
-
-      // this.tableData.forEach((res) => {
-      //   const keys = Object.keys(res);
-      //   for (const key of keys) {
-      //     let value = res[key];
-      //     if (value == name) {
-      //       this.addPolygon(res.空间信息.split(";")[1], "all", "#ff0000", true);
-      //     }
-      //   }
+    echartClick(name) {
+      this.edata.forEach((res) => {
+        const keys = Object.keys(res);
+        for (const key of keys) {
+          let value = res[key];
+          if (value == name) {
+            this.loadGeoJSON(parse(res.geom), res.itemStyle.color, "all");
+          }
+        }
 
-      // })
+      })
     },
     drawWktPloygon(item, itemColor, id) {
       // console.log(geometry, "geometry");
@@ -186,6 +183,7 @@ export default {
     },
     // 加载GeoJSON数据
     loadGeoJSON(geojson, yanse, id, height, name) {
+      viewer.dataSources.removeAll()
       let _this = this;
       let fcolor =
         id && id != "all"
@@ -224,11 +222,14 @@ export default {
           if (id) {
             dataSources[id] = data;
           }
-          if (id == "all") _this.isshowAll = true;
         });
     },
   },
   mounted() {},
+  beforeDestroy() {
+    viewer.entities.removeAll();
+    viewer.dataSources.removeAll();
+  },
 };
 </script>
 
@@ -244,12 +245,11 @@ export default {
     // width: 19rem;
     // height: 350px;
     width: 387px !important;
-    height: 200px;
-    min-height: 200px;
+    height: 200px !important;
   }
   .echart_vertical {
     width: 387px !important;
-    height: 400px !important;
+    height: 370px !important;
   }
 
   .downloadDiv {