liuxiaolong
2019-05-06 8700cf1dc46c350371d865532c2914595187788e
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
<template>
 
      <!-- <b-card no-body >
          <b-card-header header-tag="h5">
            预警信息
          </b-card-header>
          <div class="pl20 pr20 pt10 pb30">
            <Table
              :data="tableList"
              highlight-current-row
              ref="leftTable"
            >
              <TableColumn
                type="index"
                prop="index"
                label="序号"
                :index="snMethod"
                width="50"
              />
              <TableColumn
                label="地图名称"
                prop="name"
              />
              <TableColumn
                label="更新时间"
                prop="updateTime"
                width="200"
              />
            </Table>
            <div class="pt20 pb20">
              <b-pagination class="justify-content-center justify-content-sm-end m-0"
                v-if="total"
                v-model="activePage"
                :total-rows="total"
                :per-page="pageSize"
              />
            </div>
          </div>
        </b-card> -->
  <b-card no-body>
    <b-card-header header-tag="h5" class="with-elements pr-0 pb-0">
      <div class="card-header-title">预警信息</div>
    </b-card-header>
    <div class="pl10 pr10 pt10 overflow-y" style="height:80vh">
      <b-list-group :flush="true" v-if="tableList.length !== 0">
        <b-list-group-item class="py-3" v-for="(iteam,index) in tableList" :key="index">
          <div class="badge badge-danger float-right">预警</div>
          <div class="font-weight-semibold f18">{{index+1}}、【{{iteam.alarmType}}】</div>
          <p class="text-truncate my-1"><span class="text-muted">报警时间:</span>{{iteam.alarmTime}}</p>
          <p class="text-truncate"><span class="text-muted">报警地点:</span>{{iteam.deviceName}}</p>
        </b-list-group-item>
      </b-list-group>
      <div class="py-5 text-center" v-else>
        <small class="text-muted">暂无数据</small>
      </div>
    </div>
    <div class="pb20 pl10 pr10" v-if="total">
      <hr class="border-light mt-0">
      <b-pagination class="justify-content-center justify-content-sm-end m-0" v-model="activePage" :total-rows="total" :per-page="pageSize" />
    </div>
  </b-card>
</template>
<!-- Page -->
<script>
import { Table, TableColumn } from 'element-ui'
import { getActiveAlarmList } from '@/server/home.js'
export default {
  name: 'HomeAlarmInfoList',
  data() {
    return {
      userInfo: this.$store.getters.basicUserInfo,
      name: '',
      tableList: [],
      total: 0,
      pageSize: 10,
      activePage: 1
    }
  },
  computed: {},
  methods: {
    snMethod(index) {
      return this.activePage > 1
        ? this.pageSize * (this.activePage - 1) + index + 1
        : index + 1
    },
    /* 设备列表初始化 */
    async _initData() {
      let res = await getActiveAlarmList({
        orgId: this.userInfo.orgId,
        startTime: this.$moment().format('YYYY-MM-DD 00:00:00'),
        endTime: this.$moment().format('YYYY-MM-DD 23:59:59')
      })
      if (res) {
        this.tableList = res
      }
    }
  },
  watch: {
    activePage(val, oldVal) {
      if (val !== oldVal) {
        this.activePage = val
        this._initData()
      }
    }
  },
  created() {
    /* 查询列表 */
    this._initData()
  },
  components: {
    Table,
    TableColumn
  }
}
</script>