alarm-item.vue
3.51 KB
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
154
155
156
<template>
<view class="alarm-list">
<view @click="$emit('openAlertDetail',item)" class="list-item" v-for="(item, index) in list" :key="index">
<view class="u-flex item">
<view class="item-text text-clip">
<text class="text-bold">{{ item.deviceAlias || item.deviceName || '暂无数据' }}</text>
</view>
<view class="item-text text-clip">
<text class="text-muted">{{ item.details == null ? '暂无数据' : formatDetailText(item.details) }}</text>
</view>
<view class="item-text">
<text class="text-muted">
告警状态:{{item.status | setAlarmStatus(alarmStatus)}}
</text>
</view>
<view class="item-text">
<text class="text-secondary">{{ item.createdTime }}</text>
</view>
</view>
<view class="item">
<view class="u-flex item-right">
<image class="right-image" :src="bindImageUrl(item.severity)"></image>
<view class="right-text">
<text class="text-no-color" :style="[setAlarmSeverityColor(item.severity,alarmSeverity)]">
{{item.severity | setAlarmSeverity(alarmSeverity)}}
</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import {
alarmSeverity,
alarmStatus
} from '../config/data.js';
import {findLogin} from './config'
export default {
props: {
list: {
type: Array,
default: []
}
},
data() {
return {
alarmSeverity,
alarmStatus
}
},
filters: {
setAlarmStatus(value, list) {
return list.find(item => item.value === value).label
},
setAlarmSeverity(value, list) {
return list.find(item => item.value === value).label
}
},
methods: {
setAlarmSeverityColor(value, list) {
return {
color: list.find(item => item.value === value).color
}
},
bindImageUrl(e) {
return this.alarmSeverity.find(item => item.value === e).icon
},
formatDetailText(details) {
const deviceIdKeys = Object.keys(details)
if(!deviceIdKeys) return
const values = deviceIdKeys.reduce((acc, curr) => {
const items = details[curr]?.triggerData
if(items?.key && items?.logicValue && items.realValue){
acc.push(`触发属性:${items.key ||'暂无数据'} 触发条件:${findLogin(items)+items.logicValue || '暂无数据'} 触发值:${items?.realValue || '暂无数据'} `)
}
return acc
}, [])
return values.join(',')
}
}
}
</script>
<style lang="scss" scoped>
.alarm-list {
display: flex;
flex-direction: column;
padding-left: 18rpx;
justify-content: flex-start;
.list-item {
width: 713rpx;
height: 233rpx;
background-color: #fff;
margin-top: 24rpx;
display: flex;
flex-direction: row;
border-radius: 10px;
justify-content: space-between;
.item {
justify-content: flex-start;
flex-direction: column;
align-items: center;
height: 211rpx;
margin-top: 8rpx;
margin-left: 20rpx;
.item-text {
width: 500rpx;
text-align: left;
margin-top: 13rpx;
line-height: 40rpx;
.text {
color: #666666;
font-size: 15px;
}
.text-three {
color: #333333;
font-size: 15px;
}
.text-nine {
color: #999999;
font-size: 15px;
}
}
.item-right {
flex-direction: row;
margin-top: -3rpx;
margin-right: 25rpx;
.right-image {
width: 30rpx;
height: 30rpx;
margin-top: 20rpx;
margin-right: 5rpx;
}
.right-text {
color: #333333;
font-size: 13px;
margin-left: 5rpx;
margin-top: 20rpx;
}
}
}
}
}
</style>