From a79e85a2de679cc4886d82eb70d0b90d3e2a8861 Mon Sep 17 00:00:00 2001
From: Surpriseplus <845948745@qq.com>
Date: 星期一, 08 五月 2023 09:33:51 +0800
Subject: [PATCH] 图层管理上移下移修改

---
 src/views/Tools/LayerTree.vue            |  198 ++++++++++++++++++++++++++++++++++----
 src/store/index.js                       |    1 
 .vscode/settings.json                    |    3 
 src/views/Synthesis/LeftMenu.vue         |    6 
 src/components/MapView/mapSpacePop.vue   |    3 
 src/views/datamanage/layerManagement.vue |   46 +++++---
 6 files changed, 212 insertions(+), 45 deletions(-)

diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..be5acdf
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+  "vue.codeActions.enabled": false
+}
diff --git a/src/components/MapView/mapSpacePop.vue b/src/components/MapView/mapSpacePop.vue
index 1b2e5e9..102b52f 100644
--- a/src/components/MapView/mapSpacePop.vue
+++ b/src/components/MapView/mapSpacePop.vue
@@ -691,8 +691,7 @@
         }
 
       }
-      // debugger
-      // // debugger
+
       // // // for (var i in val_Data) {
       // // //   var valste = val_Data[i]
       // // //   for (var j in this.optionx) {
diff --git a/src/store/index.js b/src/store/index.js
index 4917f99..934fde3 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -9,6 +9,7 @@
 
 export default new Vuex.Store({
   state: {
+    oldTree: null,
     catalogueName: '',
     cataNode: {},
     lang: 'zh',
diff --git a/src/views/Synthesis/LeftMenu.vue b/src/views/Synthesis/LeftMenu.vue
index fb4755b..a593fbf 100644
--- a/src/views/Synthesis/LeftMenu.vue
+++ b/src/views/Synthesis/LeftMenu.vue
@@ -2451,13 +2451,15 @@
         if (str.url != null && str.type == 2 && str.isShow == 1) {
           return str;
         }
+
+      })
+      var layer = std.filter((str) => {
         if (str.isProject == 1 && str.type == 2) {
           this.$store.state.isProjectLayer.push(str);
         }
       })
 
       this.setAddLayers(value);
-
       var res = this.setTreeData(val);
       this.$store.state.pigCode = null;
       //瀛樺偍閫変腑鍥惧眰
@@ -2470,7 +2472,7 @@
       //     }
       //   });
       // }
-
+      this.$store.state.oldTree = val;
       this.$store.state.treeData = res;
 
       this.$store.state.checkedKeys = checkKey;
diff --git a/src/views/Tools/LayerTree.vue b/src/views/Tools/LayerTree.vue
index f1f209e..3b587fb 100644
--- a/src/views/Tools/LayerTree.vue
+++ b/src/views/Tools/LayerTree.vue
@@ -115,7 +115,7 @@
       <div
         class="edit"
         @click="pellucidity()"
-        v-if="showlocal"
+        v-if="showopaque"
       >
         <i class="el-icon-tickets"></i>&nbsp;&nbsp;閫忔槑搴�
       </div>
@@ -227,6 +227,7 @@
     return {
       shwoHistogram: false,
       showlocal: false,
+      showopaque: false,
       eleId: "",
       isShow: false,
       currentData: "",
@@ -270,6 +271,7 @@
       mptLayer: [],
       optionts: [],
       proValue: null,
+      setCheeckedLayer: []
     };
   },
   methods: {
@@ -341,8 +343,13 @@
       }
       if (Node.data.children == null && Node.data.serveType == "Tileset") {
         this.showlocal = true;
+        this.showopaque = true;
+      } else if (Node.data.children == null && Node.data.serveType == "TMS") {
+        this.showlocal = true;
+        this.showopaque = false;
       } else if (Node.data.children == null && Node.data.serveType != "Tileset") {
         this.showlocal = false;
+        this.showopaque = false;
       }
       this.menuVisible = true;
 
@@ -484,15 +491,27 @@
 
 
     //妯″瀷瀹氫綅
-    positioning() {
+    async positioning() {
       this.menuVisible = false
-      for (var i in Viewer.scene.primitives._primitives) {
-        if (
-          Viewer.scene.primitives._primitives[i].id == this.currentData.cnName
-        ) {
-          Viewer.flyTo(Viewer.scene.primitives._primitives[i]);
+
+      if (this.currentData.serveType == 'Tileset') {
+        for (var i in Viewer.scene.primitives._primitives) {
+          if (
+            Viewer.scene.primitives._primitives[i].id == this.currentData.cnName
+          ) {
+            Viewer.flyTo(Viewer.scene.primitives._primitives[i]);
+          }
+        }
+      } else if (this.currentData.serveType == 'TMS' && this.currentData.pubid) {
+        const data = await comprehensive_selectPubById({ id: this.currentData.pubid })
+        if (data.result.geom) {
+          var wkt = this.$wkt.parse(data.result.geom);
+          Viewer.camera.flyTo({
+            destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[1], wkt.coordinates[0], 2000),
+          });
         }
       }
+
     },
     // 缂栬緫鑺傜偣
     editNode(data) {
@@ -954,6 +973,7 @@
             })
           );
           layer.name = res.cnName;
