he wei
2025-06-06 895129470d7ee48183fc15b9ee18ef0880503e5d
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
<template>
    <el-menu :default-active="acTabs">
        <template v-for="menu in rsMenus">
            <el-submenu v-if="menu.childrens" :key="menu.name" :index="menu.name">
                <template slot="title">
                    <i v-if="menu.icon" :class="menu.icon"></i>
                    <span>{{ menu.label }}</span>
                </template>
                <el-menu-item v-for="child in menu.childrens" :key="child.name" :index="child.name" @click="select(child)">
                    {{ child.label }}
                </el-menu-item>
            </el-submenu>
            <el-menu-item v-else :index="menu.name" :key="menu.name" @click="select(menu)">
                <div class="submenu__title">
                    <i class="el-icon-s-home"></i>
                    <span slot="title">{{ menu.label }}</span>
                </div>
            </el-menu-item>
        </template>
    </el-menu>
</template>
 
<script>
export default {
    name: 'PageNav',
    props: {
        status:{
            type:Boolean,
            default() {
                return false
            },
        },
        menus: {
            type: Array,
            default() {
                return []
            },
            
        },
    },
    data() {
        return {
            acTabs: this.$route.name
        }
    },
    watch: {
        '$route'(to) {
            this.acTabs = to.name
        }
    },
    methods: {
        select(data) {
            if(!this.status){
                let url = window.location.hostname + ":8090/screen/index.html";
                    if (process.env.NODE_ENV == "dev") {
                        url = " http://localhost:8081/";
                    }
                    // 根据数据跳转
                    if (data.target) {
                        let userId = sessionStorage.getItem("userId");
                        window.open(url + data.src + "?userId=" + userId);
                        return;
                    }
                    if (this.$store.state.tagsView.cachedViews.indexOf(data.name) == -1) {
                        this.$router.push(data.src)
                    } else {
                        this.$store.state.tagsView.visitedViews.map(item => {
                            if (item.name == data.name) {
                                this.$router.push(item.path)
                                this.$store.dispatch('app/closeSideBar', false)
                            }
                        })
                    }
            }
        },
    },
    computed: {
        rsMenus() {
            let rs = [];
            let menus = this.menus;
            menus.forEach(menu => {
                if (menu.enableduse) {
                    let tmp = {};
                    Object.keys(menu).forEach(key => {
                        if (key != 'childrens') {
                            tmp[key] = menu[key];
                        }
                    });
                    if (menu.childrens) {
                        tmp.childrens = [];
                        menu.childrens.forEach(children => {
                            if (children.enableduse) {
                                tmp.childrens.push(children);
                            }
                        });
                    }
                    rs.push(tmp);
                }
            });
            rs = rs.filter(item => {
                if (item.noChild || item.childrens.length > 0) {
                    return true;
                } else {
                    return false;
                }
            });
            return rs;
        }
    },
}
</script>
 
<style scoped>
</style>