c0df0af6 by 杨威

默认展开到宗地节点

1 parent 9eaddfbb
...@@ -79,13 +79,22 @@ export default { ...@@ -79,13 +79,22 @@ export default {
79 } 79 }
80 }, 80 },
81 openMenu(e, item) { 81 openMenu(e, item) {
82 if (item.isZD!=undefined) { 82 if (item.zdbsm) {
83 var x = e.pageX; 83 var x = e.pageX;
84 var y = e.pageY; 84 var y = e.pageY;
85 this.$emit("changeIsZD", item.isZD); 85 this.$emit("changeIsZD", true);
86 this.$emit("changeTop", y); 86 this.$emit("changeTop", y);
87 this.$emit("changeLeft", x); 87 this.$emit("changeLeft", x);
88 this.$emit("changeVisible", true); 88 this.$emit("changeVisible", true);
89 } else if (item.zrzbsm) {
90 var x = e.pageX;
91 var y = e.pageY;
92 this.$emit("changeIsZD", false);
93 this.$emit("changeTop", y);
94 this.$emit("changeLeft", x);
95 this.$emit("changeVisible", true);
96 } else {
97 return;
89 } 98 }
90 // this.top = y; 99 // this.top = y;
91 // this.left = x; 100 // this.left = x;
......
...@@ -34,10 +34,10 @@ ...@@ -34,10 +34,10 @@
34 <lineItem 34 <lineItem
35 v-if="item.expand && item.children.length > 0" 35 v-if="item.expand && item.children.length > 0"
36 v-on="$listeners" 36 v-on="$listeners"
37 @changeTop="changeTop" 37 @changeTop="changeTop"
38 @changeLeft="changeLeft" 38 @changeLeft="changeLeft"
39 @changeVisible="changeVisible" 39 @changeVisible="changeVisible"
40 @changeIsZD="changeIsZD" 40 @changeIsZD="changeIsZD"
41 :list="item.children" 41 :list="item.children"
42 :visible="visible" 42 :visible="visible"
43 :size="size" 43 :size="size"
...@@ -78,8 +78,8 @@ export default { ...@@ -78,8 +78,8 @@ export default {
78 formatData: [], 78 formatData: [],
79 visible: false, 79 visible: false,
80 top: 0, 80 top: 0,
81 left: 0, 81 left: 0,
82 isZD:true 82 isZD: true,
83 }; 83 };
84 }, 84 },
85 watch: { 85 watch: {
...@@ -91,6 +91,7 @@ export default { ...@@ -91,6 +91,7 @@ export default {
91 created() { 91 created() {
92 console.log("lineTree create"); 92 console.log("lineTree create");
93 this.preDealData(this.pd); 93 this.preDealData(this.pd);
94 this.expandTreeItemById(["6b5af49d803f97baf06afb897de257f5"]);
94 }, 95 },
95 96
96 methods: { 97 methods: {
...@@ -109,17 +110,20 @@ export default { ...@@ -109,17 +110,20 @@ export default {
109 }, 110 },
110 preDealData(list) { 111 preDealData(list) {
111 list.forEach((x) => { 112 list.forEach((x) => {
112 if (!x.expand) this.$set(x, "expand", false); 113 if (!x.expand) this.$set(x, "expand", true);
113 if (x.children && x.children.length > 0) this.preDealData(x.children); 114 if (x.children && x.children.length > 0) {
115 this.preDealData(x.children);
116 }
114 }); 117 });
115 return list; 118 return list;
116 }, 119 },
117 // 根据id展开树的具体项 120 // 根据id展开树的具体项
118 expandTreeItemById(idList) { 121 expandTreeItemById(idList) {
122 debugger;
119 let _this = this; 123 let _this = this;
120 function loopTree(list) { 124 function loopTree(list) {
121 list.forEach((x) => { 125 list.forEach((x) => {
122 if (idList.includes(x.id)) { 126 if (idList.includes(x.zdbsm)) {
123 _this.$set(x, "expand", true); 127 _this.$set(x, "expand", true);
124 } else { 128 } else {
125 _this.$set(x, "expand", false); 129 _this.$set(x, "expand", false);
...@@ -129,6 +133,7 @@ export default { ...@@ -129,6 +133,7 @@ export default {
129 return list; 133 return list;
130 } 134 }
131 this.formatData = loopTree(this.pd); 135 this.formatData = loopTree(this.pd);
136 console.log(this.formatData, "this.formatData");
132 }, 137 },
133 itemClick(item) { 138 itemClick(item) {
134 item.expand = !item.expand; 139 item.expand = !item.expand;
......