lineTree.vue
10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
<template>
<div
class="content column-start-center reTree_box"
:style="{ fontSize: (size || 14) + 'px', lineHeight: (size || 14) + 'px', width: (islpb ? '200':'374') + 'px' }"
>
<div
class="column-start-center basic_layer"
:class="islpb ? 'white_layer':''"
v-for="(item, index) in formatData"
:key="index"
>
<div
class="row-flex-start basic_banner"
:class="{
active_color: item.expand && item.children.length > 0,
}"
@click="itemClick(item)"
>
<div
class="reTree_icon"
:style="{
height: (size || 14 * 1.2) + 'px',
width: (size || 14 * 1.2) + 'px',
}"
:class="{
reTree_default_icon: item.children.length === 0,
reTree_collapse_icon: item.expand && item.children.length > 0,
reTree_expand_icon: !item.expand && item.children.length > 0,
}"
></div>
<div class="layer_text nowrap" @contextmenu.prevent="openMenu($event, item)">{{ item.mc }}</div>
</div>
<lineItem
v-if="item.expand && item.children.length > 0"
v-on="$listeners"
@ownerMethod="ownerMethod(arguments)"
@changeTop="changeTop"
@changeZdData="changeZdData"
@changeLeft="changeLeft"
@changeVisible="changeVisible"
@changeLpbVisible="changeLpbVisible"
@changeIsZD="changeIsZD"
@changeCreateVisible="changeCreateVisible"
@changeDzVisible="changeDzVisible"
:list="item.children"
:visible="visible"
:size="size"
:islpb="islpb"
:formatData="formatData"
></lineItem>
</div>
<ul
v-show="visible"
:style="{ left: left + 'px', top: top + 'px' }"
class="contextmenu"
>
<li>定位</li>
<li>导入图形</li>
<li>导出图形</li>
<li v-show="isZD">导入属性</li>
<li v-show="!isZD">导入楼盘</li>
<li>重叠分析</li>
<li v-show="isZD" @click="openCreateDialog">添加定着物</li>
<li @click="deleteByBsm()">删除</li>
</ul>
<ul
v-show="dzVisible"
:style="{ left: left + 'px', top: top + 'px' }"
class="contextmenu"
>
<li @click="openCreateDialog">新建自然幢</li>
</ul>
<ul
v-show="createVisible"
:style="{ left: left + 'px', top: top + 'px' }"
class="contextmenu"
>
<li @click="openCreateDialog">新建宗地</li>
</ul>
<ul
v-show="lpbvisible"
:style="{ left: lpbleft + 'px', top: lpbtop + 'px' }"
class="contextmenu"
>
<li v-show="zdData.type == 'zrz'" @click="openLpbDialog('ljz')">添加逻辑幢</li>
<li v-show="zdData.type == 'zrz' || zdData.type == 'ljz'" @click="openLpbDialog('zdy')">添加幢单元</li>
<li v-show="zdData.type == 'zrz' || zdData.type == 'ljz' || zdData.type == 'zdy'" @click="openLpbDialog('ch')">添加层户</li>
</ul>
<!-- 添加定着物弹框 -->
<el-dialog title="新建" :visible.sync="dialogVisible" width="40%">
<Create @closeDialog="closeDialog" :auth="true"></Create>
</el-dialog>
</div>
</template>
<script>
import lineItem from "./lineItem.vue";
import {deleteZdInfoByBsm} from "../../api/zd";
import Create from "../../views/panel/create/index";
export default {
inheritAttrs: false,
props: {
pd: {},
size: {
type: Number,
default: 14,
},
islpb:{
type: Boolean,
default: false,
}
},
components: { lineItem,Create },
data() {
return {
selectedDetail: {},
timer: {},
formatData: [],
visible: false,
top: 0,
left: 0,
isZD: true,
zdData:{},
dialogVisible:false,
//控制楼盘表
lpbvisible: false,
lpbtop: 0,
lpbleft: 0,
//控制新建宗地菜单
createVisible:false,
//多幢
dzVisible:false
};
},
watch: {
pd(n, o) {
this.formatData = this.preDealData(n);
console.log(this.formatData);
},
lpbvisible(value) {
if (value) {
document.body.addEventListener("click", this.closeMenu);
} else {
document.body.removeEventListener("click", this.closeMenu);
}
},
dzVisible(value) {
if (value) {
document.body.addEventListener("click", this.closeMenu);
} else {
document.body.removeEventListener("click", this.closeMenu);
}
},
// createVisible(value) {
// if (value) {
// document.body.addEventListener("click", this.closeMenu);
// } else {
// document.body.removeEventListener("click", this.closeMenu);
// }
// }
},
created() {
console.log("lineTree create");
this.preDealData(this.pd);
// this.expandTreeItemById(["6b5af49d803f97baf06afb897de257f5"]);
},
methods: {
// 改变菜单数据
changeVisible(data) {
this.visible = data;
},
changeZdData(data) {
this.zdData = data
},
changeTop(data) {
this.top = data;
this.lpbtop = data;
},
changeLeft(data) {
this.left = data;
this.lpbleft = data;
},
changeIsZD(data) {
this.isZD = data;
},
changeLpbVisible(data) {
this.lpbvisible = data;
},
changeCreateVisible(data){
this.createVisible = true;
},
//多幢
changeDzVisible(data){
this.dzVisible = data
},
//添加定着物
openCreateDialog(){
console.log(this.zdData,'this.zdData');
this.dialogVisible = true;
this.$store.state.zdbsm = this.zdData.zdbsm;
this.$store.state.dzbsm = this.zdData.bsm;
},
//关闭添加定着物弹框
closeDialog() {
this.dialogVisible = false;
},
preDealData(list) {
//楼盘表目录树没有expand属性
list.forEach((x) => {
if (x.expand == undefined) this.$set(x, "expand", true);
if (x.children && x.children.length > 0) {
this.preDealData(x.children);
}
});
return list;
},
// 根据id展开树的具体项
expandTreeItemById(idList) {
let _this = this;
function loopTree(list) {
list.forEach((x) => {
if (idList.includes(x.zdbsm)) {
_this.$set(x, "expand", true);
} else {
_this.$set(x, "expand", false);
}
if (x.children && x.children.length > 0) loopTree(x.children);
});
return list;
}
this.formatData = loopTree(this.pd);
console.log(this.formatData, "this.formatData");
},
itemClick(item) {
// item.expand = item.expand == undefined? true:!item.expand;
console.log(item,'item');
console.log(this.formatData,'this.formatData');
this.formatData.forEach(i=>{
if(i.bsm != item.bsm){
i.expand = false
}else{
// i.expand = !item.expand
}
})
item.expand = !item.expand;
// this.$emit("itemClick", item);
},
//给所有权类型添加子节点
ownerMethod(arr){
let item = arr[0];
let list = arr[1]
this.formatData.forEach(i=>{
if (i.bsm == item.xzq){
i.children.forEach(j=>{
if (j.bsm == item.djq) {
j.children.forEach(k=>{
if(k.bsm == item.djzq){
k.children.forEach(n=>{
if(n.dm == item.dm){
this.$nextTick(()=>{
n.children = list;
})
}
})
}
})
}
})
}
})
console.log(this.formatData,'formatData');
},
//自然幢右键点击事件
openMenu(e,item){
console.log(item,'右键item');
this.lpbleft = e.pageX;
this.lpbtop = e.pageY;
this.zdData = item;
this.changeLpbVisible(true);
},
//关闭右键菜单
closeMenu(){
this.lpbvisible = false;
this.dzVisible = false;
// this.createVisible = false;
},
//楼盘表右键菜单项打开父组件弹框
openLpbDialog(type){
this.$parent.openLpbDialog(this.zdData,type);
},
detailDoubleClick(data) {
clearTimeout(this.timer);
this.selectedDetail = data;
this.$emit("detailDoubleClick", data);
},
//右键菜单的删除
deleteByBsm(){
console.log(this.zdData.zdbsm);
let params={"bsm":this.zdData.zdbsm,"type":this.zdData.type}
deleteZdInfoByBsm(params)
.then((res) => {
if(res.code=200){
this.$message({
message: res.message,
type: "success",
});
} else {
this.$message({
message: res.message,
type: "warning",
});
}
})
.catch((error) => {});
},
},
};
</script>
<style lang="less" scoped>
.content {
height: 100%;
width: 100%;
overflow-y: scroll;
overflow-x: hidden;
}
.column-start-center {
display: flex;
display: -webkit-flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
}
.row-flex-start {
display: flex;
display: -webkit-flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.nowrap {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
// .active_color {
// color: #ffffff;
// }
.reTree_box {
// overflow-y: auto;
}
.reTree_icon {
width: 17px;
height: 17px;
margin-right: 10px;
}
.basic_layer {
width: 100%;
position: relative;
color: #ffffff;
cursor: pointer;
moz-user-select: -moz-none;
-moz-user-select: none;
-o-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
.layer_text {
flex: 1;
}
}
.white_layer {
color: black!important;
}
.first_vertical_line {
content: "";
position: absolute;
width: 1px;
left: 6px;
top: 17px;
background: #c3c5c8;
}
.basic_banner {
position: relative;
width: 100%;
padding-bottom: 13px;
}
.second_layer {
position: relative;
width: 100%;
cursor: pointer;
padding-left: 25px;
}
.second_layer::before {
content: "";
position: absolute;
height: 1px;
width: 16px;
left: 9px;
top: 9px;
background: #c3c5c8;
}
.linkLine_default::after {
content: "";
position: absolute;
height: 100%;
width: 1px;
left: 9px;
top: 0px;
background: #c3c5c8;
}
.linkLine_first::after {
content: "";
position: absolute;
/* 为了触顶 */
top: -14px;
height: calc(100% + 14px);
width: 1px;
left: 9px;
background: #c3c5c8;
}
// 上半截
.linkLine_half_top::after {
content: "";
position: absolute;
height: 24px;
top: -14px;
width: 1px;
left: 9px;
background: #c3c5c8;
}
.linkLine_last::after {
content: "";
position: absolute;
height: 9px;
width: 1px;
left: 9px;
top: 0px;
background: #c3c5c8;
}
.reTree_collapse_icon {
background: url("../../assets/images/reTree_collapse_.svg") no-repeat center
center;
background-size: contain;
}
.reTree_default_icon {
background: url("../../assets/images/reTree_default_.svg") no-repeat center
center;
background-size: contain;
}
.reTree_expand_icon {
background: url("../../assets/images/reTree_expand_.svg") no-repeat center
center;
background-size: contain;
}
.reTree_focus_icon {
background: url("../../assets/images/reTree_focus_.svg") no-repeat center
center;
background-size: contain;
}
</style>