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
<template>
  <div class="table_alarmLogist">
    <a-table ref="table" bordered size="middle" :rowKey="(record,index)=>{return index}" :columns="columns"
             :dataSource="dataList" :pagination="false" :loading="loading">
      <template slot="status" slot-scope="status">
        <div v-if="status == '25'" style="color: #C11900;width: 100%; height: 100%;">故障</div>
      </template>
    </a-table>
  </div>
</template>
 
<script>
  export default {
    name: 'FaultLogList',
    props: {
      dataList: {
        type: Array,
        required: true,
        default: []
      },
      loading: {
        type: Boolean,
        default: false
      }
    },
    data() {
      return {
        disabled: true,
        columns: [
          {
            title: '状态',
            align: 'center',
            dataIndex: 'status',
            scopedSlots: { customRender: 'status' }
          },
          {
            title: '故障时间',
            align: 'center',
            dataIndex: 'startTime'
          },
          {
            title: '结束时间',
            align: 'center',
            dataIndex: 'endTime'
          },
          {
            title: '持续时间',
            align: 'center',
            dataIndex: 'duration',
            customRender: (t, r, index) => {
              var ss = parseInt(t)
              if (ss >= 3600) {
                // 根据秒数转换成对应的时分秒
                const hour = parseInt(ss / 3600) < 10 ? '0' + parseInt(ss / 3600) : parseInt(ss / 3600)
                const min = parseInt(ss % 3600 / 60) < 10 ? '0' + parseInt(ss % 3600 / 60) : parseInt(ss % 3600 / 60)
                const sec = parseInt(ss % 3600 % 60) < 10 ? '0' + parseInt(ss % 3600 % 60) : parseInt(ss % 3600 % 60)
                if (min == '00') {
                  if (sec == '00') {
                    return hour + '小时'
                  } else {
                    return hour + '小时' + sec + '秒'
                  }
 
                } else {
                  if (sec == '00') {
                    return hour + '小时' + min + '分'
                  } else {
                    return hour + '小时' + min + '分' + sec + '秒'
                  }
                }
 
              } else if (60 < ss && ss < 3600) {
                const min1 = parseInt(ss % 3600 / 60) < 10 ? '0' + parseInt(ss % 3600 / 60) : parseInt(ss % 3600 / 60)
                const sec1 = parseInt(ss % 3600 % 60) < 10 ? '0' + parseInt(ss % 3600 % 60) : parseInt(ss % 3600 % 60)
                return min1 + '分' + sec1 + '秒'
              } else {
                const sec2 = parseInt(ss % 3600 % 60) < 10 ? '0' + parseInt(ss % 3600 % 60) : parseInt(ss % 3600 % 60)
                return sec2 + '秒'
              }
            }
          },
        ]
      }
    }
  }
</script>
 
<style lang="less" scoped>
  @import '~@assets/less/common.less';
 
  @media screen and (min-width: 1920px) {
    .table_alarmLogist {
      height: 417px !important;
      overflow: auto;
    }
  }
 
  @media screen and (min-width: 1680px) and (max-width: 1920px) {
    .table_alarmLogist {
      height: 417px !important;
      overflow: auto;
    }
  }
 
  @media screen and (min-width: 1400px) and (max-width: 1680px) {
    .table_alarmLogist {
      height: 266px !important;
      overflow: auto;
    }
  }
 
  @media screen and (min-width: 1280px) and (max-width: 1400px) {
    .table_alarmLogist {
      height: 360px !important;
      overflow: auto;
    }
  }
 
  @media screen and (max-width: 1280px) {
    .table_alarmLogist {
      height: 170px !important;
      overflow: auto;
    }
  }
</style>