张卓
2022-09-29 4ef1c909df36c48f7f040e9ec408fc15e6745e71
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
<template>
  <div class="navbar">
    <hamburger
      :is-active="sidebar.opened"
      class="hamburger-container"
      @toggleClick="toggleSideBar"
    />
 
    <breadcrumb class="breadcrumb-container" />
    <!-- 切换城市移到这边 -->
 
    <div class="right-menu">
      <ul>
        <li>
          <!-- <el-cascader
            v-model="newRegion"
            :options="options"
            :props="{ checkStrictly: true }"
            clearable
            change-on-select
            placeholder="切换城市"
          /> -->
          <!-- <el-cascader
            v-model="newRegion"
            placeholder="选择省/市/区"
            :options="options"
            :props="{ checkStrictly: true }"
            clearable
            change-on-select
            style="flex:1"
          /> -->
        </li>
        <!-- <li>
            <div style="background: #409eff;color: #fff;margin: 5px;border-radius: 5px;cursor: pointer;font-size: 14px;" @click="getRegionApi">查询</div>
        </li>-->
        <!-- <li style="color:#eee" class="clickHover" @click="logout">
          <i class="iconfont icontuichu" /> 退出系统
        </li> -->
        <!-- <li style="color:#eee">欢迎 {{ monitorPointName }}!</li> -->
      </ul>
      <div style="position: relative">
<!--        <el-badge :value="'99+'" class="item">-->
<!--          <img-->
<!--            src="../../assets/images/news.png"-->
<!--            alt=""-->
<!--            @click="showNews"-->
<!--          >-->
<!--        </el-badge>-->
<!--        <div v-if="showNewsFlag" style="position: absolute;right: -70px;top: 30px;z-index: 2">-->
<!--          <span class="sanjiao" />-->
<!--          <ul class="newsText">-->
<!--            <li class="paging">-->
<!--              <el-pagination-->
<!--                  background-->
<!--                  @current-change="handleCurrentChange"-->
<!--                  :current-page="currentPage"-->
<!--                  :page-sizes="[100, 200, 300, 400]"-->
<!--                  :page-size="100"-->
<!--                  layout="prev, pager, next"-->
<!--                  :total="1000">-->
<!--              </el-pagination>-->
<!--            </li>-->
<!--            <li class="text_item ">-->
<!--              <span class="date">-->
<!--                <b style="position:relative;top:-10px;font-size: 14px;top: -6px; left: 4px;">10/11</b>-->
<!--                <b style="font-size: 10px;position: relative;top: -44px;left: 10px;">2021</b>-->
<!--              </span>-->
<!--              <span style="display: inline-block;float:right;width: 330px;height: 48px;">-->
<!--                <span style="position: relative;top: -10px;font-size: 14px;font-weight: 700;padding: 0">-->
<!--                  &lt;!&ndash;                  <el-badge is-dot>【{{item}}时数据提醒】</el-badge>&ndash;&gt;-->
<!--                  <span>【1时数据提醒】</span>-->
<!--                  <span style="display: inline-block ; float: right; font-size: 12px;color: #66b1ff; line-height: 16px;padding-top: 8px;">-->
<!--                    <img src="../../assets/images/copy.png" alt="" style="vertical-align: middle">-->
<!--                    <span style="display: inline-block; vertical-align: middle;margin-top: 1px;font-weight: 300">复制</span>-->
<!--                  </span>-->
<!--                </span>-->
<!--                <span-->
<!--                  style="display:inline-block;-->
<!--                  height: 24px;-->
<!--                  width:100%;-->
<!--                  line-height:16px;-->
<!--                  font-size: 10px;-->
<!--                  color: grey;-->
<!--                  vertical-align: top ;-->
<!--                  position: relative;-->
<!--                  top:-28px;padding: 0 6px;-->
<!--                  margin-top: 2px;"-->
<!--                >-->
<!--                  <span style="display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">-->
<!--                    11时,我市AQI:28,等级:优。与10时相比,PM10:21微克/立方米,下降11;PM2.5:11微克/立方米,下降2;O3:88微克/立方米,上升16;TVOC总量:0.404毫克/立方米。-->
<!--                  </span>-->
<!--                  <span style="display: block">当前天气状况:温度27℃,湿度42%,东北风1~2级。</span>-->
<!--                  <span style="display: block;float: right">(七星瓢虫专家组)</span>-->
<!--                </span>-->
<!--              </span>-->
<!--            </li>-->
<!--            <li v-for="item in 5" class="text_item">-->
<!--              <span class="date">-->
<!--                <b style="position:relative;top:-10px;font-size: 14px;top: -6px; left: 4px;">10/11</b>-->
<!--                <b style="font-size: 10px;position: relative;top: -44px;left: 10px;">2021</b>-->
<!--              </span>-->
<!--              <span style="display: inline-block;float:right;width: 330px;height: 48px;">-->
<!--                <span style="position: relative;top: -10px;font-size: 14px;font-weight: 700;padding: 0">-->
<!--                  <el-badge is-dot>【{{ item }}时数据提醒】</el-badge>-->
<!--                  &lt;!&ndash;                  <span>【{{item}}时数据提醒】</span>&ndash;&gt;-->
<!--                </span>-->
<!--                <span-->
<!--                  style="display:inline-block;-->
<!--                  height: 24px;-->
<!--                  width:100%;-->
<!--                  line-height:24px;-->
<!--                  font-size: 12px;-->
<!--                  color: grey;-->
<!--                  vertical-align: top ;-->
<!--                  position: relative;-->
<!--                  top:-28px;padding: 0 6px;overflow: hidden;text-overflow: ellipsis;-->
<!--                  white-space: nowrap;"-->
<!--                >-->
<!--                  <span style="display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">-->
<!--                    11时,我市AQI:28,等级:优。与10时相比,PM10:21微克/立方米,下降11;PM2.5:11微克/立方米,下降2;O3:88微克/立方米,上升16;TVOC总量:0.404毫克/立方米。-->
<!--                  </span>-->
<!--                  <span style="display: block">当前天气状况:温度27℃,湿度42%,东北风1~2级。</span>-->
<!--                  <span style="display: block;float: right">(七星瓢虫专家组)</span>-->
<!--                </span>-->
<!--              </span>-->
<!--            </li>-->
<!--          </ul>-->
<!--        </div>-->
      </div>
      <el-dropdown style="color:#eee" class="avatar-container clickHover" trigger="click">
        <div class="avatar-wrapper" style="margin-top:0">
          <div style="color:#eee;padding: 0 0 0 10px;">欢迎 {{ monitorPointName }}!</div>
          <i style="top:20px" class="el-icon-caret-bottom" />
        </div>
        <el-dropdown-menu slot="dropdown" class="user-dropdown" style="margin-top: 0;padding-top: 0;">
          <router-link to="/">
            <el-dropdown-item v-for="(item, key) in dropMenus" :key="key">
              <router-link :to="'/dropDown/'+item.path">
                {{ item.meta.title }}
              </router-link>
            </el-dropdown-item>
          </router-link>
          <!-- <a target="_blank" href="https://github.com/PanJiaChen/vue-admin-template/">
            <el-dropdown-item>Github</el-dropdown-item>
          </a> -->
          <el-dropdown-item divided style="margin: 0">
            <span style="display:block;" @click="logout">退出系统</span>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>
 
