whychw
2020-10-09 d4094eb607fb006383ac7155ce281f9150b02183
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
207
208
209
210
<template>
    <div class="page-header">
        <div class="page-header-left">
            <div class="nav">
                <ul>
                    <li @click="showBattTree">
                        <i class="el-icon-s-home"></i>
                        <a href="javascript:;">电池组列表</a>
                    </li>
                    <li 
                    v-for="(nav, key) in navs" 
                    :key="key"
                    :class="{'nav_active': key==$store.state.navActive}"
                    @click="handleNavClick(key, nav.to)">
                        <i :class="nav.icon"></i>
                        <a href="javascript:;">{{nav.txt}}</a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="page-header-content">
            <!-- <div class="page-header-title">大屏数据监控</div> -->
            <!-- <div class="page-header-subtitle">{{$store.getters.getFullName}}</div> -->
            <div class="page-header-title">{{$store.getters.getFullName}}</div>
        </div>
        <div class="page-header-right">
            <div class="btn_grp">
                <div class="btn_3d" v-if="'/history' != $route.path" @click="showSettings">告警参数设置</div>
                <div class="btn_3d" @click="back">综合页面</div>
            </div>
            <div class="page-header-time">{{time}}</div>
        </div>
        <el-drawer
        title="我是标题"
        custom-class="theme-dark"
        size="20rem"
        :visible.sync="drawer"
        :withHeader="false"
        direction="ltr">
            <home-tree ref="battTree" @select-click="treeSelect"></home-tree>
        </el-drawer>
    </div>
</template>
 
<script>
import HomeTree from '../components/HomeTree'
 
export default {
    components: {
        HomeTree
    },
    data() {
        return {
            time: 'xxxx年xx月xx日-xx时xx分xx秒',
            interval: '',
            active: 0,
            drawer: false,
            navs: [
                {
                    icon: 'el-icon-video-camera-solid',
                    to: '/',
                    txt: '实时监控'
                },
                {
                    icon: 'el-icon-s-marketing',
                    to: '/history',
                    txt: '历史监控'
                }
            ],
        }
    },
    methods: {
        startInterval() {
            var date = new Date().format("yyyy年MM月dd日-hh时mm分ss秒");
            this.time = date;
            this.interval = setInterval(()=>{
                var date = new Date().format("yyyy年MM月dd日-hh时mm分ss秒");
                this.time = date;
            }, 1000);
        },
        back () {
            window.open('/DyEnvir_system/', '_self');
        },
        handleNavClick: function(key, to) {
            if(this.$store.state.navActive != key) {
                this.$store.state.navActive = key;
                if(to) {
                    this.$router.replace({
                        path: to
                    });
                }
            }
            
        },
        treeSelect: function(data) {
            // 修改名称
            this.$store.dispatch('changeBattGroup', data);
            // 关闭面板
            this.drawer = false;
        },
        showBattTree () {
            this.drawer = true;
            this.$nextTick(() => {
                this.$refs['battTree'].setCurrent(this.$store.state.battGroup.BattGroupId);
            });
        }
        ,showSettings () {
            this.$event.$emit('showSettings');
        }
    },
    mounted(){
        // 启动时间计时器
        this.startInterval();
    },
    destroyed() {
        clearInterval(this.interval);
    }
}
</script>
 
<style scoped>
.page-header {
    height: 4rem;
    background: url('../assets/images/head_bg.png') no-repeat;
    background-size: 100% 100%;
    position: relative;
}
.page-header-left,
.page-header-right {
    position: absolute;
    top: 0;
    height: 2.5rem;
}
.page-header-left {
    left: 0;
}
.page-header-right {
    right: 1rem;
    display: -webkit-flex;
    display: flex;
}
.btn_grp {
    padding-top: 10px;
    padding-right: 20px;
    display: -webkit-flex;
    display: flex;
}
.btn_grp .btn_3d {
    /*width: 6em;*/
    padding-left: 1em;
    padding-right: 1em;
    margin-left: .6em;
    font-size: .8rem;
}
.page-header-content {
    text-align: center;
}
.page-header-title {
    height: 2rem;
    line-height: 2rem;
    font-weight: bold;
}
.page-header-subtitle {
    height: 1.4rem;
    line-height: 1.4rem;
    font-size: 1rem;
    font-weight: 700;
    color: #0f0;
}
.page-header-time {
    font-size: 0.9rem;
    height: 2.5rem;
    line-height: 2.5rem;
    color: rgba(255,255,255,.7);
}
.nav>ul {
    font-size: 0.8rem;
}
.nav>ul>li {
    display: inline-block;
    margin-left: 0.4rem;
    width: 6rem;
    text-align: center;
    height: 2rem;
    position: relative;
    line-height: 2rem;
    margin-top: .25rem;
    box-sizing: border-box;
    border-radius: 0.25px;
}
.nav>ul>li>i {
    margin-right: 0.25rem;
}
.nav>ul>li>a {
    color: #FFFFFF;
}
.nav>ul>li:hover {
    box-shadow: -10px 0px 15px #034c6a inset, 
                0px -10px 15px #034c6a inset, 
                10px 0px 15px #034c6a inset, 
                0px 10px 15px #034c6a inset;
}
.nav_active {
    border-bottom: 0.2rem solid #4b8df8;
    box-shadow: -10px 0px 15px #034c6a inset, 
                0px -10px 15px #034c6a inset, 
                10px 0px 15px #034c6a inset, 
                0px 10px 15px #034c6a inset;
}
</style>