Xxxu
2020-07-03 1ac6ef52a03f25f9def9f6a2594d2a8196aa77f6
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
<template>
  <div>
    <div class="atmo-data-title">
      <div style="margin-left:30px;padding-top:8px">
          <img src="~@/assets/img/home/atmo_data_icon.png" style="margin-top:0px" height="13px" width="15px">
          <span style="color:white">大气数据信息</span>
      </div>
    </div>
    <div id="atmo-data-body" class="atmo-data-body">
      <div style="text-align:center;padding:10px;margin-top:0px;height:30px">
        <span style="color:white;font-size:18px">路灯实时数据收集</span>
      </div>
      <el-carousel
        @change="((pre, next) => {setList(pre, next)})" 
        direction="vertical"
        :height="tableHeight">
        <el-carousel-item v-for="item in pageNum" :key="item">
          <div id="amtoDataTable">
          <table class="amtoDataTable">
            <thead>
              <tr>
                <td>序列号</td>
                <td>温度</td>
                <td>湿度</td>
                <td>pm2.5</td>
                <td>pm10</td>
                <td>甲醛</td>
                <td>CO2</td>
                <td>风速</td>
                <td>光照强度</td>
              </tr>
            </thead>
            <tbody>
            <tr v-for="(item, index) in list" :key="index">
              <td>{{item.streetlightName}}</td>
              <td>{{item.temperature}}C°</td>
              <td>{{item.humidity}}%rh</td>
              <td>{{item.pm25}}ppm</td>
              <td>{{item.pm10}}ppm</td>
              <td>{{item.ech2o}}ug/m3</td>
              <td>{{item.eco2}}ug/m3</td>
              <td>{{item.windSpeed}}m/s</td>
              <td>{{item.brightness}}Lux</td>
            </tr>
            </tbody>
          </table>
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="atmo-data-bottom">
    </div>
  </div>
</template>
 
<script>
export default {
  data () {
    return {
      test: false,
      tableItemNum: 3,
      pageNum: 0,
      tableHeight: '150px',
      list: [],
      allList: []
    }
  },
  components: {
 
  },
  activated () {
    this.getNewList()
  },
  methods: {
    init () {
      var h = window.innerHeight || document.body.clientHeight
      var atmoBodyH = document.getElementById('atmo-data-body')
      var num = h - 700 - 2
      atmoBodyH.style.height = num + 'px'
      this.tableHeight = (h - 626 - 45) + 'px'
      this.tableItemNum = parseInt((h - 626 - 45) / 45)
      this.list = this.getPartOfList(this.allList, 0, this.tableItemNum)
      this.pageNum = Math.ceil(this.allList.length / this.tableItemNum)
    },
    getdomheight (dom) {
      return dom.offsetHeight
    },
    getPartOfList (list, start, end) {
      var slist = []
      for (var i = 0; i < list.length; i++) {
        if (i >= start) {
          if (i < end) {
            slist.push(list[i])
          }
        }
      }
      return slist
    },
    setList (cur, pre) {
      this.list = this.getPartOfList(this.allList, cur * this.tableItemNum, (cur + 1) * this.tableItemNum)
    },
    openAtmo () {
      alert(1)
    },
    getNewList () {
      this.$http({
        url: this.$http.adornUrl('/pole/polesensor/newList'),
        method: 'get'
      }).then(({ data }) => {
        this.allList = data.list
        this.init()
      })
    }
  }
}
</script>
<style>
.atmo-data-title {
    height: 30px;
    width: 100%;
    background-image: url(~@/assets/img/content_charts_title.png);
    background-size: 100% 30px;
}
.atmo-data-body {
    margin-top: 0px;
    height: 100px;
    width: 100%;
    background-image: url(~@/assets/img/content_charts_body.png);
    background-size: 100% 100%;
}
.atmo-data-bottom {
    height: 30px;
    width: 100%;
    background-image: url(~@/assets/img/content_charts_bottom.png);
    background-size: 100% 30px;
}
.amtoDataTable {
    margin: 0px;
    padding: 10px;
    margin-top: 0px;
    padding-top:0px;
    width: 100%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0);
    border-collapse: separate; 
    border-spacing: 0px 10px;
}
.amtoDataTable tr {
    background-color: #022440;
    color:white;
    text-align: center;
}
</style>