96009bc9
hexiaodong
hxd
|
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
|
<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 {
|