基于亦庄一张图系统为模板创建的Demo系统
surprise
2024-04-16 f51e0da4c397110b2916a9dc371b6d745042029d
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
<template>
  <div class="LeftBox">
    <el-tree
      :data="LeftTreeData"
      node-key="id"
      ref="leftTree"
      style="min-width: 160px"
      show-checkbox
      :props="defaultProps"
      accordion
      @check="setLeftCheckTree"
    ></el-tree>
  </div>
  <div class="rightBox">
    <el-tree
      :data="rightTreeData"
      node-key="id"
      ref="rightTree"
      style="min-width: 160px"
      show-checkbox
      accordion
      :props="defaultProps"
      @check="setRightCheckTree"
    ></el-tree>
  </div>
</template>
 
<script lang="ts" setup>
import { ref, onMounted, nextTick } from "vue";
import historyLayer from "../assets/js/historyLayer";
import { ElTree } from "element-plus";
import type Node from "element-plus/es/components/tree/src/model/node";
interface Tree {
  id: number;
  label: string;
  children?: Tree[];
}
const leftTree = ref<InstanceType<typeof ElTree>>();
const rightTree = ref<InstanceType<typeof ElTree>>();
const defaultProps = {
  children: "children",
  label: "name",
};
const LeftTreeData = ref([]);
const rightTreeData = ref([]);
const setLeftCheckTree = (treeNode, data) => {
  if (data.checkedKeys.length == 0) {
    historyLayer.removeLeftMapLayer();
    return;
  }
  if (data.checkedKeys.length == 1) {
    historyLayer.LeftInit(treeNode);
    return;
  }
  if (data.checkedKeys.length > 1) {
    leftTree.value.setCheckedKeys([treeNode.id], true);
    historyLayer.LeftInit(treeNode);
  }
};
const setRightCheckTree = (treeNode, data) => {
  if (data.checkedKeys.length == 0) {
    historyLayer.removeLeftMapLayer();
    return;
  }
  if (data.checkedKeys.length == 1) {
    historyLayer.RightInit(treeNode);
    return;
  }
  if (data.checkedKeys.length > 1) {
    rightTree.value.setCheckedKeys([treeNode.id], true);
    historyLayer.RightInit(treeNode);
  }
};
onMounted(() => {
  LeftTreeData.value = historyData;
  rightTreeData.value = historyData;
});
</script>
 
<style scoped lang="less">
.LeftBox {
  position: absolute;
  right: 51%;
  top: 135px;
  z-index: 40;
  position: absolute;
  background: url("../assets/img/menu/listbg.png") no-repeat;
  background-size: 100% 100%;
  padding: 10px;
  border-radius: 5px;
  height: 400px;
}
.rightBox {
  position: absolute;
  left: 51%;
  top: 135px;
  z-index: 40;
  position: absolute;
  background-image: url("../assets/img/menu/listbg.png");
  background-size: 100% 100%;
  padding: 10px;
  border-radius: 5px;
  height: 400px;
}
/* yhadd */
.el-tree {
  background: transparent;
  color: white;
  height: 93%;
  overflow: auto;
}
 
.el-tree /deep/ .el-tree-node__content {
  background-color: transparent !important;
}
 
.el-tree /deep/ .el-tree-node__content:hover {
  background-color: rgba(255, 255, 255, 0.4) !important;
}
 
.el-tree /deep/ .is-current > .el-tree-node__content {
  background-color: rgba(255, 255, 255, 0.4) !important;
  font-size: 14px;
}
 
::-webkit-scrollbar {
  /*滚动条整体样式*/
  width: 5px;
  /*高宽分别对应横竖滚动条的尺寸*/
  height: 8px;
  scrollbar-arrow-color: red;
}
 
/* 滚动条 */
::-webkit-scrollbar-thumb {
  border-radius: 5px;
  -webkit-box-shadow: inset 0 0 5px rgba(218, 218, 218, 0.2);
  box-shadow: inset 0 0 5px rgba(218, 218, 218, 0.2);
  background: rgba(218, 218, 218, 0.5);
  scrollbar-arrow-color: red;
}
 
/* 滚动槽 */
::-webkit-scrollbar-track {
  -webkit-box-shadow: inset 0 0 5px rgba(218, 218, 218, 0.2);
  box-shadow: inset 0 0 5px rgba(218, 218, 218, 0.2);
  border-radius: 0;
  background: rgba(218, 218, 218, 0.1);
}
.el-tree {
  /deep/ .el-tree-node {
    // css 让父级不现实checkbox
    .is-leaf + .el-checkbox .el-checkbox__inner {
      display: inline-block;
    }
    .el-checkbox .el-checkbox__inner {
      display: none;
    }
  }
}
 
.el-tree .TreeNodeClass {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  font-size: 14px;
  padding-right: 8px;
  justify-content: space-between !important;
}
</style>