+          layer.id = "TMS"
           this.setChangeWMS();
         }
 
@@ -1025,12 +1045,12 @@
 
         layer.name = res.cnName;
 
-        if (data.result.geom) {
-          var wkt = this.$wkt.parse(data.result.geom);
-          Viewer.camera.flyTo({
-            destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[1], wkt.coordinates[0], 2000),
-          });
-        }
+        // if (data.result.geom) {
+        //   var wkt = this.$wkt.parse(data.result.geom);
+        //   Viewer.camera.flyTo({
+        //     destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[1], wkt.coordinates[0], 2000),
+        //   });
+        // }
         this.setChangeWMS();
       }
     },
@@ -1166,17 +1186,40 @@
       }
       this.$refs.tree.setCheckedKeys(std);
     },
+    getNewTree(obj, result) {
+      for (const i in obj) {
+        result.push(obj[i])
+        if (obj[i].children && obj[i].children.length > 0) {
+          this.getNewTree(obj[i].children, result)
+        }
+      }
+      return result
+    },
+
+
+
     // 鏌ヨ
     filterNode(value, data) {
-
       if (!value) return true;
       return data.cnName.indexOf(value) !== -1;
     },
 
     async setproChange(res) {
-
-      this.$store.state.pigCode = res;
       if (res) {
+        this.setCheeckedLayer = this.$refs.tree.getCheckedKeys();
+
+        this.$store.state.pigCode = res;
+        var st_code = this.optionts.filter(rs => {
+          if (rs.code == res) {
+            return rs
+          }
+        })
+        var val = this.$store.state.oldTree.filter(rs => {
+          if (rs.enName == st_code[0].code) {
+            return rs
+          }
+        })
+        this.removeAllLayer();
         var obj = {
           dirid: res,
           pageIndex: 1,
@@ -1188,23 +1231,130 @@
           this.$message.error("鍒楄〃鑾峰彇澶辫触");
           return;
         }
+
         if (data.result[0]) {
           var geom = data.result[0].geom
-          var wkt = this.$wkt.parse(geom)
-          Viewer.camera.flyTo({
-            destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[0].toFixed(6), wkt.coordinates[1].toFixed(6), 5000),
-          });
+          if (geom) {
+            var wkt = this.$wkt.parse(geom)
+            Viewer.camera.flyTo({
+              destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[0].toFixed(6), wkt.coordinates[1].toFixed(6), 5000),
+            });
+          }
 
         }
-        this.setChangeProLayer();
-      } else {
+        if (val.length > 0) {
+          if (val[0].type == 1 && val[0].isProject == 1) {//椤圭洰鍒嗙被
+            var std = [];
+            for (var i in val) {
+              var std_val = this.getNewTree([this.$refs.tree.getNode(val[i].id).data], [])
+              for (var j in std_val) {
+                std.push(std_val[j])
+              }
+            }
+            var value = this.$store.state.isProjectLayer;
+            for (var i in value) {
+              std.push(value[i])
+            }
 
-        this.$store.state.pigCode = null
-        this.setChangeWMS();
+
+            this.setProjectLayer(std);
+          } else {
+            this.setChangeProLayer();
+          }
+        } else {
+          this.setChangeProLayer();
+        }
+
+
+      } else {
+        this.removeAllLayer();
+        this.$store.state.pigCode = null;
+        this.$refs.tree.setCheckedKeys(this.setCheeckedLayer);
+        var std = [];
+        for (var i in this.setCheeckedLayer) {
+          std.push(this.$refs.tree.getNode(this.setCheeckedLayer[i]).data)
+        }
+
+        this.setProjectLayer(std);
+
+
       }
+
+
     },
