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
| <template>
| <div class="InfoPopup">
| <Popup
| ref="pop"
| v-for="(data, index) in PopupData"
| :key="data.id"
| title="图层管理"
| :maxHeight="data.maxHeight || '500px'"
| @close="close(data.id)"
| :left="data.left || left"
| :top="data.top || top + index * 42 + 'px'"
| >
| <div class="treeContainer">
| <el-tree
| ref="tree"
| :data="treeData"
| show-checkbox
| node-key="id"
| draggable
| :expand-on-click-node="false"
| :auto-expand-parent="false"
| :default-expanded-keys="defaultExpanded"
| :default-checked-keys="defaultCheck"
| >
| </el-tree>
| </div>
| </Popup>
| </div>
| </template>
|
| <script>
| import Popup from './Popup.vue';
| export default {
| name: 'maplayer',
| components: {
| Popup,
| },
| data() {
| return {
| // 弹窗数据
| PopupData: ['maplayer'],
| left: 'calc(100% - 330px)',
| top: 10,
| treeData: [],
| defaultCheck: [],
| defaultExpanded: [],
| selectNode: undefined,
| rightClickMenuDisplay: false,
| rightClickMenuStyle: {},
| isClickParent: false,
| isNewFold: false,
| newFoldName: undefined,
| mergeNode: false,
| };
| },
| computed: {},
| mounted() {
| this.treeData([
| { id: '82A0C3DE', name: '影像', children: [] },
| { id: '82C3DE', name: '地形', children: [] },
| { id: '4FE10400', name: '模型', children: [] },
| { id: '0A51CF71', name: '矢量', children: [] },
| ]);
| },
| methods: {
| // 关闭所有
| closeAll() {
| this.PopupData.forEach((item) => {
| item.close && item.close();
| });
| this.PopupData = [];
| },
| // 关闭弹窗
| close(id) {
| let index = this.PopupData.findIndex((item) => {
| return item.id === id;
| });
| let data = this.PopupData.splice(index, 1)[0];
| data.close && data.close();
| },
| // 打开弹窗
| open(title, value, style = {}) {
| this.PopupData.push({
| id: this.createRandomId(),
| title,
| value,
| ...style,
| });
| let index = this.PopupData.length - 1;
| this.$nextTick(() => {
| this.$refs.pop[index].open();
| });
| return this.PopupData[index];
| },
| // 随机id
| createRandomId() {
| return (
| (Math.random() * 10000000).toString(16).substr(0, 4) +
| '-' +
| new Date().getTime() +
| '-' +
| Math.random().toString().substr(2, 5)
| );
| },
| },
| };
| </script>
|
| <style scoped lang="less">
| .text {
| margin-left: 15px;
| margin-right: 15px;
| }
| </style>
|
|