<script>
import Cookies from 'js-cookie'
import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'
 
export default {
  components: {
    Breadcrumb,
    Hamburger
  },
  data() {
    return {
      currentPage: 1, // 当前页
      showNewsFlag: false, // 用于判断是否显示消息气泡
      options: [],
      newRegion: [],
      logo: require('@/assets/images/LOGO.png'),
      monitorPointName: Cookies.get('monitorPointName'),
      dropMenus: []
    }
  },
  computed: {
    ...mapGetters(['sidebar', 'avatar'])
  },
  watch: {
    newRegion(newVal, oldVal) {
 
      if (newVal.length === 3) {
        this.$store.state.regionCode = this.newRegion[this.newRegion.length - 1]
        console.log(this.$store.state.regionCode)
      }
    }
  },
  beforeCreate() {
    this.$store.state.type = 'Map'
    this.$store.state.aside = true
  },
  created() {
    const menus = this.$router.options.routes
    for (let i = 0; i < menus.length; i++) {
 
      if (menus[i].path === '/dropDown') {
        this.dropMenus = menus[i].children
      }
    }
    this.getRegion()
  },
  methods: {
    // 分页
    // handleSizeChange(val) {
    //   console.log(val)
    // },
 
    handleCurrentChange(val) {
      console.log('---------------------------++++-------------------------------------')
      console.log(val)
      this.currentPage = val
    },
    // 点击消息铃铛显示气泡
    // showNews() {
    //   this.showNewsFlag = !this.showNewsFlag
    //   console.log(this.showNewsFlag)
    // },
    getRegion() {
      this.$request({
        url: '/organization/getMapPath',
        method: 'get',
        params: {
          organizationId: this.$store.state.orgId
        }
      }).then(res => {
        const data = res.data
        for (let i = 0; i < data.length; i++) {
          this.options.push({
            value: data[i].provinceCode,
            label: data[i].provinceName
          })
          this.options[i].children = []
          for (let j = 0; j < data[i].cities.length; j++) {
            this.options[i].children.push({
              value: data[i].cities[j].cityCode,
              label: data[i].cities[j].cityName
            })
            this.options[i].children[j].children = []
            for (let k = 0; k < data[i].cities[j].areas.length; k++) {
              this.options[i].children[j].children.push({
                value: data[i].cities[j].areas[k].areaCode,
                label: data[i].cities[j].areas[k].areaName
              })
            }
          }
        }
      })
        .catch(err => {
          console.log('请求Region失败')
          console.log(err)
        })
      // console.log('请求Region结束')
    },
 
    handleCommand(command) {
      // this.type = command
 
      this.$store.state.type = command
      if (this.$store.state.type === 'Map') {
        console.log('是Map')
        this.$store.state.aside = true
      } else {
        console.log('是LineChart')
        this.$store.state.aside = false
      }
 
      // console.log(this.type)
      // this.$message('click on item ' + command);
    },
    toggleSideBar() {
      this.$store.dispatch('app/toggleSideBar')
      this.$store.state.leftaSide = !this.$store.state.leftaSide
    },
    async logout() {
      await this.$store.dispatch('user/logout')
      this.$router.push(`/login`)
      location.reload()
    }
  }
}
</script>
 
