|
@@ -48,6 +48,8 @@ export default {
|
|
|
filePath: "",
|
|
|
// 上传文件列表
|
|
|
fileList: [],
|
|
|
+ // 暂存上传文件数据
|
|
|
+ fileDataList: {},
|
|
|
// 上传数据弹窗显示状态
|
|
|
dialogVisible: false
|
|
|
};
|
|
@@ -73,12 +75,20 @@ export default {
|
|
|
},
|
|
|
// 弹窗关闭询问
|
|
|
handleClose() {
|
|
|
- if (this.dialogVisible) {
|
|
|
+ if (this.dialogVisible && this.fileList.length > 0) {
|
|
|
+ this.$confirm("确认关闭?")
|
|
|
+ .then(_ => {
|
|
|
+ this.clearDialogVisible();
|
|
|
+ })
|
|
|
+ .catch(_ => {});
|
|
|
+ } else {
|
|
|
this.clearDialogVisible();
|
|
|
}
|
|
|
},
|
|
|
// 上传数据关闭
|
|
|
clearDialogVisible() {
|
|
|
+ this.fileList = [];
|
|
|
+ this.fileDataList = {};
|
|
|
// 关闭弹窗
|
|
|
this.dialogVisible = false;
|
|
|
// 修改父级菜单变量(弹窗显示状态和显示底部菜单)
|
|
@@ -86,6 +96,11 @@ export default {
|
|
|
},
|
|
|
// 上传数据表单提交
|
|
|
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("数据上传成功!");
|
|
@@ -102,11 +117,11 @@ export default {
|
|
|
},
|
|
|
// 文件列表移除文件时
|
|
|
handleRemove(file, fileList) {
|
|
|
- console.log("删除数据中移除文件", file, fileList);
|
|
|
+ this.fileList = fileList;
|
|
|
+ delete this.fileDataList[file.uid];
|
|
|
},
|
|
|
// 点击文件列表中已上传的文件时
|
|
|
handlePreview(file) {
|
|
|
- console.log(file);
|
|
|
},
|
|
|
// 文件超出个数限制时
|
|
|
handleExceed(files, fileList) {
|
|
@@ -136,7 +151,6 @@ export default {
|
|
|
this.$store.state.selectSelectDataMap["singlePolygon"] = [];
|
|
|
}
|
|
|
let firstPolygon = JSON.parse(JSON.stringify(geoJson));
|
|
|
- console.log("上传文件读取到的数据", firstPolygon);
|
|
|
firstPolygon.features.forEach((ele, index) => {
|
|
|
let cid = `myLayer_${index}`;
|
|
|
let geometry = JSON.stringify(ele);
|
|
@@ -148,14 +162,12 @@ export default {
|
|
|
},
|
|
|
// 读取file对象内容
|
|
|
getActionData(file) {
|
|
|
- // console.log();
|
|
|
const __this = this;
|
|
|
var reader = new FileReader(); // 新建一个FileReader
|
|
|
reader.readAsText(file.raw, "UTF-8"); // 读取文件
|
|
|
reader.onload = function (evt) {
|
|
|
- //读取文件完毕执行此函数
|
|
|
- const dataJson = JSON.parse(evt.target.result);
|
|
|
- __this.uploadRENDER(dataJson);
|
|
|
+ __this.fileList.push(file);
|
|
|
+ __this.fileDataList[file.uid] = evt.target.result;
|
|
|
};
|
|
|
},
|
|
|
// 上传文件之前
|