Forráskód Böngészése

上传多个图层时重复添加bug修复

Bella 2 éve
szülő
commit
4ed78c1a9e

+ 15 - 21
src/components/common/BottomForm/UploadingDataShp.vue

@@ -28,10 +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)格式的数据,且不超过50MB ;<br/>
+          * 仅支持上传zip格式的shp压缩包, json(或geojson)格式的数据,且不超过50MB
+          ;<br />
           * 仅支持上传上海2000投影坐标数据 ;
         </div>
-        
       </el-upload>
     </div>
     <span slot="footer" class="dialog-footer">
@@ -214,16 +214,12 @@ export default {
 
     // 上传表单提交,开始渲染上传的图层数据,并且添加到我的图层
     subMitDialogVisible() {
-      setTimeout(() => {
-        // 一次只允许上传一个图层
-        for (let key in this.fileUniqueObj) {
-          // 获取疑点图层数据
-          const datajson = this.fileUniqueObj[key];
-          this.uploadRender(datajson, key);
-        }
+      if (this.layerUniqueName != "") {
+        const datajson = this.fileUniqueObj[this.layerUniqueName];
+        this.uploadRender(datajson, this.layerUniqueName);
         this.$message.success("数据上传成功,开始渲染!");
         this.clearDialogVisible();
-      }, 500);
+      }
     },
     uploadRender(datajson, uniqueId) {
       if (datajson.length === 0) {
@@ -243,7 +239,7 @@ export default {
     handleRemove(file, fileList) {
       this.fileList = fileList;
       delete this.fileDataList[file.uid];
-      delete this.fileUniqueObj[this.layerUniqueName]
+      delete this.fileUniqueObj[this.layerUniqueName];
     },
     // 点击文件列表中已上传的文件时
     handlePreview(file) {},
@@ -274,28 +270,26 @@ export default {
         this.$message.error("上传文件大小不能超过 100MB!");
       }
 
-      let enableUpload = true
+      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 (this.fileUniqueObj.hasOwnProperty(this.layerUniqueName)) {
+          enableUpload = false;
+          this.$message.warning("已上传过该图层,不允许重复上传!");
         }
-
       }
 
-      if(isZip){
+      if (isZip) {
         this.layerUniqueName = fileName.slice(0, fileName.indexOf(".zip"));
-        if(this.fileUniqueObj.hasOwnProperty(this.layerUniqueName)){
-          enableUpload = false
-          this.$message.warning("已上传过该图层,不允许重复上传")
+        if (this.fileUniqueObj.hasOwnProperty(this.layerUniqueName)) {
+          enableUpload = false;
+          this.$message.warning("已上传过该图层,不允许重复上传");
         }
       }
 
-      
       return (isGeojson || isZip) && isLt50M && enableUpload;
     },
   },

+ 13 - 6
src/views/ComprehensiveAnalysis.vue

@@ -306,7 +306,12 @@
               >
                 <template slot="title">
                   <div class="status-select" @mouseenter="panelMouseEnter(key)">
-                    <el-tooltip effect="light" :content="key" placement="bottom-start"><div class="title">{{ key }}</div></el-tooltip>
+                    <el-tooltip
+                      effect="light"
+                      :content="key"
+                      placement="bottom-start"
+                      ><div class="title">{{ key }}</div></el-tooltip
+                    >
                     <NewSelect
                       v-if="isSortCaseObj[key] === '预设模型'"
                       style="width: 100px"
@@ -392,7 +397,10 @@
                   v-for="(item, index) in rightLabelData"
                   :key="item.id"
                 >
-                  <div class="title-section" @click="listItemClick('new', item)">
+                  <div
+                    class="title-section"
+                    @click="listItemClick('new', item)"
+                  >
                     {{ item.name ? item.name : `疑点${index}` }}
                   </div>
                   <span class="operation-icon"
@@ -848,9 +856,8 @@ export default {
           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);
+        }, 500);
       }
     });
 
@@ -3104,12 +3111,12 @@ 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{
+          .title-section {
             max-width: 160px;
             overflow: hidden;
             white-space: nowrap;
             text-overflow: ellipsis;
-            font-size:14px;
+            font-size: 14px;
           }
           .normal-icon {
             position: absolute;