LeftSideMenuLv2.vue
2.08 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
<template>
<div class="com-left-side-menu-lv2">
<GLScroll class="com-left-side-menu-lv2-scroll-y">
<el-menu class="flex-1 none-border" background-color="#fff" active-text-color="#409EFF" text-color="#999" :default-openeds="cur.openeds" :default-active="cur.active" :collapse-transition="false" ref="menus">
<LeftSideMenuLv2Item></LeftSideMenuLv2Item>
</el-menu>
</GLScroll>
</div>
</template>
<script>
import { currentId } from './mixins/index'
import { mapGetters } from 'vuex'
export default {
name: 'LeftSideMenuLv2',
mixins: [currentId],
inject: ['bus', 'isPop'],
created() {
this.bus.$on('menuOpenedsChanged', this.handleMenuOpenedsChanged)
},
mounted() {
this.handleCurrentChange(this.current)
},
beforeDestroy() {
this.bus.$off('menuOpenedsChanged', this.handleMenuOpenedsChanged)
},
computed: {
...mapGetters(['menu'])
},
watch: {
current: {
handler(n) {
this.handleCurrentChange(n)
}
}
},
data() {
return {
cur: {
openeds: [],
active: ''
}
}
},
methods: {
handleCurrentChange({ lv1, lv2, lv3 }) {
this.cur.active = `${lv1}-${lv2}-${lv3}`
},
handleMenuOpenedsChanged({ menus }) {
if (this.menu.isCollapse && !this.isPop) return
const _ids = menus.map(({ id, children = [] }) => {
if (children.noHidden().length) {
return id
}
})
if (this.cur.openeds.toString() == _ids.toString()) return
this.cur.openeds = _ids
}
}
}
</script>
<style lang="scss" scoped>
@import '~@/assets/style/collapse.scss';
.com-left-side-menu-lv2 {
width: 100%;
user-select: none;
overflow-y: auto;
flex: 1;
// width: calc(#{$menu_width} - #{$menu_width_collapse});
::v-deep.el-menu {
height: 100%;
width: calc(#{$menu_width} - #{$menu_width_collapse});
}
&-scroll-y {
::v-deep.el-scrollbar__wrap {
margin-bottom: 0 !important;
.el-scrollbar__view {
min-height: 52px;
max-height: calc(100vh - #{$logo-height});
}
}
height: 100%;
}
}
</style>