From a35f963076eecf415487e4c9cc4c102903fec4d2 Mon Sep 17 00:00:00 2001
From: lixuliang <lixuliang_hd@126.com>
Date: 星期三, 01 十一月 2023 17:11:15 +0800
Subject: [PATCH] 会议保障历史记录+跳转标准地平台

---
 src/components/left/layerTree/Layer.vue |  206 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 197 insertions(+), 9 deletions(-)

diff --git a/src/components/left/layerTree/Layer.vue b/src/components/left/layerTree/Layer.vue
index 06b73bb..d133a86 100644
--- a/src/components/left/layerTree/Layer.vue
+++ b/src/components/left/layerTree/Layer.vue
@@ -19,18 +19,38 @@
             <el-button
               class="button-user"
               type="primary"
-              size="mini"
               slot="trigger"
               icon="el-icon-folder-opened"
-              title="鎵撳紑閰嶇疆鏂囦欢"
+              title="鎵撳紑鏈湴閰嶇疆鏂囦欢"
             ></el-button>
             <el-button
               class="button-user"
               type="primary"
-              size="mini"
               icon="el-icon-download"
-              title="淇濆瓨閰嶇疆鏂囦欢"
+              title="淇濆瓨涓烘湰鍦伴厤缃枃浠�"
               @click.stop="save"
+            ></el-button>
+            <el-button
+              class="button-user"
+              type="primary"
+              icon="el-icon-delete"
+              title="娓呴櫎鎵�鏈夋爣缁�"
+              @click.stop="deleteAllPlot"
+            ></el-button>
+            <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-upload>
         </div>
@@ -148,6 +168,18 @@
 import SaveScene from "./SaveScene.vue";
 // 宸ョ▼鏍戝伐鍏�
 let _treeTool;
+function arrGroup(arr, fn) {
+  const obj = {};
+  arr.forEach((item) => {
+    const key = JSON.stringify(fn(item));
+    obj[key] = obj[key] || [];
+    obj[key].push(item);
+  });
+  return Object.keys(obj).map((k) => {
+    return obj[k];
+  });
+}
+
 export default {
   name: "Layer",
   components: {
@@ -323,12 +355,166 @@
       };
       reader.readAsText(file.raw);
     },
