zpf 11 mesiacov pred
rodič
commit
744312def5

+ 31 - 1
src/views/cockpit/common/VectorSpace/BoxCommonVector.vue

@@ -37,6 +37,8 @@
   
 <script>
 import { QueryList } from '@/api/cockpitNew'
+import * as tdsy from "@/views/cockpit/js/tdsy";
+
 import * as wellknown from "wellknown";
 import * as turf from "@turf/turf";
 export default {
@@ -50,11 +52,30 @@ export default {
         };
     },
     methods: {
-
+        draw_vector_tdgy_gy_jd(data) {
+            data.forEach((res) => {
+                res.type = '国有建设用地完成项目'
+                if (res.geom) {
+                    res.geom.coordinates.forEach((res_coordinates) => {
+                        let arrayt = [];
+                        if (res_coordinates.length == 1) {
+                            arrayt = res_coordinates[0]
+                        } else {
+                            arrayt = res_coordinates
+                        }
+
+                        const twoDArray = arrayt;
+                        const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
+                        tdsy.add(res,"国有建设用地完成项目", oneDArray);
+                    })
+                }
+            })
+        },
 
         close() {
 
             store.setViewerFlagb(true);
+            tdsy.remove("国有建设用地完成项目");
         },
 
         change_witch() {
@@ -98,13 +119,22 @@ export default {
     },
     watch: {
         cockpit_vector(newVal, oldVal) {
+            console.log('newVal: ', newVal);
             this.title = newVal.title
             this.active_dableData = newVal.tableData
             this.tableData = newVal.tableData
+        },
+        active_dableData(newVal, oldVal) {
+            this.draw_vector_tdgy_gy_jd(newVal);
         }
     },
     mounted() {
+        const that = this;
+        this.$nextTick(() => {
+            // tdsy.init(viewer);
+
 
+        });
     }
 
 };

+ 27 - 8
src/views/cockpit/js/tdsy.js

@@ -1,21 +1,24 @@
-let gy_jd_entity = {};
+let gy_jd_entity = null;
 let _viewer = {};
 
 export const init = (viewer) => {
 
-    gy_jd_entity = new Cesium.CustomDataSource("gy_jd_entity");
-    viewer.dataSources.add(gy_jd_entity);
-    gy_jd_entity.show = false;
-    _viewer = viewer;
+    if (gy_jd_entity == null) {
+        gy_jd_entity = new Cesium.CustomDataSource("gy_jd_entity");
+        viewer.dataSources.add(gy_jd_entity);
+        // gy_jd_entity.show = false;
+        _viewer = viewer;
+    }
 
 }
 
-export const add = (res, oneDArray) => {
+export const add = (res, type, oneDArray) => {
 
+    init(viewer);
     gy_jd_entity.entities.add({
         // position: Cesium.Cartesian3.fromDegrees(res_coordinates[0], res_coordinates[1], 0),
         properties: res,
-        name: "国有建设用地完成项目",
+        name: type,
         polygon: {
             zIndex: 1,
             hierarchy: {
@@ -25,14 +28,30 @@ export const add = (res, oneDArray) => {
             // material: Cesium.Color.fromCssColorString(xzqh_color),
 
             height: 5,
-            extrudedHeight: 0,
+            // extrudedHeight: 5,
             outline: true,
             // outlineColor : Cesium.Color.BLACK
             outlineColor: Cesium.Color.fromCssColorString('#55A1E3'),
         }
     })
 }
+export const remove = (type) => {
+    viewer.dataSources.remove(gy_jd_entity);
+    gy_jd_entity = null
+    store.setCockpit_vector({
+        title: "",
+        tableData: [],
+        columns: [],
+    })
+    // if (gy_jd_entity.entities) {
+    //     gy_jd_entity.entities.values.forEach((res) => {
+    //         if (res.name == type) {
+    //             gy_jd_entity.remove(res);
+    //         }
+    //     })
+    // }
 
+}
 export const hidden = (flag) => {
     gy_jd_entity.show = flag;
 

+ 15 - 49
src/views/cockpit/tdsy.vue

@@ -837,58 +837,24 @@ export default {
       this.$refs.hysy_bar_graph.setOptions(this.legendData, this.xdata, this.result);
 
     },
-    draw_vector_tdgy_gy_jd() {
-      this.vector_data.forEach((res) => {
-        res.type = '国有建设用地完成项目'
-        if (res.geom) {
-          res.geom.coordinates.forEach((res_coordinates) => {
-            let arrayt = [];
-            if (res_coordinates.length == 1) {
-              arrayt = res_coordinates[0]
-            } else {
-              arrayt = res_coordinates
-            }
 
-            const twoDArray = arrayt;
-            const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
-
-            // this.gy_jd_entity.entities.add({
-            //   // position: Cesium.Cartesian3.fromDegrees(res_coordinates[0], res_coordinates[1], 0),
-            //   properties: res,
-            //   name: "国有建设用地完成项目",
-            //   polygon: {
-            //     zIndex: 1,
-            //     hierarchy: {
-            //       positions: Cesium.Cartesian3.fromDegreesArrayHeights(oneDArray),
-            //     },
-            //     // outline: false,
-            //     // material: Cesium.Color.fromCssColorString(xzqh_color),
-
-            //     height: 5,
-            //     extrudedHeight: 0,
-            //     outline: true,
-            //     // outlineColor : Cesium.Color.BLACK
-            //     outlineColor: Cesium.Color.fromCssColorString('#55A1E3'),
-            //   }
-            // })
-
-            tdsy.add(res, oneDArray);
-          })
-        }
-      })
-    },
     switch_vector_tdgy_gy_jd(flag) {
 
       // store.state.query_vector_input = !store.state.query_vector_input
-      if (flag) {
-        store.setCockpit_vector({
-          title: "土地供应完成项目",
-          tableData: this.vector_data,
-          columns:["项目名称","土地用途","出让面积(公顷)","土地使用权","土地座落","批准文号","批准机关"],
-        })
-        console.log(store.state.cockpit_vector.tableData,'store.state.cockpit_vector.tableData');
+      // if (flag) {
+      //   store.setCockpit_vector({
+      //     title: "土地供应完成项目",
+      //     tableData: this.vector_data,
+      //     columns:["项目名称","土地用途","出让面积(公顷)","土地使用权","土地座落","批准文号","批准机关"],
+      //   })
+      // }
 
-      }
+
+      store.setCockpit_vector({
+        title: "土地供应完成项目",
+        tableData: this.vector_data,
+        columns: ["项目名称", "土地用途", "出让面积(公顷)", "土地使用权", "土地座落", "批准文号", "批准机关"],
+      })
 
     },
     async init_vector(params) {
@@ -905,7 +871,7 @@ export default {
 
       })
       this.vector_data = data.data;
-      // this.draw_vector_tdgy_gy_jd()
+
     }
   },
   mounted() {
@@ -928,7 +894,7 @@ export default {
       // viewer.dataSources.add(this.gy_jd_entity);
       // this.gy_jd_entity.show = false
 
-      tdsy.init(viewer);
+      // tdsy.init(viewer);
 
 
     });