LeftSideMenuLv1.vue
2.92 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
<template>
<div class="com-left-side-menu-lv1">
<GLScroll class="side-bar-menu-scroll-y">
<div class="menu-lv1-item-wrap">
<LeftSideMenuLv1Item v-for="item in menuList" :key="item.id" :menuData="item"></LeftSideMenuLv1Item>
</div>
</GLScroll>
<el-popover
v-if="showPop && menu.isCollapse"
ref="pop"
:append-to-body="true"
:popper-options="{
boundariesElement: 'body',
gpuAcceleration: true,
positionFixed: true,
preventOverflow: true
}"
:reference="reference"
@hide="hide()"
placement="right-start"
:visible-arrow="false"
width="160"
:open-delay="500"
trigger="hover"
popper-class="el-submenu-popper-base-left-side-menu"
>
<LeftSideMenuLv2></LeftSideMenuLv2>
</el-popover>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'LeftSideMenuLv1',
inject: ['bus'],
provide() {
return {
isPop: true //LeftSideMenuLv2 组件判断是否POPover内
}
},
props: {
menuList: {
type: Array,
default: () => []
},
bus: {
type: Object,
default: () => {}
}
},
computed: {
...mapGetters(['menu'])
},
data() {
return {
reference: {},
// 控制渲染条件
showPop: false
}
},
mounted() {
this.bus.$on('mouseenter', this.mouseenter)
},
beforeDestroy() {
this.bus.$off('mouseenter', this.mouseenter)
},
methods: {
mouseenter(reference, onReady) {
this.showPop = false
this.$nextTick(() => {
this.reference = reference
this.$nextTick(() => {
// 等待显示的popover销毁后再 重新渲染新的popover
this.showPop = true
this.$nextTick(() => {
// 此时才能获取refs引用
this.$refs.pop.doShow()
this.$nextTick(() => {
onReady()
this.$nextTick(() => this.$refs.pop.updatePopper())
})
})
})
})
},
hide() {
// this.showPop = false
}
}
}
</script>
<style lang="scss">
$width: 160px;
@mixin popup_width {
width: $width !important;
min-width: $width !important;
}
// .el-menu--vertical {
.el-popover.el-submenu-popper-base-left-side-menu {
padding: 0 !important;
margin: 0 !important;
// left: calc(#{$menu_width_collapse} + 1px) !important;
border: none !important;
box-shadow: 0 6px 20px 0 #7a7a7a33;
> .com-left-side-menu-lv2 {
border-radius: 4px;
}
}
// }
</style>
<style lang="scss" scoped>
.com-left-side-menu-lv1 {
position: relative;
width: $menu_width_collapse;
height: 100%;
.side-bar-menu-scroll-y {
/deep/.el-scrollbar__wrap {
margin-bottom: 0 !important ;
}
height: calc(100vh - #{$logo-height + 36px});
}
// border-right: 1px solid #f5f7fa;
.menu-lv1-item-wrap {
display: flex;
flex-direction: column;
gap: 16px;
}
}
</style>