gaosp
2024-01-13 c936d0112f5c4a2cab145161937eada674939372
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<template>
    <Home>
        <template slot="menu">
            <div class="menu-container">
                <ul class="">
                    <!-- <li :class="activeId ==='1' ? 'active' : ''" @click="navigateTo('1')">状态监控</li> -->
                    <li :class="activeId ==='preview' ? 'active' : ''" @click="navigateTo('preview')">大屏展示</li>
                    <li :class="activeId ==='2' ? 'active' : ''" @click="navigateTo('2')">
                        <span>
                            车间地图
                        </span>
                        
                    </li>
                    <li :class="activeId ==='3' ? 'active' : ''" @click="navigateTo('3')">
                        <span>
                            车间列表<i class="el-icon-caret-bottom"></i>
                        </span>
                        <ul v-if="showSub" class="sub">
                            <li v-for="item in workshopList" :key="item.id" @click.stop="navigateTo('workshop',item)">{{ item.name }}</li>
                        </ul>
                    </li>
                    <li :class="activeId ==='4' ? 'active' : ''" @click="navigateTo('4')">
                        <span>
                            设备保养<i class="el-icon-caret-bottom"></i>
                        </span>
                        <ul v-if="showSub">
                            <li @click="navigateTo('maintenance', {style: 1})">日常保养</li>
                            <li @click="navigateTo('maintenance', {style: 2})">一级</li>
                            <li @click="navigateTo('maintenance', {style: 3})">二级</li>
                            <li @click="navigateTo('maintenance', {style: 4})">三级</li>
                        </ul>
                    </li>
                    <!-- <li :class="activeId ==='5' ? 'active' : ''" @click="navigateTo('5')">
                        <span>
                            报表生成<i class="el-icon-caret-bottom"></i>
                        </span>
                        <ul v-if="showSub">
                            <li>2厂</li>
                            <li>2厂</li>
                            <li>2厂</li>
                            <li>2厂</li>
                        </ul>
                    </li> -->
                    <!-- <li :class="activeId ==='6' ? 'active' : ''" @click="navigateTo('6')">班次设置</li> -->
                    <li :class="activeId ==='7' ? 'active' : ''" @click="navigateTo('7')">工件信息</li>
                    <li :class="activeId ==='8' ? 'active' : ''" @click="navigateTo('8')">
                        <span>
                            更多菜单<i class="el-icon-caret-bottom"></i>
                        </span>
                        <ul v-if="showSub">
                            <li @click="navigateTo('ledger')">台账</li>
                            <li @click="navigateTo('deviceType')">设备类型管理</li>
                        </ul>
                    </li>
                </ul>
                <div class="user">
                    <span>Admin</span>
                    <img @click="logout" src="./logout.png" alt="">
                </div>
            </div>
        </template>
        <template slot="content">
            <router-view></router-view>
        </template>
    </Home>
</template>
<script>
import { mapGetters } from 'vuex'
import Home from '@/components/home/index'
export default {
    components: {
        Home
    },
    data () {
        return {
            activeId: '',
            showSub: false,
        }
    },
    computed: {
        ...mapGetters(['userInfo','workshopList'])
    },
    methods: {
        logout() {
            this.$store.dispatch('LogOut').then(() => {
                // location.reload() // 为了重新实例化vue-router对象 避免bug
                this.$router.push('/')
            })
        },
        navigateTo (name,v) {
            let routers = {
                2: 'map',
                workshop: 'workshop',
                maintenance: 'maintenance',
                7: 'component',
                ledger: 'ledger',
                deviceType: 'deviceType',
                preview: 'preview'
            }
            
            if (['3','4','5','8'].includes(name)) {
                if (name === this.activeId) {
                    this.showSub = !this.showSub
                } else {
                    this.showSub = true
                }
                this.activeId = name
            } else {
                this.activeId = name
                let params = {}
                let query = {}
                if ('workshop' === name) {
                    params.id = v.id
                    query.name = v.name
                }
                if (name === 'maintenance') {
                    params.style = v.style
                }
                this.$router.push({name: routers[name],params: params,query: query})
                this.$nextTick(() => {
                    this.showSub = false
                })
            }
            
        }
    },
}
</script>
<style lang="scss" scoped>
 
 
.menu-container {
    margin-left: auto;
    display: flex;
    line-height: 37px;
    & > ul {
        flex: 0 1 auto;
        color: #AEAFAF;
        font-size: 18px;
        list-style: none;
        display: flex;
        & > li {
            cursor: pointer;
            background: #27394E;
            padding: 0 12px;
            white-space: nowrap;
            text-overflow: ellipsis;
            position: relative;
            ul {
                display: none;
                font-size: 14px;
            }
            // user-select:none;
        }
        & > li.active {
            & > ul {
                padding: 0;
                margin: 0;
                padding-inline: 0;
                list-style: none;
                min-width: 100%;
                display: block;
                position: absolute;
                left: 0;
                z-index: 999;
                background: rgba(0,0,0,.5);
                text-align: center;
                border: 1px solid #0170bc;
                li {
                    padding: 4px;
                    margin: 0;
                    color: #FFF;
                }
                li:hover {
                    color: #68D9FF;
                }
            }
        }
        li~li {
            margin-left: 10px;
        }
        li.active {
            color: #68D9FF;
        }
    }
    .user {
        margin-left: 30px;
        width: 114px;
        height: 37px;
        background: rgba(38, 36, 36, 0.58);
        border-radius: 19px;
        display: flex;
        align-items: center;
        cursor: pointer;
        span {
            padding: 0 13px;
            color: #FFFFFF;
            font-size: 16px;
        }
        img {
            width: 20px;
            height: 20px;
        }
    }
}
</style>