1
1
<template >
2
- <div class = " cl-menu-tree " >
3
- < el-popover
4
- placement =" bottom-start"
5
- trigger =" click"
6
- width =" 500px"
7
- popper-class =" popper -menu-tree"
8
- >
9
- <el-input v-model =" keyword" size =" small" >
10
- <template #prefix >
11
- <i class =" el-input__icon el-icon-search" ></i >
12
- </template >
13
- </el-input >
2
+ <el-popover
3
+ :visible = " visible "
4
+ placement =" bottom-start"
5
+ trigger =" click"
6
+ width =" 500px"
7
+ popper-class =" cl -menu-tree"
8
+ >
9
+ <el-input v-model =" keyword" size =" small" >
10
+ <template #prefix >
11
+ <i class =" el-input__icon el-icon-search" ></i >
12
+ </template >
13
+ </el-input >
14
14
15
+ <div class =" cl-menu-tree__scroller scroller1" >
15
16
<el-tree
16
17
ref =" treeRef"
17
18
node-key =" menuId"
26
27
:filter-node-method =" filterNode"
27
28
@current-change =" onCurrentChange"
28
29
/>
30
+ </div >
29
31
30
- <template #reference >
31
- <el-input v-model =" name" readonly placeholder =" 请选择" />
32
- </template >
33
- </el-popover >
34
- </div >
32
+ <template #reference >
33
+ <el-input v-model =" name" readonly placeholder =" 请选择" @click =" visible = true" />
34
+ </template >
35
+ </el-popover >
35
36
</template >
36
37
37
38
<script lang="ts">
@@ -54,6 +55,8 @@ export default defineComponent({
54
55
// 关键字
55
56
const keyword = ref <string >(" " );
56
57
58
+ const visible = ref <boolean >(false );
59
+
57
60
// 树形列表
58
61
const list = ref <any []>([]);
59
62
@@ -66,6 +69,7 @@ export default defineComponent({
66
69
// 绑定值回调
67
70
function onCurrentChange({ id }: any ) {
68
71
emit (" update:modelValue" , id );
72
+ visible .value = false ;
69
73
}
70
74
71
75
// 刷新列表
@@ -107,6 +111,7 @@ export default defineComponent({
107
111
});
108
112
109
113
return {
114
+ visible ,
110
115
keyword ,
111
116
list ,
112
117
expandedKeys ,
@@ -122,11 +127,16 @@ export default defineComponent({
122
127
</script >
123
128
124
129
<style lang="scss">
125
- .popper -menu-tree {
130
+ .cl -menu-tree {
126
131
box-sizing : border-box ;
127
132
128
133
.el-input {
129
134
margin-bottom : 10px ;
130
135
}
136
+
137
+ & __scroller {
138
+ max-height : 400px ;
139
+ overflow : hidden auto ;
140
+ }
131
141
}
132
142
</style >
0 commit comments