From 2a960cd2c5b88b143cea4acfaeafb96daef0f29b Mon Sep 17 00:00:00 2001
From: surprise <15810472099@163.com>
Date: 星期三, 10 一月 2024 09:47:09 +0800
Subject: [PATCH] 代码更新

---
 src/components/left/layerTree/Layer.vue |  101 ++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 84 insertions(+), 17 deletions(-)

diff --git a/src/components/left/layerTree/Layer.vue b/src/components/left/layerTree/Layer.vue
index 389efd2..1d3ee7f 100644
--- a/src/components/left/layerTree/Layer.vue
+++ b/src/components/left/layerTree/Layer.vue
@@ -19,8 +19,8 @@
             <el-button class="button-user" type="primary" icon="el-icon-upload" title="涓婁紶鑷虫湇鍔″櫒"
               @click.stop="saveHistoryPlot"></el-button>
 
-            <!-- <el-button class="button-user historyBtn" type="primary" icon="el-icon-s-order" title="鍘嗗彶璁板綍"
-              @click.stop="histotyPlotting"></el-button> -->
+            <el-button class="button-user historyBtn" type="primary" icon="el-icon-s-order" title="鑾峰彇鏈�鏂版暟鎹�"
+              @click.stop="histotyPlotting"></el-button>
           </el-upload>
         </div>
 
@@ -97,8 +97,10 @@
 import AddOnlineMap from "./AddOnlineMap.vue";
 import GetScene from "./GetScene.vue";
 import SaveScene from "./SaveScene.vue";
-import { Op_SelectByPage, Op_Insert, Op_UpdateById } from '../../../api/api.js'
+import { Op_SelectByPage, Op_Insert, Op_UpdateById, Img_SelectByPage, Img_DeleteByIds } from '../../../api/api.js'
 import model from "../../../assets/js/Layer/model";
