Pārlūkot izejas kodu

上传数据功能优化及关联问题修改

Bella 2 gadi atpakaļ
vecāks
revīzija
096ed76749

+ 86 - 173
src/components/common/BottomForm/UploadingDataShp.vue

@@ -13,21 +13,6 @@
       </div>
     </template>
     <div id="uploadingBox">
-      <!-- <el-upload
-        class="upload-demo"
-        ref="upload"
-        drag
-        :http-request="uploadSectionFile"
-        action="#"
-        :limit="1"
-        :show-file-list="false"
-      >
-        <i class="el-icon-upload"></i>
-        <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
-        <div class="el-upload__tip" slot="tip">
-          *仅支持上传zip格式的shp压缩包,json(或geojson)格式的数据
-        </div>
-      </el-upload> -->
       <el-upload
         class="upload-demo"
         drag
@@ -35,7 +20,6 @@
         :http-request="uploadSectionFile"
         :on-preview="handlePreview"
         :on-remove="handleRemove"
-        :before-remove="beforeRemove"
         :before-upload="beforeAvatarUpload"
         :limit="1"
         :on-exceed="handleExceed"
@@ -44,11 +28,10 @@
         <i class="el-icon-upload"></i>
         <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
         <div class="el-upload__tip" slot="tip">
-          *仅支持上传zip格式的shp压缩包,json(或geojson)格式的数据,且不超过100MB
+          * 仅支持上传zip格式的shp压缩包, json(或geojson)格式的数据,且不超过50MB ;<br/>
+          * 仅支持上传上海2000投影坐标数据 ;
         </div>
-        <!-- <div class="el-upload__tip" slot="tip">
-          *仅支持Geojson格式文件,且不超过5MB
-        </div> -->
+        
       </el-upload>
     </div>
     <span slot="footer" class="dialog-footer">
@@ -65,19 +48,16 @@
  * @author: GAO LU
  * @Date: 2023年3月6-8日
  */
-import shp from "shpjs";
 import JsZip from "jszip";
 import iconv from "iconv-lite";
