topMenu.vue
2.58 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
<template >
<div>
<el-tabs v-model="activeName">
<el-tab-pane :name="item.path" v-for="(item,i) in menuList" :key="i">
<span slot="label" class="tab-menu-title" @click="handleClick(item)">
<i :class="item.icon +' left-icon'"></i>
{{generateTitle(item.vueName,item.fullName)}}</span>
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import { mapGetters, mapState } from 'vuex'
import { generateTitle } from '@/utils/i18n'
export default {
data() {
return {
activeName: ''
}
},
computed: {
...mapGetters(['menuList']),
...mapState({
slideClass: state => state.settings.slideClass,
})
},
created() {
this.setDefault()
},
methods: {
handleClick(item) {
if (item.type === 1) {
this.$store.commit('user/SET_LEFTMENULIST', item.children || [])
} else if (item.type === 6 || (item.type === 7 && item.linkTarget === "_blank")) {
window.open(item.path)
} else {
this.$router.push(item.path)
}
},
setDefault() {
const currPath = this.$route.path
const modelId = this.$route.meta.modelId || ''
if (!modelId) return
for (let i = 0; i < this.menuList.length; i++) {
const e = this.menuList[i];
let boo = false
const loop = data => {
if (modelId === data.id) {
boo = true
this.activeName = e.path
if (e.type === 1) this.$store.commit('user/SET_LEFTMENULIST', e.children || [])
return
}
if (data.children && Array.isArray(data.children) && data.children.length) {
for (let j = 0; j < data.children.length; j++) {
loop(data.children[j])
}
}
}
loop(e)
if (boo) break
}
},
generateTitle
},
}
</script>
<style lang="scss" scoped>
.top-menu {
padding-right: 20px;
>>> .el-tabs {
.el-tabs__header {
height: 60px !important;
margin: 0 !important;
.el-tabs__nav {
height: 60px;
line-height: 60px;
.el-tabs__active-bar {
display: none;
}
}
}
.el-tabs__content {
display: none;
}
.el-tabs__nav-wrap::after {
display: none;
}
.el-tabs__nav-prev,
.el-tabs__nav-next {
line-height: 60px;
}
.el-tabs__item {
height: 60px;
}
}
.tab-menu-title {
display: inline-block;
line-height: 60px;
height: 60px;
display: flex;
align-items: center;
}
.left-icon {
font-size: 20px;
width: 20px;
margin-right: 10px;
}
}
</style>