+
+    setProjectLayer(res) {
+      var layerid = [];
+      for (var i in res) {
+        layerid.push(res[i].id)
+      }
+      this.$refs.tree.setCheckedKeys(layerid);
+      // var value = this.$refs.tree.getCheckedNodes();
+      // this.$bus.$emit("showMenuLayer", value);
+
+      var listWMS = [];
+      var listWFS = [];
+      var listTileset = [];
+      var listTMS = [];
+      var listMpt = [];
+      for (var i in res) {
+        if (res[i].type == 2) {
+          switch (res[i].serveType) {
+            case 'WMS':
+              listWMS.push(res[i])
+              break;
+            case 'WFS':
+              listWFS.push(res[i])
+              break;
+            case 'Tileset':
+              listTileset.push(res[i])
+              break;
+            case 'Mpt':
+              listMpt.push(res[i])
+              break;
+            case 'TMS':
+              listTMS.push(res[i])
+              break;
+
+          }
+        }
+      }
+      // this.setChangeProLayer();
+      this.setChangeWMS(listWMS, true);
+      this.setChangeWFS(listWFS, true);
+      this.setChangeTileset(listTileset, true);
+      this.setChangeTMS(listTMS, true);
+      this.setChangeMpt(listMpt, true);
+    },
+    removeAllLayer() {
+      for (var j in Viewer.scene.primitives._primitives) {
+        Viewer.scene.primitives.remove(Viewer.scene.primitives._primitives[j])
+      }
+      for (var i in window.Viewer.dataSources._dataSources) {
+        window.Viewer.dataSources.remove(
+          window.Viewer.dataSources._dataSources[i]
+        );
+      }
+      for (var i = 0; i < window.Viewer.imageryLayers._layers.length; i++) {
+        var val_id = window.Viewer.imageryLayers._layers[i].id;
+        if (val_id == 'TMS') {
+          window.Viewer.imageryLayers.remove(
+            window.Viewer.imageryLayers._layers[i]
+          );
+        }
+      }
+      for (var i in this.mptLayer) {
+        this.mptLayer[i].deleteObject();
+        this.mptLayer.splice(i, 1)
+      }
+      this.mptLayer = [];
+    },
+
+
     setChangeProLayer() {
+
       var value = this.$store.state.isProjectLayer;
+
       if (value.length != 0) {
 
         var std = [];
diff --git a/src/views/datamanage/layerManagement.vue b/src/views/datamanage/layerManagement.vue
index 3cbc504..1da5a84 100644
--- a/src/views/datamanage/layerManagement.vue
+++ b/src/views/datamanage/layerManagement.vue
@@ -438,19 +438,24 @@
           if (currentId != 0) {
             const tempChildrenNodex1 = pchildNodes[currentId - 1];
             const tempChildrenNodex2 = pchildNodes[currentId];
-            tempChildrenNodex2.orderNum =
-              pchildNodes[currentId - 1].data.orderNum;
-            tempChildrenNodex1.orderNum = pchildNodes[currentId].data.orderNum;
+            // tempChildrenNodex2.orderNum =
+            //   pchildNodes[currentId - 1].data.orderNum;
+            // tempChildrenNodex1.orderNum = pchildNodes[currentId].data.orderNum;
             var arr = [];
             this.oriData.filter((res) => {
               if (res.id == tempChildrenNodex2.data.id) {
-                res.orderNum = tempChildrenNodex2.orderNum;
+                // res.orderNum = tempChildrenNodex2.orderNum;
                 arr.push(res);
               } else if (res.id == tempChildrenNodex1.data.id) {
-                res.orderNum = tempChildrenNodex1.orderNum;
+                // res.orderNum = tempChildrenNodex1.orderNum;
                 arr.push(res);
               }
             });
+
+            const orderNum = arr[1].orderNum
+            arr[1].orderNum = arr[0].orderNum
+            arr[0].orderNum = orderNum
+
             this.newData = arr;
             this.sendChange();
           } else {
@@ -464,19 +469,22 @@
           if (currentId < pchildNodes.length - 1) {
             const tempChildrenNodex1 = pchildNodes[currentId + 1];
             const tempChildrenNodex2 = pchildNodes[currentId];
-            tempChildrenNodex2.orderNum =
-              pchildNodes[currentId + 1].data.orderNum;
-            tempChildrenNodex1.orderNum = pchildNodes[currentId].data.orderNum;
+            // tempChildrenNodex2.orderNum =
+            //   pchildNodes[currentId + 1].data.orderNum;
+            // tempChildrenNodex1.orderNum = pchildNodes[currentId].data.orderNum;
             var arr = [];
             this.oriData.filter((res) => {
               if (res.id == tempChildrenNodex2.data.id) {
-                res.orderNum = tempChildrenNodex2.orderNum;
+                // res.orderNum = tempChildrenNodex2.orderNum;
                 arr.push(res);
               } else if (res.id == tempChildrenNodex1.data.id) {
-                res.orderNum = tempChildrenNodex1.orderNum;
+                // res.orderNum = tempChildrenNodex1.orderNum;
                 arr.push(res);
               }
             });
+            const orderNum = arr[1].orderNum
+            arr[1].orderNum = arr[0].orderNum
+            arr[0].orderNum = orderNum
             this.newData = arr;
             this.sendChange();
           } else {
@@ -622,13 +630,17 @@
       });
     },
     layerFormInline(res) {
+
       var val = JSON.parse(JSON.stringify(res))
-      this.backUpData = JSON.stringify(res)
-      this.currentData = JSON.stringify(res)
-      this.formInline = val;
-      this.formInline.type = val.type.toString();
-      this.formInline.isShow = val.isShow.toString();
-      this.formInline.isProject = val.isProject.toString();
+
+      var data = this.$refs.tree.getNode(val.id).data;
+
+      this.backUpData = JSON.stringify(data)
+      this.currentData = JSON.stringify(data)
+      this.formInline = data;
+      this.formInline.type = data.type.toString();
+      this.formInline.isShow = data.isShow.toString();
+      this.formInline.isProject = data.isProject.toString();
     },
     //鍥惧眰鍒楄〃鐐瑰嚮浜嬩欢
     handleNodeClick(data, node) {
@@ -643,7 +655,7 @@
 
           branchArr.sort(function (a, b) {
 
-            return b.orderNum - a.orderNum
+            return a.orderNum - b.orderNum
           })
         }
 

--
Gitblit v1.9.3