+import mapOL from "../../../assets/js/Layer/mapOL";
+import mapGeo from "../../../assets/js/Layer/mapGeo";
 // 宸ョ▼鏍戝伐鍏�
 let _treeTool;
 function arrGroup(arr, fn) {
@@ -153,6 +155,16 @@
     };
   },
   mounted() {
+
+    Bus.$on("reastLayer", (type) => {
+      this.setTreeData([]);
+      this.initData({});
+      model.deleteAll();
+      setTimeout(() => {
+  
+        this.histotyPlotting();
+      }, 100);
+    });
     // 鑾峰彇鏈湴閰嶇疆鏂囦欢
     if (this.$route.query.hasOwnProperty("layer")) {
       axios
@@ -195,11 +207,13 @@
       Bus.$emit("checkTab", "index/add/treeLayer", false);
     },
     closeLayer() {
-      this.$parent.hideLayer();
+      this.$store.state.isShowLayer = false
+      // this.$parent.hideLayer();
     },
     // 瀹氫箟涓浆绔欎簨浠�
     initBusEvent() {
-      Bus.$off("addLayer");
+
+
       Bus.$on("addLayer", (type) => {
         this.selectNode = this.$refs.tree && this.$refs.tree.getCurrentNode();
         this.openThisTypePop(type);
@@ -389,7 +403,12 @@
     },
     // 鍔犺浇鍘嗗彶鏍囩粯鏁版嵁
     async histotyPlotting() {
+      this.setTreeData([]);
+      this.initData({});
+      model.deleteAll();
+      var finalPlotting = [];
       const data = await Op_SelectByPage({ pageSize: 1000000, pageIndex: 1, name: '' });
+      const data1 = await Img_SelectByPage({ pageSize: 1000000, pageIndex: 1, name: '' });
       if (data.status == 200 && data.data.length > 0) {
         var val_data = data.data;
         for (var i in val_data) {
@@ -400,7 +419,7 @@
             let plottingArr = [];
             plottingArr.push(val[0]);
             const newArr = arrGroup(plottingArr, (item) => item.name);
-            let finalPlotting = [];
+
             newArr.map((a) => {
               let newObj = {};
               a.map((b) => {
@@ -412,16 +431,33 @@
               });
               finalPlotting.push(newObj);
             });
-            let json = {
-              name: "姹熻嫃浜ゆ帶鏅烘収楂橀��",
-              id: 1,
-              open: true,
-              children: finalPlotting,
-            };
-            this.initData(json);
+
           }
         }
       }
+
+      if (data1.status == 200) {
+        var img_data = data1.data;
+        if (img_data && img_data.length > 0) {
+          for (var i = 0; i < img_data.length; i++) {
+            var item = img_data[i]
+            item.sourceType = 'imgUp'
+            item.sid = item.id;
+            item.id = new Date().getTime() + i;
+            item.checked = true;
+            finalPlotting[0].children.push(item)
+          }
+        }
+
+      }
+      var json = {
+        name: "姹熻嫃浜ゆ帶鏅烘収楂橀��",
+        id: 1,
+        open: true,
+        children: finalPlotting
+      };
+   
+      this.initData(json);
       // const downloading = this.$loading({
       //   lock: true,
       //   text: "浼氳淇濋殰鍘嗗彶鏁版嵁鍔犺浇涓紝璇风◢鍚�",
@@ -550,6 +586,7 @@
         if (addData && node._children) {
           node._children.forEach((item) => {
             _treeTool.addData(item);
+  
             this.setAddGLBLayer(item);
           });
         } else {
@@ -586,6 +623,12 @@
           model.addModelLayer(treeNode);
         } else {
           model.setDelGLBModel(treeNode);
+        }
+      } else if (treeNode.sourceType == "SimpleGraphic") {
+        if (isCheck) {
+          mapOL.addLayerData(treeNode);
+        } else {
+          mapOL.removeLayerData(treeNode);
         }
       }
       // 鍙兘鍚屾椂鍔犺浇涓�涓湴褰�
@@ -809,7 +852,13 @@
       if (res.sourceType == "GLB" && res.checked) {
 
         model.addModelLayer(res);
-      }
+      } else if (res.sourceType == "SimpleGraphic" && res.checked) {
+        mapOL.addLayerData(res);
+      } else if (res.sourceType == "imgUp" && res.checked) {
+        model.addImgUpLayer(res);
+      }else if(res.sourceType == "DrawGrid" && res.checked) {
+聽 聽 聽 聽 mapGeo.addGridLayer(res);
+聽 聽 聽 }
     },
     // 娣诲姞婕旂ず鍔ㄧ敾
     editDemoAnimation() {
@@ -927,6 +976,9 @@
     // 鍙抽敭鑿滃崟鍏冪礌
     rightClick(e, data, node, comp) {
       this.isClickParent = !!data.children;
+      if (data.sourceType == 'imgUp') {
+        this.isClickParent = true;
+      }
       this.selectNode = data;
       this.rightClickMenuStyle = { top: e.pageY + "px", left: e.pageX + "px" };
       this.rightClickMenuDisplay = true;
@@ -943,12 +995,15 @@
       if (this.selectNode.sourceType === "GLB") {
         model.setDelGLBModel(this.selectNode)
       }
-
+      if (this.selectNode.sourceType === "SimpleGraphic") {
+        mapOL.removeLayerData(this.selectNode)
+      }
+      if (this.selectNode.sourceType === "imgUp") {
+        this.removeimgUpData(this.selectNode)
+      }
       this.remove(this.selectNode);
       this.$refs.tree && this.$refs.tree.setCurrentKey(null);
       this.selectNode = undefined;
-
-
     },
     // 鍙抽敭缂栬緫鎸夐挳缂栬緫鏍戣妭鐐�
     editTreeNode() {
@@ -975,6 +1030,18 @@
         }
       }
     },
+    async removeimgUpData(res) {
+      const data = await Img_DeleteByIds(res.sid);
+      if (data.status == 200) {
+
+      }
+    },
+
+
+
+
+
+
     // 娣诲姞鐩綍
     addFold() {
       let newChild = {

--
Gitblit v1.9.3