whychdw
2019-07-05 7ab97c4ada45550abc7f440d60549b249726a9ff
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
<template>
    <div class="layout">
        <Layout>
            <Header>
                <Menu mode="horizontal" theme="dark" :active-name="getActiveName" @on-select="changeDataPage">
                    <div class="layout-logo">
                        新能源充电桩在线巡检系统
                    </div>
                    <div class="layout-nav">
                        <MenuItem name="home" to="/index">
                            <Icon type="ios-home" />
                            <span>首页</span>
                        </MenuItem>
                        <MenuItem name="control" @click="toDataControl()">
                            <Icon type="ios-stats" />
                            <span>实时监控</span>
                        </MenuItem>
                        <MenuItem name="history" @click="toDataHistory()">
                            <Icon type="ios-paper"/>
                            <span>历史数据</span>
                        </MenuItem>
                        <!-- <MenuItem name="4">
                            <Icon type="ios-notifications" />
                            <span>告警管理</span>
                        </MenuItem>
                        <MenuItem name="5">
                            <Icon type="ios-settings" />
                            <span>系统管理</span>
                        </MenuItem> -->
                    </div>
                    <div class="user-info-menu">
                        <Avatar style="background-color: #87d068" icon="ios-person" />
                        <Dropdown trigger="hover" style="margin-left: 8px; color: #FFFFFF" @on-click="userDropDown">
                            <a href="javascript:void(0)" style="color: #FFFFFF">
                                {{getUserName}}
                                <Icon type="ios-arrow-down"></Icon>
                            </a>
                            <DropdownMenu slot="list">
                                <DropdownItem>密码修改</DropdownItem>
                                <DropdownItem name="exitSystem">退出系统</DropdownItem>
                            </DropdownMenu>
                        </Dropdown>
                        <!-- <Tooltip :content="warnStatus.tooltip" placement="bottom">
                            <span style="font-size: 22px; margin-left:8px"><Icon :type="warnStatus.type" @click="toggleWarnStatus"/></span>
                        </Tooltip> -->
                        <!-- <audio src="./music/smoke_alarm.mp3" controls="controls" autoplay="autoplay"></audio> -->
                    </div>
                </Menu>
            </Header>
            <Content class="main-page-content" :style="{padding: '1px', minHeight: '280px', background: '#fff', overflowY: 'auto' }">
                <router-view></router-view>
            </Content>
        </Layout>
    </div>
</template>
<script>
export default {
    data: function() {
    return {
        activeName: '',        // 当前页面所在的路由
        warnStatus: {
            type: 'ios-notifications',
            tooltip: '点击关闭告警音'
        }
    }
  },
  methods:{
    changeDataPage: function(name) {
        // 设置主导航
        this.$store.commit('setActiveName', name);
        switch(name) {
            case 'control':
            case 'history':
                this.$router.push('/index/data/');
                this.$bus.$emit('changePageState', name);
            break;
        }
    },
    openWarnStatus: function() {
        this.warnStatus = {
            type: 'ios-notifications',
            tooltip: '点击关闭告警音'
        };
    },
    offWarnStatus: function() {
        this.warnStatus = {
            type: 'ios-notifications-off',
            tooltip: '点击开启告警音'
        };
    },
    toggleWarnStatus: function() {
        if(this.warnStatus.type == 'ios-notifications') {
            this.offWarnStatus();
        }else {
            this.openWarnStatus();
        }
    },
    userDropDown: function(name) {
        // 根据点击的内容触发事件
        switch(name) {
            case 'exitSystem':
                this.exitSystem();
            break;
        }
    },
    exitSystem: function() {
        var _self = this;
        //console.log(this.$router);
        this.$Modal.warning({
            title: '系统提示',
            content: '按ESC关闭面板,点击确定退出系统',
            closable: true,
            onOk: function() {
                _self.$store.commit('setLogin', false);
                _self.$router.push('/');
            }
        });
    }
  },
  computed: {
    getActiveName: function() {
        // console.log(this.$store.getters.getActiveName);
        return this.$store.getters.getActiveName;
    },
    getUserName: function() {
        return this.$store.state.userName;
    }
  },
  mounted: function() {
      var _self = this;
  }
}
</script>
<style scoped>
.layout-logo{
    padding: 0 16px;
    height: 36px;
    line-height: 36px;
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 4px;
    color: #FFFFFF;
    border-radius: 3px;
    float: left;
    position: relative;
    top: 15px;
    left: 20px;
}
.layout-nav{
    width: 400px;
    margin: 0 auto;
    margin-right: 60px;
}
.user-info-menu {
    color: #FFFFFF;
}
.user-info-menu-icon {
    display: inline-block;
    text-align: center;
    font-size: 18px;
    color: #fff;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    vertical-align: middle;
    width: 32px;
    height: 32px;
    line-height: 32px;
    border-radius: 16px;
    background-color: #87d068;
}
.main-page-content {
    height: calc(100vh - 64px);
}
</style>