-import { open, openShp, openDbf } from "shapefile";
-import coordinate from "@/utils/coordinate";
+import { open } from "shapefile";
+
 export default {
   name: "UploadingData",
   components: {},
   data() {
     return {
-      headerObj:{
-
-      },
+      headerObj: {},
       // 当前上传文件的unique名称
       layerUniqueName: null,
       // shp数据
@@ -130,6 +110,7 @@ export default {
     clearDialogVisible() {
       this.fileList = [];
       this.fileDataList = {};
+      // this.fileUniqueObj = {};
       // 关闭弹窗
       this.dialogVisible = false;
       // 修改父级菜单变量(弹窗显示状态和显示底部菜单)
@@ -137,35 +118,28 @@ export default {
     },
     // 上传判断
     uploadSectionFile(params) {
-      debugger
       const file = params.file;
       const fileName = file.name;
       const isGeojson =
         fileName.indexOf("json") != -1 || fileName.indexOf("geojson") != -1;
       const isZip = fileName.indexOf("zip") !== -1;
       const isShp = fileName.indexOf("shp") !== -1;
-      // 用于识别不同文件,并作为图层名称
-      this.layerUniqueName = ""
+
       if (isGeojson) {
-        this.layerUniqueName =
-          fileName.slice(0, fileName.indexOf(".json")) ||
-          fileName.slice(0, fileName.indexOf(".geojson"));
         this.fileUniqueObj[this.layerUniqueName] = [];
-        console.log("读取geojson格式的数据");
-        this.readGeojson(file,this.layerUniqueName);
-      } 
-      
+        this.readGeojson(file, this.layerUniqueName);
+      }
+
       if (isZip) {
-        this.layerUniqueName = fileName.slice(0, fileName.indexOf(".zip"));
         this.fileUniqueObj[this.layerUniqueName] = [];
-        console.log("读取shp压缩包");
-        this.openZip(file,this.layerUniqueNamee);
-      } 
+        this.openZip(file, this.layerUniqueName);
+      }
     },
-    openZip(data, uniqueName) {
+    openZip(file, uniqueName) {
+      this.fileList.push(file);
       let newZip = new JsZip();
       newZip
-        .loadAsync(data, {
+        .loadAsync(file, {
           decodeFileName: function (bytes) {
             return iconv.decode(bytes, "gbk"); // 按中文编码
           },
@@ -188,7 +162,12 @@ export default {
                 .async("arraybuffer")
                 .then((attrContent) => {
                   // 文件中的内容
-                  this.shapefileOpen(geometryInfo, attrContent,uniqueName);
+                  this.shapefileOpen(
+                    geometryInfo,
+                    attrContent,
+                    uniqueName,
+                    file.uid
+                  );
                 });
             })
             .catch((err) => {
@@ -196,116 +175,75 @@ export default {
               console.log(err);
               this.$message.error("请上传正确格式的文件!");
             });
-          // zip.forEach((path, zipEntry) => {
-          //   console.log(zipEntry.name); // 输出不乱码中文
-          // });
         });
     },
     // 为zip时,读取压缩包,选取shp文件
     // 读取geojson数据
-    readGeojson(data, uniqueName) {
-      debugger;
+    readGeojson(file, uniqueName) {
       const reader = new FileReader();
-      reader.readAsText(data, "UTF-8");
-      // reader.readAsArrayBuffer(data);
+      reader.readAsText(file, "UTF-8");
       reader.onload = (e) => {
         let result = e.target.result;
-        this.fileUniqueObj[uniqueName] = result;
-        // 转换坐标 -- 渲染疑点,添加到我的图层
-        // this.geojsonFileRender(result,uniqueName);
+        this.fileUniqueObj[uniqueName] = JSON.parse(result).features;
+        this.fileList.push(file);
+        this.fileDataList[file.uid] = result;
       };
     },
     // 渲染geojson的数据
     geojsonFileRender(content, uniqueName) {},
     // 解析.shp或.dbf文件
-    shapefileOpen(geoContent, attrContent, uniqueName) {
+    shapefileOpen(geoContent, attrContent, uniqueName, uid) {
       let options = {
         encoding: "utf8",
       };
-      let that = this
+      let that = this;
       that.shpDataList = [];
       // 读取几何信息
       open(geoContent, attrContent, options)
         .then((source) =>
           source.read().then(function log(result) {
             if (result.done) return;
-            // console.log(result)
             that.shpDataList.push(result.value);
             return source.read().then(log);
           })
         )
         .catch((error) => console.error(error.stack));
-      this.fileUniqueObj[uniqueName] = that.shpDataList
-      console.log(this.fileUniqueObj[uniqueName], "读取到的shp数据");
+      this.fileUniqueObj[uniqueName] = that.shpDataList;
+      this.fileDataList[uid] = that.shpDataList;
     },
-    /**
-     * 上海2000高斯投影坐标转上海2000经纬度坐标
-     */
-    latLngsTransform(latlngsAry) {
-      // 深拷贝
-      var tempLatlngsAry = JSON.parse(JSON.stringify(latlngsAry));
-      if (typeof tempLatlngsAry[0] === "number") {
-        if (tempLatlngsAry.length < 3 && tempLatlngsAry.length > 0) {
-          tempLatlngsAry = coordinate.shcj_to_wgs84(
-            tempLatlngsAry[0],
-            tempLatlngsAry[1]
-          );
-          tempLatlngsAry = [
-            tempLatlngsAry[0] - 0.19195,
-            tempLatlngsAry[1] + 0.00011,
-          ];
 
-          return tempLatlngsAry;
-        }
-        if (tempLatlngsAry.length === 3) {
-          tempLatlngsAry = coordinate.shcj_to_wgs84(
-            tempLatlngsAry[0],
-            tempLatlngsAry[1]
-          );
-          tempLatlngsAry = [
-            tempLatlngsAry[0] - 0.19195,
-            tempLatlngsAry[1] + 0.00011,
-          ];
-          return tempLatlngsAry;
-        }
-      } else {
-        for (var i = 0, l = tempLatlngsAry.length; i < l; i++) {
-          tempLatlngsAry[i] = latLngsTransform(tempLatlngsAry[i]);
+    // 上传表单提交,开始渲染上传的图层数据,并且添加到我的图层
+    subMitDialogVisible() {
+      setTimeout(() => {
+        // 一次只允许上传一个图层
+        for (let key in this.fileUniqueObj) {
+          // 获取疑点图层数据
+          const datajson = this.fileUniqueObj[key];
+          this.uploadRender(datajson, key);
         }
+        this.$message.success("数据上传成功,开始渲染!");
+        this.clearDialogVisible();
+      }, 500);
+    },
+    uploadRender(datajson, uniqueId) {
+      if (datajson.length === 0) {
+        this.$message.info("暂无疑点数据!");
+      }
+      if (datajson.length > 0) {
+        let data = JSON.stringify(datajson);
+        let option = {
+          id: `upload_${uniqueId}`,
+          data: data,
+          label: uniqueId,
+        };
+        this.$bus.$emit("addUploadLayerEvent", option);
       }
-      return tempLatlngsAry;
     },
-    // 上传表单提交,开始渲染上传的图层数据,并且添加到我的图层
-    subMitDialogVisible(){
-
-    }, 
-    // 上传数据表单提交
-    // subMitDialogVisible() {
-    //   let fileDataList = this.fileDataList;
-    //   for (let key in fileDataList) {
-    //     const dataJson = JSON.parse(fileDataList[key]);
-    //     this.uploadRENDER(dataJson);
-    //   }
-    //   setTimeout(() => {
-    //     if (map2DViewer.analysisGroups[`upload_layer_unique`]) {
-    //       this.$message.success("数据上传成功!");
-    //       map2DViewer.map.fitBounds(
-    //         map2DViewer.analysisGroups[`upload_layer_unique`].getBounds()
-    //       );
-    //     }
-    //     let options = {
-    //       id: "upload_layer_unique",
-    //       label: "我的图层1",
-    //     };
-    //     this.$bus.$emit("addUploadLayerEvent", options);
-    //   }, 1000);
-
-    //   this.clearDialogVisible();
-    // },
     // 文件列表移除文件时
     handleRemove(file, fileList) {
       this.fileList = fileList;
       delete this.fileDataList[file.uid];
+      delete this.fileUniqueObj[this.layerUniqueName]
     },
     // 点击文件列表中已上传的文件时
     handlePreview(file) {},
@@ -317,73 +255,48 @@ export default {
         } 个文件`
       );
     },
-    // 删除文件之前
-    beforeRemove(file, fileList) {
-      this.$message.success(`文件${file.name}移除成功!`);
-      return true;
-    },
-    // 根据上传的文件渲染到地图中
-    // uploadRENDER(geoJson) {
-    //   // 呈现数据已经成功
-    //   let firstPolygon = JSON.parse(JSON.stringify(geoJson));
-    //   // let uniqueId = firstPolygon.name;
-    //   let uniqueId = `upload_layer_unique`;
-    //   if (!map2DViewer.analysisGroups[uniqueId]) {
-    //     map2DViewer.analysisGroups[uniqueId] = L.featureGroup();
-    //     map2DViewer.analysisGroups[uniqueId].addTo(map2DViewer.map);
-    //     if (!this.$store.state.selectSelectDataMap["singlePolygon"]) {
-    //       this.$store.state.selectSelectDataMap["singlePolygon"] = [];
-    //     }
-
-    //     console.log("上传文件读取到的数据", firstPolygon);
-    //     firstPolygon.features.forEach((ele, index) => {
-    //       let cid = `myLayer_${index}`;
-    //       let geometry = JSON.stringify(ele);
-    //       this.$store.state.mapMethodsCollection
-    //         .get("RENDER")
-    //         .addSinglePolygon(
-    //           geometry,
-    //           cid,
-    //           "rgb(0,255,255)",
-    //           uniqueId,
-    //           "我的图层",
-    //           "土地资源"
-    //         );
-    //     });
-    //   }
-    // },
-    // // 读取file对象内容
-    getActionData(file) {
-      console.log(file, "getActionData");
-      // const __this = this;
-      // var reader = new FileReader(); // 新建一个FileReader
-      // reader.readAsText(file.raw, "UTF-8"); // 读取文件
-      // reader.onload = function (evt) {
-      //   __this.fileList.push(file);
-      //   __this.fileDataList[file.uid] = evt.target.result;
-      // };
-    },
     // 上传文件之前
     beforeAvatarUpload(file) {
-      console.log(file, "beforeUpload");
       let fileName = file.name;
       const isGeojson =
         fileName.indexOf("json") != -1 || fileName.indexOf("geojson") != -1;
       const isZip = fileName.indexOf("zip") !== -1;
-      const isLt100M = file.size / 1024 / 1024 < 100;
+      const isLt50M = file.size / 1024 / 1024 < 50;
+
+      // 用于识别不同文件,并作为图层名称
+      this.layerUniqueName = "";
 
       if (!(isGeojson || isZip)) {
         this.$message.error("仅支持json格式文件或shp格式的压缩包!");
       }
-      // const isJPG = file.name.indexOf(".geojson") === file.name.length - 8;
-      // const isLt5M = file.size / 1024 / 1024 < 5;
-      // if (!isJPG) {
-      //   this.$message.error("仅支持Geojson格式文件!");
-      // }
-      if (!isLt100M) {
+
+      if (!isLt50M) {
         this.$message.error("上传文件大小不能超过 100MB!");
       }
-      return (isGeojson || isZip) && isLt100M;
+
+      let enableUpload = true
+
+      if (isGeojson) {
+        this.layerUniqueName =
+          fileName.slice(0, fileName.indexOf(".json")) ||
+          fileName.slice(0, fileName.indexOf(".geojson"));
+        if(this.fileUniqueObj.hasOwnProperty(this.layerUniqueName)){
+          enableUpload = false
+          this.$message.warning("已上传过该图层,不允许重复上传!")
+        }
+
+      }
+
+      if(isZip){
+        this.layerUniqueName = fileName.slice(0, fileName.indexOf(".zip"));
+        if(this.fileUniqueObj.hasOwnProperty(this.layerUniqueName)){
+          enableUpload = false
+          this.$message.warning("已上传过该图层,不允许重复上传")
+        }
+      }
+
+      
+      return (isGeojson || isZip) && isLt50M && enableUpload;
     },
   },
   watch: {},

+ 0 - 383
src/components/common/BottomForm/UploadingDataShp1.vue

@@ -1,383 +0,0 @@
-<template>
-  <!-- 上传数据弹窗 -->
-  <el-dialog
-    title="上传数据"
-    :visible.sync="dialogVisible"
-    :before-close="handleClose"
-    width="400px"
-  >
-    <template slot="title">
-      <div class="dialogTitle">
-        <div class="dialogTitleIcon"></div>
-        请选择你要上传的文件
-      </div>
-    </template>
-    <div id="uploadingBox">
-      <el-upload
-        class="upload-demo"
-        ref="upload"
-        drag
-        :http-request="uploadSectionFile"
-        action="#"
-        :limit="1"
-        :show-file-list="false"
-      >
-        <i class="el-icon-upload"></i>
-        <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
-        <div class="el-upload__tip" slot="tip">
-          *仅支持上传zip格式的shp压缩包,json(或geojson)格式的数据
-        </div>
-      </el-upload>
-      <!-- <el-upload
-        class="upload-demo"
-        drag
-        action="https://jsonplaceholder.typicode.com/posts/"
-        :on-preview="handlePreview"
-        :on-remove="handleRemove"
-        :on-success="handleSuccess"
-        :before-remove="beforeRemove"
-        :before-upload="beforeAvatarUpload"
-        multiple
-        :on-exceed="handleExceed"
-        :file-list="fileList"
-      >
-        <i class="el-icon-upload"></i>
-        <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
-        <div class="el-upload__tip" slot="tip">
-          *仅支持Geojson格式文件,且不超过5MB
-        </div>
-      </el-upload> -->
-    </div>
-    <span slot="footer" class="dialog-footer">
-      <el-button @click="clearDialogVisible()">取 消</el-button>
-      <el-button type="primary" @click="subMitDialogVisible()">确 定</el-button>
-    </span>
-  </el-dialog>
-</template>
-
-<script>
-/**
- * 底部菜单(上传数据)组件
- * 支持geosjon格式的数据以及shp的压缩包 -- 坐标系必须为上海2000高斯投影坐标
- * @author: GAO LU
- * @Date: 2023年3月6-7日
- */
-import shp from "shpjs";
-import JsZip from "jszip";
-import iconv from "iconv-lite";
-import { open, openShp, openDbf } from "shapefile";
-import coordinate from "@/utils/coordinate";
-export default {
-  name: "UploadingData",
-  components: {},
-  data() {
-    return {
-      // 文件目标路径
-      upName: null,
-      // shp数据
-      shpFile: null,
-      shpDataList: [],
-      // 属性信息
-      shpFileAttributes: null,
-      filePath: "",
-      // 上传文件列表
-      fileList: [],
-      // 暂存上传文件数据
-      fileDataList: {},
-      // 上传数据弹窗显示状态
-      dialogVisible: false,
-    };
-  },
-  mounted() {
-    // 上传数据事件监听
-    this.$bus.$off("scsj");
-    this.$bus.$on("scsj", () => {
-      this.changeShowBottomMenusStatus();
-    });
-  },
-  destroy() {
-    // 当容器销毁时,需要停止监听该事件
-    this.$bus.$off("scsj");
-  },
-  props: [],
-  methods: {
-    // 当用户点击svg底座时,切换底部菜单显示隐藏状态。
-    changeShowBottomMenusStatus() {
-      // 打开弹窗
-      this.dialogVisible = true;
-      this.$emit("changeShowBottomMenusStatus", false);
-    },
-    // 弹窗关闭询问
-    handleClose() {
-      if (this.dialogVisible && this.fileList.length > 0) {
-        this.$confirm("确认关闭?")
-          .then((_) => {
-            this.clearDialogVisible();
-          })
-          .catch((_) => {});
-      } else {
-        this.clearDialogVisible();
-      }
-    },
-    // 上传数据关闭
-    clearDialogVisible() {
-      this.fileList = [];
-      this.fileDataList = {};
-      // 关闭弹窗
-      this.dialogVisible = false;
-      // 修改父级菜单变量(弹窗显示状态和显示底部菜单)
-      this.$emit("changeShowBottomMenusStatus", true);
-    },
-    // 上传判断
-    uploadSectionFile(params) {
-      const file = params.file;
-      const fileName = file.name;
-      const isGeojson =
-        fileName.indexOf("json") != -1 || fileName.indexOf("geojson") != -1;
-      const isZip = fileName.indexOf("zip") !== -1;
-      const isShp = fileName.indexOf("shp") !== -1;
-      this.upName = fileName; //项目中需要传文件名字,所以这里保存下来
-      if (isGeojson) {
-        console.log("读取geojson格式的数据");
-        this.readGeojson(file);
-      } else if (isZip) {
-        console.log("读取shp压缩包");
-        this.openZip(file);
-      } else {
-        this.$message.info(
-          "仅支持上传zip格式的shp压缩包,json(或geojson)格式的数据"
-        );
-      }
-
-      // if (!(isZip || isShp)) {
-      //   this.$message.error("只能上传zip、shp格式!");
-      //   this.abortLoad(); //因为手动上传,所以这里是取消上传
-      //   return false;
-      // } else {
-      //   isZip ? this.openZip(file) : this.readGeojson(file);
-      // }
-    },
-    openZip(data) {
-      let newZip = new JsZip();
-      newZip
-        .loadAsync(data, {
-          decodeFileName: function (bytes) {
-            return iconv.decode(bytes, "gbk"); // 按中文编码
-          },
-        })
-        .then((file) => {
-          // 压缩包里的内容file,files
-          const fileList = Object.keys(file.files);
-          const pattern = new RegExp(/\S\.shp$/);
-          const attrPattern = new RegExp(/\S\.dbf$/);
-          this.shpFile = fileList.find((i) => pattern.test(i));
-          this.shpFileAttributes = fileList.find((i) => attrPattern.test(i));
-          // 此处是压缩包中的shp文件,arraybuffer(此时在回调的参数中已经可以获取到上传的zip压缩包下的所有文件)
-          newZip
-            .file(this.shpFile)
-            .async("arraybuffer")
-            .then((geoContent) => {
-              let geometryInfo = geoContent;
-              newZip
-                .file(this.shpFileAttributes)
-                .async("arraybuffer")
-                .then((attrContent) => {
-                  // 文件中的内容
-                  this.shapefileOpen(geometryInfo, attrContent);
-                });
-            })
-            .catch((err) => {
-              // 是否是合法的zip包,解决rar包改后缀zip
-              console.log(err);
-              this.$message.error("请上传正确格式的文件!");
-            });
-          // zip.forEach((path, zipEntry) => {
-          //   console.log(zipEntry.name); // 输出不乱码中文
-          // });
-        });
-    },
-    // 为zip时,读取压缩包,选取shp文件
-    // 读取geojson数据
-    readGeojson(data) {
-      debugger;
-      const reader = new FileReader();
-      // reader.readAsText(data.raw,"UTF-8")
-      reader.readAsArrayBuffer(data);
-      reader.onload = (e) => {
-        let a = e.target.result;
-        this.geojsonFileOpen(this.result);
-      };
-    },
-    // 解析geojson格式的数据
-    geojsonFileOpen(content) {},
-    // 解析.shp或.dbf文件
-    shapefileOpen(geoContent, attrContent) {
-      let options = {
-        encoding: "utf8",
-      };
-      let shpDataList = [];
-
-      // 读取几何信息
-      open(geoContent, attrContent, options)
-        .then((source) =>
-          source.read().then(function log(result) {
-            if (result.done) return;
-            shpDataList.push(result.value);
-            return source.read().then(log);
-          })
-        )
-        .catch((error) => console.error(error.stack));
-
-      console.log(shpDataList, "读取到的shp数据");
-    },
-    /**
-     * 上海2000高斯投影坐标转上海2000经纬度坐标
-     */
-    latLngsTransform(latlngsAry) {
-      // 深拷贝
-      var tempLatlngsAry = JSON.parse(JSON.stringify(latlngsAry));
-      if (typeof tempLatlngsAry[0] === "number") {
-        if (tempLatlngsAry.length < 3 && tempLatlngsAry.length > 0) {
-          tempLatlngsAry = coordinate.shcj_to_wgs84(
-            tempLatlngsAry[0],
-            tempLatlngsAry[1]
-          );
-          tempLatlngsAry = [
-            tempLatlngsAry[0] - 0.19195,
-            tempLatlngsAry[1] + 0.00011,
-          ];
-
-          return tempLatlngsAry;
-        }
-        if (tempLatlngsAry.length === 3) {
-          tempLatlngsAry = coordinate.shcj_to_wgs84(
-            tempLatlngsAry[0],
-            tempLatlngsAry[1]
-          );
-          tempLatlngsAry = [
-            tempLatlngsAry[0] - 0.19195,
-            tempLatlngsAry[1] + 0.00011,
-          ];
-          return tempLatlngsAry;
-        }
-      } else {
-        for (var i = 0, l = tempLatlngsAry.length; i < l; i++) {
-          tempLatlngsAry[i] = latLngsTransform(tempLatlngsAry[i]);
-        }
-      }
-      return tempLatlngsAry;
-    },
-    // 上传数据表单提交
-    // subMitDialogVisible() {
-    //   let fileDataList = this.fileDataList;
-    //   for (let key in fileDataList) {
-    //     const dataJson = JSON.parse(fileDataList[key]);
-    //     this.uploadRENDER(dataJson);
-    //   }
-    //   setTimeout(() => {
-    //     if (map2DViewer.analysisGroups[`upload_layer_unique`]) {
-    //       this.$message.success("数据上传成功!");
-    //       map2DViewer.map.fitBounds(
-    //         map2DViewer.analysisGroups[`upload_layer_unique`].getBounds()
-    //       );
-    //     }
-    //     let options = {
-    //       id: "upload_layer_unique",
-    //       label: "我的图层1",
-    //     };
-    //     this.$bus.$emit("addUploadLayerEvent", options);
-    //   }, 1000);
-
-    //   this.clearDialogVisible();
-    // },
-    // 文件列表移除文件时
-    // handleRemove(file, fileList) {
-    //   this.fileList = fileList;
-    //   delete this.fileDataList[file.uid];
-    // },
-    // 点击文件列表中已上传的文件时
-    // handlePreview(file) {},
-    // 文件超出个数限制时
-    // handleExceed(files, fileList) {
-    // this.$message.warning(
-    //   `当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
-    //     files.length + fileList.length
-    //   } 个文件`
-    // );
-    // },
-    // 删除文件之前
-    // beforeRemove(file, fileList) {
-    //   this.$message.success(`文件${file.name}移除成功!`);
-    //   return true;
-    // },
-    // 文件上传成功时
-    // handleSuccess(response, file, fileList) {
-    //   this.getActionData(file);
-    // },
-    // 根据上传的文件渲染到地图中
-    // uploadRENDER(geoJson) {
-    //   // 呈现数据已经成功
-    //   let firstPolygon = JSON.parse(JSON.stringify(geoJson));
-    //   // let uniqueId = firstPolygon.name;
-    //   let uniqueId = `upload_layer_unique`;
-    //   if (!map2DViewer.analysisGroups[uniqueId]) {
-    //     map2DViewer.analysisGroups[uniqueId] = L.featureGroup();
-    //     map2DViewer.analysisGroups[uniqueId].addTo(map2DViewer.map);
-    //     if (!this.$store.state.selectSelectDataMap["singlePolygon"]) {
-    //       this.$store.state.selectSelectDataMap["singlePolygon"] = [];
-    //     }
-
-    //     console.log("上传文件读取到的数据", firstPolygon);
-    //     firstPolygon.features.forEach((ele, index) => {
-    //       let cid = `myLayer_${index}`;
-    //       let geometry = JSON.stringify(ele);
-    //       this.$store.state.mapMethodsCollection
-    //         .get("RENDER")
-    //         .addSinglePolygon(
-    //           geometry,
-    //           cid,
-    //           "rgb(0,255,255)",
-    //           uniqueId,
-    //           "我的图层",
-    //           "土地资源"
-    //         );
-    //     });
-    //   }
-    // },
-    // // 读取file对象内容
-    // getActionData(file) {
-    //   const __this = this;
-    //   var reader = new FileReader(); // 新建一个FileReader
-    //   reader.readAsText(file.raw, "UTF-8"); // 读取文件
-    //   reader.onload = function (evt) {
-    //     __this.fileList.push(file);
-    //     __this.fileDataList[file.uid] = evt.target.result;
-    //   };
-    // },
-    // 上传文件之前
-    // beforeAvatarUpload(file) {
-    //   const isJPG = file.name.indexOf(".geojson") === file.name.length - 8;
-    //   const isLt5M = file.size / 1024 / 1024 < 5;
-    //   if (!isJPG) {
-    //     this.$message.error("仅支持Geojson格式文件!");
-    //   }
-    //   if (!isLt5M) {
-    //     this.$message.error("上传文件大小不能超过 5MB!");
-    //   }
-    //   return isJPG && isLt5M;
-    // },
-  },
-  watch: {},
-};
-</script>
-<style lang="less" scoped>
-#uploadingBox {
-  display: flex;
-  .el-upload *:not(em) {
-    color: #f2f6fc;
-  }
-  .el-upload__tip {
-    color: #c0c4cc;
-  }
-}
-</style>

+ 7 - 1
src/components/map/MapHolder.vue

@@ -248,7 +248,13 @@ export default {
           // 不需要显示法律法规详细信息的弹窗
           $(() => {
             if ($(`#${str}_id a`)) {
-              $(`#${str}_id a`).remove();
+              $(`#${str}_id a`).eq(0).remove();
+              $(`#${str}_id a`)
+                .eq(0)
+                .click((e) => {
+                  // 触发综合分析右侧面板点击事件
+                  this.$bus.$emit("viewDetailsPopup", geojsonData);
+                });
             }
           });
           // console.log("呈现我的模型的几何数据");

+ 2 - 2
src/utils/request.js

@@ -6,7 +6,7 @@ import { VueAxios } from "./axios";
 // 创建 axios 实例
 const service = axios.create({
   // baseURL: 'http://121.43.55.7:8888',
-  timeout: 800000000, // 请求超时时间,
+  timeout: 60000, // 请求超时时间,
   headers: {
     "Content-Type": "application/form-data",
   },
@@ -14,7 +14,7 @@ const service = axios.create({
 
 const fileService = axios.create({
   baseURL: "",
-  timeout: 800000, // 请求超时时间,
+  timeout: 60000, // 请求超时时间,
   headers: {
     "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
   },

+ 167 - 61
src/views/ComprehensiveAnalysis.vue

@@ -306,7 +306,7 @@
               >
                 <template slot="title">
                   <div class="status-select" @mouseenter="panelMouseEnter(key)">
-                    <div class="title">{{ key }}</div>
+                    <el-tooltip effect="light" :content="key" placement="bottom-start"><div class="title">{{ key }}</div></el-tooltip>
                     <NewSelect
                       v-if="isSortCaseObj[key] === '预设模型'"
                       style="width: 100px"
@@ -324,7 +324,7 @@
                   :key="v.id"
                   @dblclick="locateCase(v)"
                 >
-                  <div>
+                  <div class="title-section">
                     {{
                       v.title +
                       "_" +
@@ -392,7 +392,7 @@
                   v-for="(item, index) in rightLabelData"
                   :key="item.id"
                 >
-                  <div @click="listItemClick('new', item)">
+                  <div class="title-section" @click="listItemClick('new', item)">
                     {{ item.name ? item.name : `疑点${index}` }}
                   </div>
                   <span class="operation-icon"
@@ -433,6 +433,7 @@ import publicFun from "@/utils/publicFunction.js";
 import AttributePopup from "@/components/popup/AttributePopup.vue";
 import LabelCasePopup from "@/components/popup/LabelCasePopup.vue";
 import LawPopup from "@/components/popup/LawPopup.vue";
+import coordinate from "@/utils/coordinate";
 export default {
   name: "ComprehensiveAnalysis",
   components: {
@@ -446,6 +447,7 @@ export default {
   },
   data() {
     return {
+      uploadNodeChildren: [],
       // 判断是否显示疑点筛选弹窗
       isSortCaseObj: {},
       // 存储图层构成信息
@@ -560,14 +562,7 @@ export default {
           let panelId = this.enteredPanelId;
           let mainType = this.enteredMainType;
           let sourceType = this.enteredSourceType;
-          this.changeSingleLayer(
-            val,
-            currentPageSize,
-            columnId,
-            panelId,
-            mainType,
-            sourceType
-          );
+          this.changeSingleLayer(val, currentPageSize, panelId);
         },
         handleSizeChange: (val) => {
           this.handleSizeChange(val);
@@ -831,23 +826,31 @@ export default {
     this.$bus.$off("addUploadLayerEvent");
     this.$bus.$on("addUploadLayerEvent", (data) => {
       if (this.$refs.tree) {
-        let children = [
-          {
+        if (this.uploadNodeChildren.length > 0) {
+          this.uploadNodeChildren.forEach((v) => {
+            this.handleCheckChange(v, false);
+          });
+        }
+
+        setTimeout(() => {
+          let obj = {
             id: data.id,
             label: data.label,
             mainType: "我的图层",
+            data: data.data,
             children: [],
-          },
-        ];
-        this.$refs.tree.updateKeyChildren(
-          this.firstLevelIdMap.get("我的图层").id,
-          children
-        );
-        this.expandedKeys.push(this.firstLevelIdMap.get("我的图层").id);
-        this.$refs.tree.setCheckedKeys([data.id]);
-        this.$refs.tree.setCurrentKey(data.id);
-        let nodeData = this.$refs.tree.getCurrentNode();
-        this.handleCheckChange(nodeData, true);
+          };
+          this.uploadNodeChildren.push(obj);
+          this.$refs.tree.updateKeyChildren(
+            this.firstLevelIdMap.get("我的图层").id,
+            this.uploadNodeChildren
+          );
+          this.expandedKeys.push(this.firstLevelIdMap.get("我的图层").id);
+          this.$refs.tree.setCheckedKeys([data.id]);
+          this.$refs.tree.setCurrentKey(data.id);
+          // let nodeData = this.$refs.tree.getCurrentNode();
+          this.handleCheckChange(obj, true);
+        }, 1000);
       }
     });
 
@@ -909,6 +912,7 @@ export default {
     this.$bus.$off("openMyTask");
     this.$bus.$off("openMyView");
     this.$bus.$off("caseAuditEvent2");
+    this.$bus.$off("addUploadLayerEvent");
   },
   methods: {
     /**
@@ -943,6 +947,46 @@ export default {
         return JSON.stringify(targetGeometry);
       }
     },
+    /**
+     * 上海2000高斯投影坐标转上海2000经纬度坐标
+     */
+    latLngsTransform(latlngsAry) {
+      // 深拷贝
+      let tempLatlngsAry = JSON.parse(JSON.stringify(latlngsAry));
+      if (typeof tempLatlngsAry[0] === "number") {
+        if (tempLatlngsAry.length < 3 && tempLatlngsAry.length > 0) {
+          tempLatlngsAry = coordinate.shcj_to_wgs84(
+            tempLatlngsAry[0],
+            tempLatlngsAry[1]
+          );
+          tempLatlngsAry = [
+            tempLatlngsAry[0] - 0.19195,
+            tempLatlngsAry[1] + 0.00011,
+          ];
+
+          return tempLatlngsAry;
+        }
+        if (tempLatlngsAry.length === 3) {
+          tempLatlngsAry = coordinate.shcj_to_wgs84(
+            tempLatlngsAry[0],
+            tempLatlngsAry[1]
+          );
+          tempLatlngsAry = [
+            tempLatlngsAry[0] - 0.19195,
+            tempLatlngsAry[1] + 0.00011,
+          ];
+          return tempLatlngsAry;
+        }
+      } else {
+        for (var i = 0, l = tempLatlngsAry.length; i < l; i++) {
+          tempLatlngsAry[i] = this.latLngsTransform(tempLatlngsAry[i]);
+        }
+      }
+      return tempLatlngsAry;
+    },
+    /**
+     * 叠置分析数据标准化
+     */
     overlayStandardGeojson(data) {
       if (data) {
         let geojson = {
@@ -1058,14 +1102,7 @@ export default {
             ]);
             break;
         }
-        this.changeSingleLayer(
-          1,
-          this.currentPageSize,
-          this.enteredColumnId,
-          this.enteredPanelId,
-          this.enteredMainType,
-          this.enteredSourceType
-        );
+        this.changeSingleLayer(1, this.currentPageSize, this.enteredPanelId);
       }
     },
     // 得到底部菜单疑点审计开启状态
@@ -1211,12 +1248,86 @@ export default {
       this.changeSingleLayer(
         this.currentPage,
         this.currentPageSize,
-        this.enteredColumnId,
-        this.enteredPanelId,
-        this.enteredMainType,
-        this.enteredColumnId
+        this.enteredPanelId
       );
     },
+    /**
+     * 渲染上传的疑点数据
+     * 1. 根据unique更新我的图层节点;
+     * 2. 默认打开该图层;
+     * 3. 显示疑点数目,属性数据,分页数据等信息
+     */
+    renderUploadedData(data) {
+      let uniqueId = data.id;
+      this.layerIdMap.set(uniqueId, uniqueId);
+      // 图层未初始化
+      if (!map2DViewer.analysisGroups[uniqueId]) {
+        // 生成图例时设置初始图层颜色
+        this.setLayerLegend(uniqueId, uniqueId);
+        map2DViewer.analysisGroups[uniqueId] = L.featureGroup();
+        map2DViewer.analysisGroups[uniqueId].addTo(map2DViewer.map);
+        if (!this.$store.state.selectSelectDataMap["singlePolygon"]) {
+          this.$store.state.selectSelectDataMap["singlePolygon"] = [];
+        }
+
+        let caseArr = JSON.parse(data.data).map((ele) => {
+          // 坐标转换
+          let coordinates = ele.geometry.coordinates;
+          if (coordinates.length > 0) {
+            ele.geometry.coordinates = this.latLngsTransform(coordinates);
+
+            return {
+              id: publicFun.buildGuid(uniqueId),
+              c_boolean: "未标记",
+              title: data.label,
+              mainType: "我的图层",
+              c_content: JSON.stringify(ele),
+            };
+          }
+        });
+
+        if (!this.originalDataMap.has(uniqueId)) {
+          this.originalDataMap.set(uniqueId, caseArr);
+        }
+        // 该图层疑点总数
+        this.targetLayerTotal[uniqueId] = caseArr.length;
+        // 分页组件total
+        this.paginationData.total = caseArr.length;
+        this.currentTotal += caseArr.length;
+        console.log(caseArr, "即将渲染的上传图层数据");
+        caseArr.forEach((ele) => {
+          let cid = ele.id;
+          let geometry = this.addLayerDataSource(
+            ele.c_content,
+            ele.mainType,
+            data.label
+          );
+          let defaultStatus = ele.c_boolean;
+          let color = this.collectColorMap.get(this.collectColorMapIndex);
+          this.$store.state.mapMethodsCollection
+            .get("RENDER")
+            .addSinglePolygon(
+              geometry,
+              cid,
+              color,
+              uniqueId,
+              data.mainType,
+              "",
+              defaultStatus,
+              "",
+              ""
+            );
+        });
+
+        // 激活当前展开面板
+        this.activeNames = ["myLabel", uniqueId];
+        // 用于分页数据
+        this.originalData[uniqueId] = this.originalDataMap.get(uniqueId);
+        this.isSortCaseObj[uniqueId] = data.mainType;
+        // 进行分页列表展示
+        this.changeSingleLayer(1, this.currentPageSize, uniqueId);
+      }
+    },
     getMapData(uniqueId, columnId, mainType, sourceType, layerName) {
       let layerParams = new FormData();
       layerParams = {
@@ -1348,8 +1459,6 @@ export default {
                   );
               });
 
-              // 所有数据均需要进行分页展示
-
               // 激活当前展开面板
               this.activeNames = ["myLabel", uniqueId];
               // 用于分页数据
@@ -1357,14 +1466,7 @@ export default {
               this.isSortCaseObj[uniqueId] = mainType;
 
               // 进行分页列表展示
-              this.changeSingleLayer(
-                1,
-                this.currentPageSize,
-                columnId,
-                uniqueId,
-                mainType,
-                sourceType
-              );
+              this.changeSingleLayer(1, this.currentPageSize, uniqueId);
 
               // 当前图斑数小于数据库中的图斑总数时,递归请求图斑
               if (
@@ -1414,12 +1516,11 @@ export default {
      * 切换页时改变图层数据
      * @val 当前页
      * @currentPageSize 当前面板pageSize
-     * @columnId
      * @id label_columnId
      * @mainType 所有图层/预设模型
      * @sourceType 土地资源,水资源,林地资源,全部
      */
-    changeSingleLayer(val, currentPageSize, columnId, id) {
+    changeSingleLayer(val, currentPageSize, id) {
       let uniqueId = id;
       if (map2DViewer.analysisGroups[uniqueId]) {
         this.paginationData.currentPage = val;
@@ -1431,7 +1532,7 @@ export default {
         );
 
         // 激活当前展开面板
-        this.activeNames = ["myLabel", uniqueId];
+        // this.activeNames = ["myLabel", uniqueId];
       }
     },
 
@@ -1799,7 +1900,6 @@ export default {
       this.$bus.$emit("updateModel", node);
     },
     handleDelete(node) {
-      // console.log(node, "删除节点");
       let deleteParams = {
         id: customModelIdMap.get(node.data.label).modelId,
         columnId: 49,
@@ -1926,6 +2026,13 @@ export default {
               data.label
             );
           }
+
+          // 第一级菜单是我的图层 -- 不请求接口
+          if (data.mainType === "我的图层") {
+            layerAuthorityMap.set(data.id, "有权限");
+            this.rightPanelTitle = data.label;
+            this.renderUploadedData(data);
+          }
         } else {
           if (
             this.$store.state.selectSelectDataMap["singlePolygon"] &&
@@ -2182,12 +2289,7 @@ export default {
                   this.originalDataMap.get(uniqueId);
                 this.isSortCaseObj[uniqueId] = data.mainType;
                 // 进行分页列表展示
-                this.changeSingleLayer(
-                  1,
-                  this.currentPageSize,
-                  data.columnId,
-                  uniqueId
-                );
+                this.changeSingleLayer(1, this.currentPageSize, uniqueId);
               }
             }
           );
@@ -2205,7 +2307,6 @@ export default {
     },
     // 我的模型图层取消勾选
     deleteMyModelData(data) {
-      console.log(data.id);
       // 直接删除图层组中的数据
       if (map2DViewer.analysisGroups[data.id]) {
         map2DViewer.map.removeLayer(map2DViewer.analysisGroups[data.id]);
@@ -2264,6 +2365,7 @@ export default {
         delete map2DViewer.analysisGroups[data.id];
       }
     },
+
     //显示详细信息
     viewDetailsPopup(data) {
       this.$store.state.bottomMenuIndexs.index = -1;
@@ -2289,7 +2391,7 @@ export default {
         this.boxHeight = "600";
         if (data.c_content) {
           let obj = JSON.parse(data.c_content).properties;
-    
+
           this.tableData.push(obj);
         }
       }
@@ -2366,7 +2468,6 @@ export default {
           this.$Post(this.urlsCollection.updateConllection, params).then(
             (res) => {
               if (res.code === 200) {
-               
                 this.updateCasePopupShow = false;
                 this.getUserMarkers();
                 this.$message.success("修改成功!");
@@ -2382,7 +2483,6 @@ export default {
     },
     // 修改标记 -- 仅支持修改类型和描述
     updateLabel(val) {
-      // console.log("修改标记", val);
       this.$store.state.bottomMenuIndexs.index = -1;
       this.$store.state.bottomMenuIndexs.subIndex = -1;
       this.updateCasePopupShow = true;
@@ -2401,7 +2501,6 @@ export default {
     // 删除标记
     deleteLabel(id) {
       if (localStorage.getItem("USER_ID")) {
-        // console.log("删除标记");
         let params = new FormData();
         this.$store.state.mapMethodsCollection
           .get("RENDER")
@@ -3005,6 +3104,13 @@ export default {
           border-right: 1px solid rgba(207, 222, 255, 0.2);
           border-bottom: 1px solid rgba(207, 222, 255, 0.2);
           cursor: pointer;
+          .title-section{
+            max-width: 160px;
+            overflow: hidden;
+            white-space: nowrap;
+            text-overflow: ellipsis;
+            font-size:14px;
+          }
           .normal-icon {
             position: absolute;
             right: 20px;