Commit 77ae9ecf by jack

增加分线程处理数据

1 parent 26c7d56f
......@@ -3,7 +3,11 @@ const getters = {
getTreeData:state => {
let arr = state.vehicleTree;
let n = localStorage.getItem('carTree') ? JSON.parse(localStorage.getItem('carTree')) : []
return arr || n;
if(!arr || arr.length<=0){
arr = n;
}
return arr;
}
}
......
......@@ -17,7 +17,7 @@
</div>
<div class="treebox">
<!-- <span class="el-icon-loading"></span> -->
<div class="layer" v-if="!showTree">正在加载中...</div>
<div class="layer" v-if="!showTree"> <i class="el-icon-loading"></i> 正在加载中...</div>
<el-tree v-if="showTree" :data="treedata" :default-expanded-keys="expandedKey" :props="defaultProps" show-checkbox node-key="id" ref="tree" highlight-current lazy :load="loadNode">
</el-tree>
</div>
......@@ -132,7 +132,6 @@ export default {
let _this = this;
let o = _this.$route.query;
let n = _this.$store.getters.getTreeData;
//判断
......@@ -146,9 +145,10 @@ export default {
if (n && n.length > 0) {
// console.log(n,"浏览器存储");
//_this.flatData(n);
_this.mainWorker(n);
_this.showTree = true;
_this.loading = false;
_this.mainWorker(n).then(res => {
_this.showTree = true;
_this.loading = false;
});
return false;
}
_this.getMenuTree();
......@@ -430,7 +430,6 @@ export default {
let _tree = [];
let _allTree = [];
that.addEventListener("message", function (e) {
console.log(e);
if (e.data) {
flatData(e.data);
that.postMessage({ tree: _tree, data: _allTree });
......@@ -470,7 +469,6 @@ export default {
let webWorker = new Worker(window.URL.createObjectURL(_workerJs));
webWorker.postMessage(data);
webWorker.onmessage = function (e) {
console.log(e);
let _obj = e.data;
_this.treedata = _obj.tree;
_this.newArr = _obj.data;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!