+    // 鏍囩粯涓婁紶鑷虫湇鍔″櫒
+    saveHistoryPlot() {
+      if (this.treeData.length == 0) {
+        this.$message.error("璇峰厛杩涜鏍囩粯");
+        return;
+      } else if (this.treeData.length > 1) {
+        this.$message.error("鏍煎紡涓嶆纭紝璇蜂慨鏀瑰悗閲嶆柊淇濆瓨");
+        return;
+      }
+      this.$confirm("鏄惁灏嗗綋鍓嶄細璁繚闅滄爣缁樻暟鎹笂浼犺嚦鏈嶅姟鍣�?", "涓婁紶", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning",
+      })
+        .then(() => {
+          let oricontent = JSON.stringify(this.treeData);
+          let content = oricontent.replace(
+            /"checked":true/g,
+            '"checked":false'
+          );
+          const uploading = this.$loading({
+            lock: true,
+            text: "浼氳淇濋殰鏍囩粯鏁版嵁涓婁紶涓紝璇风◢鍚�",
+            spinner: "el-icon-loading",
+            background: "rgba(0, 0, 0, 0.7)",
+          });
+          axios({
+            method: "POST",
+            url: "http://10.10.4.121:8070/PM20221203225_OpenAPI3_Service-0.0.1-SNAPSHOT/biaoHui/add",
+            data: {
+              userId: this.$store.state.userId,
+              userName: this.$store.state.userName,
+              geojsonName: this.treeData[0].name,
+              geojsonString: content,
+            },
+          }).then(
+            (response) => {
+              uploading.close();
+              if (response.data.code == 200) {
+                this.$message({
+                  message: "淇濆瓨鎴愬姛",
+                  type: "success",
+                });
+              } else {
+                this.$message.error("淇濆瓨澶辫触锛�");
+              }
+            },
+            (error) => {
+              uploading.close();
+              this.$message.error("鏁版嵁涓婁紶澶辫触");
+              // console.log("閿欒", error.message);
+            }
+          );
+        })
+        .catch(() => {
+          this.$message({
+            type: "info",
+            message: "宸插彇娑堜笂浼�",
+          });
+        });
+    },
+    // 鍔犺浇鍘嗗彶鏍囩粯鏁版嵁
+    histotyPlotting() {
+      this.$confirm(
+        "璇ユ搷浣滃皢浼氬鑷村綋鍓嶆爣缁樻暟鎹瑕嗙洊锛屾槸鍚︾户缁�?",
+        "浼氳淇濋殰鍘嗗彶鏁版嵁",
+        {
+          confirmButtonText: "纭畾",
+          cancelButtonText: "鍙栨秷",
+          type: "warning",
+          // customClass: "msgbox",
+        }
+      )
+        .then(() => {
+          const downloading = this.$loading({
+            lock: true,
+            text: "浼氳淇濋殰鍘嗗彶鏁版嵁鍔犺浇涓紝璇风◢鍚�",
+            spinner: "el-icon-loading",
+            background: "rgba(0, 0, 0, 0.7)",
+          });
+          let that = this;
+          axios({
+            method: "POST",
+            url: "http://10.10.4.121:8070/PM20221203225_OpenAPI3_Service-0.0.1-SNAPSHOT/biaoHui/list",
+            data: {
+              userId: this.$store.state.userId,
+            },
+          }).then(
+            (response) => {
+              setTimeout(() => {
+                downloading.close();
+                let plottingArr = [];
+                response.data.result.forEach((item) => {
+                  let geoJsonObj = JSON.parse(item.geojsonString);
+                  plottingArr.push(geoJsonObj[0]);
+                });
+                const newArr = arrGroup(plottingArr, (item) => item.name);
+                let finalPlotting = [];
+                newArr.map((a) => {
+                  let newObj = {};
+                  a.map((b) => {
+                    if (newObj.children) {
+                      newObj.children = newObj.children.concat(b.children);
+                    } else {
+                      newObj = b;
+                    }
+                  });
+                  finalPlotting.push(newObj);
+                });
+                let json = {
+                  name: "涓�寮犲浘",
+                  id: 1,
+                  open: true,
+                  children: finalPlotting,
+                };
+                that.initData(json);
+              }, 2000);
+            },
+            (error) => {
+              setTimeout(() => {
+                downloading.close();
+                // console.log("閿欒", error.message);
+                this.$message.error("鏁版嵁璇锋眰澶辫触");
+              }, 2000);
+            }
+          );
+        })
+        .catch(() => {
+          this.$message({
+            type: "info",
+            message: "宸插彇娑堝姞杞�",
+          });
+        });
+    },
+    // 娓呴櫎鏈湴鎵�鏈夋爣缁樹俊鎭�
+    deleteAllPlot() {
+      this.$confirm("璇ユ搷浣滃皢娓呴櫎鎵�鏈夋爣缁樹俊鎭紝鏄惁缁х画?", "娓呴櫎", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning",
+      })
+        .then(() => {
+          this.$message({
+            message: "鏍囩粯鏁版嵁宸叉竻闄�",
+            type: "success",
+          });
+          this.initData({});
+        })
+        .catch(() => {
+          this.$message({
+            type: "info",
+            message: "宸插彇娑堟竻闄�",
+          });
+        });
+    },
     // 鍒濆鍖栨暟鎹�
     initData(data) {
       if (this.treeData.length) {
         this.removeChildData(this.treeData);
       }
-
       data.name && sessionStorage.setItem("SmartEarthTitle", data.name);
       // 璁剧疆宸ョ▼鏍戞暟鎹�
       this.setTreeData(data.children);
@@ -706,8 +892,6 @@
         open: true,
         children: this.treeData,
       };
-      console.log(this.treeData);
-      debugger;
       let content = JSON.stringify(data);
       let blob = new Blob([content], { type: "" });
       var reader = new FileReader();
@@ -727,6 +911,7 @@
     rightClick(e, data, node, comp) {
       this.isClickParent = !!data.children;
       this.selectNode = data;
+      console.log(this.selectNode);
       this.rightClickMenuStyle = { top: e.pageY + "px", left: e.pageX + "px" };
       this.rightClickMenuDisplay = true;
       document.onclick = (e) => {
@@ -845,6 +1030,9 @@
 /deep/.button-user i {
   color: #ffffff !important;
 }
+.historyBtn {
+  margin-left: 28px;
+}
 .closeBtn {
   color: white;
   position: relative;
@@ -874,7 +1062,7 @@
 }
 
 .wdzy {
-  width: 320px;
+  width: 335px;
   /* height: 100%; */
   max-height: 360px;
   overflow-y: auto;
@@ -887,7 +1075,7 @@
 .closePanel {
   position: absolute;
   right: 12px;
-  top: 6px;
+  top: 10px;
   font-size: 18px;
   line-height: 30px;
   background-color: rgba(255, 255, 255, 0.5);

--
Gitblit v1.9.3