Commit f4df38c8 by jack

修复bug

1 parent 9d41b271
...@@ -12,10 +12,6 @@ ...@@ -12,10 +12,6 @@
</el-option> </el-option>
</el-select> </el-select>
</div> </div>
<!-- <div slot="btns-type">
<el-button type="primary" round @click="checkAll">全选</el-button>
<el-button round @click="reset">重置</el-button>
</div> -->
</rule-form> </rule-form>
</div> </div>
<div class="treebox"> <div class="treebox">
...@@ -23,7 +19,7 @@ ...@@ -23,7 +19,7 @@
<div class="layer" v-if="!showTree"> <div class="layer" v-if="!showTree">
<i class="el-icon-loading"></i> 正在加载中... <i class="el-icon-loading"></i> 正在加载中...
</div> </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="treeId" ref="tree" highlight-current lazy :load="loadNode">
</el-tree> </el-tree>
</div> </div>
</div> </div>
...@@ -40,7 +36,6 @@ import { ...@@ -40,7 +36,6 @@ import {
getTenantList, getTenantList,
getMenuTree, getMenuTree,
addVehicleType, addVehicleType,
editVehicleType,
GETVEHICLEINFO, GETVEHICLEINFO,
} from "services/vehicletype"; } from "services/vehicletype";
export default { export default {
...@@ -108,6 +103,8 @@ export default { ...@@ -108,6 +103,8 @@ export default {
tenantListElement: {}, tenantListElement: {},
type: 1, type: 1,
typeList: [], typeList: [],
vehicleId: "",
checkedKeys: [],
}; };
}, },
computed: { computed: {
...@@ -126,17 +123,13 @@ export default { ...@@ -126,17 +123,13 @@ export default {
let o = _this.$route.query; let o = _this.$route.query;
let n = _this.$store.getters.getTreeData; let n = _this.$store.getters.getTreeData;
this.vehicleId = o.id;
//判断 //判断
this.getTenantList(); this.getTenantList();
setTimeout(function () { setTimeout(function () {
// let n = localStorage.getItem("carTree")
// ? JSON.parse(localStorage.getItem("carTree"))
// : [];
if (n && n.length > 0) { if (n && n.length > 0) {
// console.log(n,"浏览器存储");
//_this.flatData(n);
_this.mainWorker(n).then((res) => { _this.mainWorker(n).then((res) => {
if (o.id) { if (o.id) {
_this.getInfo(o.id); _this.getInfo(o.id);
...@@ -166,17 +159,6 @@ export default { ...@@ -166,17 +159,6 @@ export default {
} }
}, },
methods: { methods: {
// 获取页面详情的接口
editVehicleType(params) {
editVehicleType(params).then((res) => {
if (res.code == "200") {
this.addUpdateForm.name = res.data.name || "暂无";
this.addUpdateForm.initOrganize = res.data.tenantId;
this.addUpdateForm.enableStatus =
res.data.enableStatus == 2 ? false : true;
}
});
},
// 获取租户列表 // 获取租户列表
getTenantList(params) { getTenantList(params) {
getTenantList(params).then((res) => { getTenantList(params).then((res) => {
...@@ -194,60 +176,35 @@ export default { ...@@ -194,60 +176,35 @@ export default {
_this.mainWorker(res.data).then((e) => { _this.mainWorker(res.data).then((e) => {
let _obj = e.data; let _obj = e.data;
_this.$store.commit("updateVehicleTree", _obj.data); _this.$store.commit("updateVehicleTree", _obj.data);
if (_this.vehicleId) {
_this.getInfo(_this.vehicleId);
}
_this.showTree = true; _this.showTree = true;
_this.loading = false; _this.loading = false;
}); });
this.showTree = true; // this.showTree = true;
this.loading = false; // this.loading = false;
}); });
}, },
// 获取选中菜单数组
getCheckedKeys() {
//this.addUpdateForm.menuIdList = this.$refs.tree.getCheckedKeys();
},
//重置
reset() {
// this.$refs.tree.setCheckedKeys([]);
// this.getCheckedKeys();
},
// 异步加载树数据 // 异步加载树数据
loadNode(node, resolve) { loadNode(node, resolve) {
let arr = []; let arr = [];
let id = node.key; let id = node.key;
// console.log(node, "选中的node"); let _list = this.newArr;
if (node.level === 0) { let _types = { 0: "first_", 1: "second_", 2: "three_", 3: "four_" };
console.log(node);
if (node.level == 0) {
id = 0; id = 0;
} }
// 动态加载第四层数据 console.log(id);
// if (node.level === 3) {
// let params = { seriesId: node.key }; arr = _list.filter((item) => {
// //请求第四层数据 let _pass = item.pid == id && item.level == node.level;
// geMenuTreeLeaf(params).then((res) => { return _pass;
// if (res.code != 200) {
// this.$message({
// type: "error",
// message: res.message,
// });
// return false;
// }
// console.log(res.data, "good");
// let forthList = res.data.map((item) => {
// return {
// ...item,
// id: item.carTypeId,
// };
// });
// //渲染第四层数据
// resolve(forthList);
// });
// }
arr = this.newArr.filter((item) => {
return item.pid == id;
}); });
// console.log(arr, "过滤之后");
resolve(arr); resolve(arr);
}, },
...@@ -255,7 +212,6 @@ export default { ...@@ -255,7 +212,6 @@ export default {
//保存按钮,提交当前表单 //保存按钮,提交当前表单
submitForm() { submitForm() {
let _this = this; let _this = this;
//this.getCheckedKeys();
_this.$refs.addUpdateForm.$children[0].validate((valid) => { _this.$refs.addUpdateForm.$children[0].validate((valid) => {
if (!valid) { if (!valid) {
return false; return false;
...@@ -346,9 +302,19 @@ export default { ...@@ -346,9 +302,19 @@ export default {
let typeList = o.typeIds; let typeList = o.typeIds;
console.log(new Date().getTime()); console.log(new Date().getTime());
_this.treeMainWorker(o).then((j) => { _this.treeMainWorker(o).then((j) => {
console.log(j); console.log(_this.newArr);
_this.expandedKey = j; _this.expandedKey = j;
_this.$refs.tree.setCheckedKeys(typeList); // _this.checkedKeys = []
// _this.checkedKeys = o.typeIds;
let _arr = [];
typeList.map((k) => {
_arr.push("four_" + k);
});
// 防止多勾选
setTimeout(function () {
_this.$refs.tree.setCheckedKeys(_arr);
}, 10);
}); });
console.log(new Date().getTime()); console.log(new Date().getTime());
...@@ -365,6 +331,7 @@ export default { ...@@ -365,6 +331,7 @@ export default {
let that = this; let that = this;
let _tree = []; let _tree = [];
let _allTree = []; let _allTree = [];
let _types = { 0: "first_", 1: "second_", 2: "three_", 3: "four_" };
that.addEventListener("message", function (e) { that.addEventListener("message", function (e) {
if (e.data) { if (e.data) {
flatData(e.data); flatData(e.data);
...@@ -379,15 +346,14 @@ export default { ...@@ -379,15 +346,14 @@ export default {
(arr || []).forEach((item) => { (arr || []).forEach((item) => {
item.pid = id || 0; item.pid = id || 0;
item.level = i; item.level = i;
if (item.childs === null) { //console.log(item.id)
item.leaf = true; item.treeId = _types[i] + item.id;
}
n.push(item); n.push(item);
if (!id) { if (!id) {
_tree.push(item); _tree.push(item);
} }
item.childs && item.childs.length > 0 item.childs && item.childs.length > 0
? flatData(item.childs, item.id, i + 1) ? flatData(item.childs, item.treeId, i + 1)
: ""; : "";
//item.childs = ""; //如果扁平化后的数组需要显示父子层级,可以把这一项删除 //item.childs = ""; //如果扁平化后的数组需要显示父子层级,可以把这一项删除
}); });
...@@ -425,8 +391,6 @@ export default { ...@@ -425,8 +391,6 @@ export default {
creatTreeWorker() { creatTreeWorker() {
let myWorker = function () { let myWorker = function () {
let that = this; let that = this;
let _tree = [];
let _allTree = [];
that.addEventListener("message", function (e) { that.addEventListener("message", function (e) {
if (!e.data) { if (!e.data) {
return false; return false;
...@@ -434,43 +398,50 @@ export default { ...@@ -434,43 +398,50 @@ export default {
console.log(e.data); console.log(e.data);
let _obj = e.data; let _obj = e.data;
let list = _obj.list; let list = _obj.list;
let typeList = _obj.typeList; let typeList = _obj.typeList || [];
let _earr = []; let _earr = [];
let _brand = []; let _brand = [];
typeList.map((k) => {
let m, b, f;
//寻找当前元素 // 筛选第四级
let n = list.find((j) => j.id == k && j.level == 3); let _four = list.filter((k) => {
let idx = typeList.findIndex((j) => j == k.id && k.level == 3);
return idx >= 0;
});
// 找第三级 // 筛选第四级
if (n) { let _three = list.filter((k) => {
m = list.find((j) => j.id == n.pid && j.level == 2); let idx = (_four || []).findIndex(
//_series.push(m); (j) => j.pid == k.treeId && k.level == 2
_earr.push(m.id); );
} return idx >= 0;
});
// 找第二级 // 筛选第二级
if (m) { let _second = list.filter((k) => {
b = list.find((j) => j.id == m.pid && j.level == 1); let idx = (_three || []).findIndex(
//_subBrand.push(b); (j) => j.pid == k.treeId && k.level == 1
_earr.push(b.id); );
} return idx >= 0;
});
// 找第一级 // 筛选第一级
if (b) { let _first = list.filter((k) => {
f = list.find((j) => { let idx = (_second || []).findIndex(
return j.id == b.pid && j.level == 0; (j) => j.pid == k.treeId && k.level == 0
);
return idx >= 0;
}); });
let _idx = _brand.findIndex((v) => v.id == f.id); let arr = _second.concat(_first, _three);
if (_idx < 0) { arr.map((k) => {
_brand.push(f); _earr.push(k.treeId);
_earr.push(f.id);
}
}
}); });
//console.log(arr);
//console.log(_first)
//console.log(_second)
console.log(_earr);
that.postMessage({ brand: _brand, expanded: _earr }); that.postMessage({ brand: _brand, expanded: _earr });
}); });
}; };
...@@ -493,8 +464,6 @@ export default { ...@@ -493,8 +464,6 @@ export default {
webWorker.postMessage(oParams); webWorker.postMessage(oParams);
webWorker.onmessage = function (e) { webWorker.onmessage = function (e) {
let _obj = e.data; let _obj = e.data;
// _this.treedata = _obj.tree;
// _this.newArr = _obj.data;
_this.showTree = true; _this.showTree = true;
resolve(_obj.expanded); resolve(_obj.expanded);
}; };
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!