c0df0af6 by 杨威

默认展开到宗地节点

1 parent 9eaddfbb
......@@ -79,13 +79,22 @@ export default {
}
},
openMenu(e, item) {
if (item.isZD!=undefined) {
if (item.zdbsm) {
var x = e.pageX;
var y = e.pageY;
this.$emit("changeIsZD", item.isZD);
this.$emit("changeIsZD", true);
this.$emit("changeTop", y);
this.$emit("changeLeft", x);
this.$emit("changeVisible", true);
} else if (item.zrzbsm) {
var x = e.pageX;
var y = e.pageY;
this.$emit("changeIsZD", false);
this.$emit("changeTop", y);
this.$emit("changeLeft", x);
this.$emit("changeVisible", true);
} else {
return;
}
// this.top = y;
// this.left = x;
......
......@@ -79,7 +79,7 @@ export default {
visible: false,
top: 0,
left: 0,
isZD:true
isZD: true,
};
},
watch: {
......@@ -91,6 +91,7 @@ export default {
created() {
console.log("lineTree create");
this.preDealData(this.pd);
this.expandTreeItemById(["6b5af49d803f97baf06afb897de257f5"]);
},
methods: {
......@@ -109,17 +110,20 @@ export default {
},
preDealData(list) {
list.forEach((x) => {
if (!x.expand) this.$set(x, "expand", false);
if (x.children && x.children.length > 0) this.preDealData(x.children);
if (!x.expand) this.$set(x, "expand", true);
if (x.children && x.children.length > 0) {
this.preDealData(x.children);
}
});
return list;
},
// 根据id展开树的具体项
expandTreeItemById(idList) {
debugger;
let _this = this;
function loopTree(list) {
list.forEach((x) => {
if (idList.includes(x.id)) {
if (idList.includes(x.zdbsm)) {
_this.$set(x, "expand", true);
} else {
_this.$set(x, "expand", false);
......@@ -129,6 +133,7 @@ export default {
return list;
}
this.formatData = loopTree(this.pd);
console.log(this.formatData, "this.formatData");
},
itemClick(item) {
item.expand = !item.expand;
......