Quellcode durchsuchen

add export jsondata

haojianlong vor 5 Jahren
Ursprung
Commit
54e9543e47
1 geänderte Dateien mit 22 neuen und 1 gelöschten Zeilen
  1. 22 1
      src/components/business_space/graphy/business.vue

+ 22 - 1
src/components/business_space/graphy/business.vue

@@ -82,6 +82,9 @@
             <el-button @click="smallSize" type="primary">- 缩小</el-button>
             <el-button @click="suitableSize" type="primary">合适比例</el-button>
             <el-button @click="bigSize" type="primary">+ 放大</el-button>
+            <el-button @click="exportJson" type="primary" icon="el-icon-download">
+                导出json文件
+            </el-button>
         </div>
     </div>
     <div
@@ -453,8 +456,11 @@
                             // console.log(unGzipData)
                             // console.log(unGzipData, "atob")
                             data = unGzipData
+                            //导出json文件
+                            _this.exportJsonData = JSON.stringify(data);
+                            _this.jsonId = jsonId.split('.')[0];
                             _this.dataMax = tools.getPoint(data);
-                            console.log(unGzipData, data)
+
                             if (data.WallList && data.WallList.length) {
                                 tools.changeMap(data.WallList, -1, "PointList");
                             }
@@ -1231,6 +1237,21 @@
                         this.$message.error("请求出错");
                         this.loading.errorNum++;
                     });
+            },
+            //导出json文件
+            exportJson(){
+                //下载为json文件
+                var Link = document.createElement('a');
+                Link.download = `${this.jsonId}.json`;
+                Link.style.display = 'none';
+                // 字符内容转变成blob地址
+                var blob = new Blob([this.exportJsonData]);
+                Link.href = URL.createObjectURL(blob);
+                // 触发点击
+                document.body.appendChild(Link);
+                Link.click();
+                // 然后移除
+                document.body.removeChild(Link);
             }
         },
         filters: {