Commit 77ae9ecf by jack

增加分线程处理数据

1 parent 26c7d56f
...@@ -3,7 +3,11 @@ const getters = { ...@@ -3,7 +3,11 @@ const getters = {
getTreeData:state => { getTreeData:state => {
let arr = state.vehicleTree; let arr = state.vehicleTree;
let n = localStorage.getItem('carTree') ? JSON.parse(localStorage.getItem('carTree')) : [] 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 @@ ...@@ -17,7 +17,7 @@
</div> </div>
<div class="treebox"> <div class="treebox">
<!-- <span class="el-icon-loading"></span> --> <!-- <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 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> </el-tree>
</div> </div>
...@@ -132,7 +132,6 @@ export default { ...@@ -132,7 +132,6 @@ export default {
let _this = this; let _this = this;
let o = _this.$route.query; let o = _this.$route.query;
let n = _this.$store.getters.getTreeData; let n = _this.$store.getters.getTreeData;
//判断 //判断
...@@ -146,9 +145,10 @@ export default { ...@@ -146,9 +145,10 @@ export default {
if (n && n.length > 0) { if (n && n.length > 0) {
// console.log(n,"浏览器存储"); // console.log(n,"浏览器存储");
//_this.flatData(n); //_this.flatData(n);
_this.mainWorker(n); _this.mainWorker(n).then(res => {
_this.showTree = true; _this.showTree = true;
_this.loading = false; _this.loading = false;
});
return false; return false;
} }
_this.getMenuTree(); _this.getMenuTree();
...@@ -430,7 +430,6 @@ export default { ...@@ -430,7 +430,6 @@ export default {
let _tree = []; let _tree = [];
let _allTree = []; let _allTree = [];
that.addEventListener("message", function (e) { that.addEventListener("message", function (e) {
console.log(e);
if (e.data) { if (e.data) {
flatData(e.data); flatData(e.data);
that.postMessage({ tree: _tree, data: _allTree }); that.postMessage({ tree: _tree, data: _allTree });
...@@ -470,7 +469,6 @@ export default { ...@@ -470,7 +469,6 @@ export default {
let webWorker = new Worker(window.URL.createObjectURL(_workerJs)); let webWorker = new Worker(window.URL.createObjectURL(_workerJs));
webWorker.postMessage(data); webWorker.postMessage(data);
webWorker.onmessage = function (e) { webWorker.onmessage = function (e) {
console.log(e);
let _obj = e.data; let _obj = e.data;
_this.treedata = _obj.tree; _this.treedata = _obj.tree;
_this.newArr = _obj.data; _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!