maxiaoxiao 11 months ago
parent
commit
a49f6442c7

+ 7 - 1
src/views/complianceAnalysis/components/lsjl.vue

@@ -83,6 +83,8 @@
 import { GetPage, GetFxjg, Delect } from "@/api/ghss/hgxfx.js";
 import hgxfx from "../../../../static/data/ghss/data.js";
 import { Message, MessageBox } from "element-ui";
+import { rest } from "lodash";
+let dataSources;
 export default {
   props: {
     historyList: {
@@ -194,14 +196,18 @@ export default {
       viewer.dataSources.removeAll();
       let polygon = Cesium.GeoJsonDataSource.load(geojson, {
         stroke: Cesium.Color.RED,
-        fill: Cesium.Color.WHITE.withAlpha(0.3),
+        fill: Cesium.Color.WHITE, //.withAlpha(0.3),
         strokeWidth: 5,
       });
       polygon.then(function (dataSource) {
+        dataSources = dataSource;
         viewer.dataSources.add(dataSource);
         viewer.zoomTo(dataSource);
       });
     },
+    reset() {
+      if (dataSources) viewer.dataSources.remove(dataSources);
+    },
   },
   watch: {},
 };

+ 1 - 2
src/views/complianceAnalysis/components/scjg.vue

@@ -124,7 +124,6 @@ export default {
     // 加载GeoJSON数据
     addPolygon(label, id, colors) {
       let _this = this;
-      console.log(colors);
       // viewer.entities.removeAll();
       let scolor = colors
         ? Cesium.Color.fromCssColorString(colors[0])
@@ -163,8 +162,8 @@ export default {
       window.open(this.$props.scjgObj.fxbg.replace(".docx", ".pdf"), "_blank");
     },
     reset() {
+      if (Object.keys(this.dataSources).length) viewer.dataSources.removeAll();
       this.dataSources = {};
-      viewer.dataSources.removeAll();
     },
   },
 

+ 3 - 4
src/views/complianceAnalysis/index.vue

@@ -75,10 +75,9 @@ export default {
   },
   watch: {
     activeTabs(newValue) {
-      if (newValue != "hgxfx") this.$refs.scjg.reset();
-      else if (newValue != "lsju")
-        viewer.dataSources.removeAll(); //this.$refs.scjg.reset();
-      else if (newValue != "scjg") this.$refs.scjg.reset();
+      if (newValue != "hgxfx") this.$refs.hgxfx.reset();
+      if (newValue != "lsju") this.$refs.lsju.reset();
+      if (newValue != "scjg") this.$refs.scjg.reset();
       if (newValue == "lsju") this.$refs.lsju.changeForm();
     },
   },