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
92
93
94
95
96
97
98
99
100
101
102
<template>
  <GlobalWindow title="控制历史" :visible.sync="visible" width="900px" :show-confirm="false">
    <p class="device-info" v-if="device.id">{{ device.name || device.code }} · {{ device.wgMac }}</p>
    <el-table v-loading="loading" :data="list" stripe size="small" max-height="420">
      <el-table-column prop="id" label="ID" width="70" align="center" />
      <el-table-column label="操作类型" min-width="100" align="center">
        <template slot-scope="{ row }">{{ formatActionType(row.actionType) }}</template>
      </el-table-column>
      <el-table-column prop="actionContent" label="操作描述" min-width="180" show-overflow-tooltip align="center" />
      <el-table-column label="结果" width="80" align="center">
        <template slot-scope="{ row }">
          <span :class="row.resultStatus === 1 ? 'green' : 'red'">{{ row.resultStatus === 1 ? '成功' : '失败' }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="resultMsg" label="说明" min-width="120" show-overflow-tooltip align="center" />
      <el-table-column prop="createDate" label="时间" min-width="150" align="center" />
    </el-table>
    <pagination
      class="mt10"
      @size-change="onSizeChange"
      @current-change="onPageChange"
      :pagination="pagination"
    />
  </GlobalWindow>
</template>
 
<script>
import GlobalWindow from '@/components/common/GlobalWindow'
import Pagination from '@/components/common/Pagination'
import { historyPage } from '@/api/business/ywconditioner'
 
const ACTION_TYPE_MAP = {
  1: '开关',
  2: '模式',
  3: '风速',
  4: '温度',
  5: '锁定',
  6: '查电量',
  7: '查功率'
}
 
export default {
  name: 'YwConditionerHistoryWindow',
  components: { GlobalWindow, Pagination },
  data () {
    return {
      visible: false,
      loading: false,
      device: {},
      list: [],
      pagination: {
        pageIndex: 1,
        pageSize: 10,
        total: 0
      }
    }
  },
  methods: {
    open (row) {
      this.device = { ...row }
      this.pagination.pageIndex = 1
      this.visible = true
      this.load()
    },
    load () {
      if (!this.device.id) return
      this.loading = true
      historyPage({
        page: this.pagination.pageIndex,
        capacity: this.pagination.pageSize,
        model: { conditionerId: this.device.id },
        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()
    },
    formatActionType (val) {
      return ACTION_TYPE_MAP[val] || val || '-'
    }
  }
}
</script>
 
<style scoped>
.device-info { margin-bottom: 12px; color: #606266; }
.mt10 { margin-top: 10px; }
.green { color: #67c23a; }
.red { color: #f56c6c; }
</style>