<style lang="scss" scoped>
.navbar {
  height: 50px;
  //overflow: hidden;
  position: relative;
  background: #0f4567;
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
 
  .hamburger-container {
    line-height: 46px;
    height: 100%;
    float: left;
    cursor: pointer;
    transition: background 0.3s;
    -webkit-tap-highlight-color: transparent;
 
    &:hover {
      background: rgba(0, 0, 0, 0.025);
    }
  }
 
  .breadcrumb-container {
    float: left;
  }
 
  .right-menu {
    float: right;
    height: 100%;
    line-height: 50px;
    display: flex;
 
    &:focus {
      outline: none;
    }
 
    .right-menu-item {
      display: inline-block;
      padding: 0 8px;
      height: 100%;
      font-size: 18px;
      color: #5a5e66;
      vertical-align: text-bottom;
 
      &.hover-effect {
        cursor: pointer;
        transition: background 0.3s;
 
        &:hover {
          background: rgba(0, 0, 0, 0.025);
        }
      }
    }
 
    .avatar-container {
      margin-right: 30px;
 
      .avatar-wrapper {
        margin-top: 5px;
        position: relative;
 
        .user-avatar {
          cursor: pointer;
          width: 40px;
          height: 40px;
          border-radius: 10px;
          object-fit: contain;
        }
 
        .el-icon-caret-bottom {
          cursor: pointer;
          position: absolute;
          right: -20px;
          top: 25px;
          font-size: 12px;
        }
      }
    }
  }
  li {
    list-style-type: none;
  }
  .right-menu > ul {
    margin: 0;
    line-height: 50px;
  }
  .right-menu > ul > li {
    float: left;
    // line-height: 18px;
    padding: 0 15px;
    cursor: pointer;
    font-size: 14px;
  }
  .clickHover{
    cursor: pointer;
    &:hover{
      background: #112f55;
    }
  }
  .item {
    margin-right: 30px;
    padding-top: 4px;
  }
  .sanjiao {
    display: block;
    width: 0px;
    height: 0px;
    border-width: 10px 8px;
    border-style: solid;
    border-color: transparent transparent white;
    position: relative;
    left: 309.5px;
  }
  .newsText {
    width: 425px;
    background-color: #E7E7E7;
    border: 0.5px solid rgba(231,231,231,0.8);
    border-top: none;
    box-shadow: -2px 0 3px -1px #E7E7E7, //左边阴影
                0 2px 3px -1px #E7E7E7, //底部阴影
                2px 0 3px -1px #E7E7E7; //右边阴影;
    padding: 0;
    margin: 0;
    //box-shadow: 1px 0 4px 1px #E7E7E7;
  }
  .text_item {
    width: 100%;
    height: 62px;
    background-color: white;
    margin: 1px;
    padding: 7px 15px;
  }
  .newsText > li:nth-child(2){
    margin: 0px;
  }
  .activeItem {
    width: 100%;
    height: 130px;
    background-color: white;
  }
  .text_item > .date {
    display: inline-block;
    width: 48px;
    height: 48px;
    background-color: #409EFD;
    border-radius: 6px;
    color: white;
  }
  .paging {
    background-color: white;
    width: 100%;
    height: 40px;
    padding: 5px 7px;
    margin: 0px;
    border-top: none;
  }
  /deep/.el-badge__content.is-fixed {
    top: 14px
  }
  // .clickHover:hover {
  //   background: #112f55;
  // }
}
</style>