doum
7 天以前 e46bfa3ff94a8a1b4daf37c7fcb79c2fab22a72c
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
<template>
  <el-dialog
    :title="'上下线记录 - ' + (gateway.wgMac || '')"
    :visible.sync="visible"
    width="720px"
    append-to-body
    @open="load"
  >
    <el-table v-loading="loading" :data="list" stripe size="small" max-height="400">
      <el-table-column prop="wgMac" label="网关MAC" min-width="140" align="center" show-overflow-tooltip />
      <el-table-column prop="oldStatus" label="原状态" min-width="90" align="center" />
      <el-table-column prop="newStatus" label="新状态" min-width="90" align="center">
        <template slot-scope="{ row }">
          <span :class="row.newStatus === '在线' ? 'green' : 'red'">{{ row.newStatus || '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="logTime" label="记录时间" min-width="160" align="center" />
      <el-table-column prop="source" label="来源" min-width="90" align="center" />
    </el-table>
    <pagination
      class="mt10"
      @size-change="onSizeChange"
      @current-change="onPageChange"
      :pagination="pagination"
    />
  </el-dialog>
</template>
 
<script>
import Pagination from '@/components/common/Pagination'
import { gatewayLogPage } from '@/api/business/ywconditionergateway'
 
export default {
  name: 'YwConditionerGatewayLogWindow',
  components: { Pagination },
  data () {
    return {
      visible: false,
      loading: false,
      gateway: {},
      list: [],
      pagination: {
        pageIndex: 1,
        pageSize: 10,
        total: 0
      }
    }
  },
  methods: {
    open (row) {
      this.gateway = { ...row }
      this.pagination.pageIndex = 1
      this.visible = true
    },
    load () {
      if (!this.gateway.id && !this.gateway.wgMac) return
      this.loading = true
      const model = {}
      if (this.gateway.id) model.gatewayId = this.gateway.id
      if (this.gateway.wgMac) model.wgMac = this.gateway.wgMac
      gatewayLogPage({
        page: this.pagination.pageIndex,
        capacity: this.pagination.pageSize,
        model,
        sorts: []
      })
        .then(data => {
          this.list = data.records || []
          this.pagination.total = data.total || 0
        })
        .catch(() => {})
        .finally(() => { this.loading = false })
    },
    onPageChange (page) {
      this.pagination.pageIndex = page || 1
      this.load()
    },
    onSizeChange (size) {
      this.pagination.pageSize = size
      this.pagination.pageIndex = 1
      this.load()
    }
  }
}
</script>
 
<style scoped>
.mt10 { margin-top: 10px; }
.green { color: #67c23a; }
.red { color: #f56c6c; }
</style>