SubNav.vue
1.63 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
<template>
<div class="scrm-base-sub-nav">
<el-tabs v-model="activeName" @tab-click="handleClick()">
<el-tab-pane :label="item.title" :name="item.path" v-for="item in subNavs" :key="item.id"></el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'SubNav',
data() {
return {
activeName: '',
subNavs: []
}
},
mounted() {},
methods: {
handleClick() {}
},
computed: {
...mapGetters(['app'])
},
watch: {
activeName(n) {
if (n.startsWith('/')) {
this.$router.push(n)
}
},
'app.currentNav2': {
handler(v) {
if (!v) return
const sub = v.children
if (sub && sub.length) {
this.subNavs = sub.filter(item => !item.hidden)
}
const curPage = this.app.currentPage
if (curPage) {
const nav2 = this.app.currentNav2
if (nav2 && curPage.id.startsWith(nav2.id)) {
this.activeName = curPage.path
return
}
}
if (this.subNavs && this.subNavs.length) {
this.activeName = this.subNavs[0].path
}
},
immediate: true
}
}
}
</script>
<style lang="scss" scoped>
@import '~@/assets/style/variables.scss';
.scrm-base-sub-nav {
/deep/.el-tabs {
&__nav-wrap {
&::after {
opacity: 0;
}
}
&__item {
&.is-active,
&:hover {
color: $main-color;
}
font-weight: 400;
color: #717171;
height: 36px;
line-height: 36px;
}
&__active-bar {
background-color: $main-color;
}
}
}
</style>