device-item.vue
2.72 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
<template>
<view class="device-list">
<view @click="$emit('openDeviceDetail',item)"
class="list-item" v-for="item in list" :key="item.id">
<view class="u-flex item">
<view class="item-text text-clip">
<view>
<text class="text-span-bold">{{ item.alias ? item.alias : item.name }}</text>
</view>
</view>
<view class="item-text text-clip">
<view class="text-container">
{{$t('device.deviceNumber')}}:
<text class="text-span">{{ item.sn }}</text>
</view>
</view>
<view class="item-text text-clip">
<view class="text-container">
{{$t('common.belongingOrganization')}}:
<text class="text-span">{{ item.organizationDTO.name }}</text>
</view>
</view>
</view>
<view class="item right-item">
<view class="u-flex" style="margin-top: -6rpx">
<image class="right-image" :src="formatRightImage(item.deviceState)" />
<view>
<text class="right-text" :style="{ color:formatColor(item.deviceState) }">
{{ formatText(item.deviceState) }}
</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
props: {
list: {
type: Array,
default: []
}
},
methods: {
formatRightImage(deviceState) {
return deviceState === 'ONLINE' ?
'/static/online.png' :
deviceState === 'INACTIVE' ?
'/static/unonline.png' :
'/static/baojing.png'
},
formatText(deviceState) {
return deviceState === 'ONLINE' ? this.$t('homePage.deviceLabel.onLine') : deviceState === 'INACTIVE' ? this.$t('homePage.deviceLabel.beActivated') : this.$t('homePage.deviceLabel.offLine')
},
formatColor(deviceState) {
return deviceState === 'ONLINE' ? '#377DFF' : deviceState === 'INACTIVE' ? '#666666' : '#DE4437'
}
}
}
</script>
<style lang="scss" scoped>
.device-list {
display: flex;
flex-direction: column;
padding-left: 20rpx;
.list-item {
width: 713rpx;
height: 200rpx;
background-color: #fff;
margin-top: 24rpx;
display: flex;
border-radius: 10px;
justify-content: space-between;
.item {
margin: 30rpx;
flex-direction: column;
justify-content: space-between;
.item-text {
width: 480rpx;
.text-container {
display: flex;
.text-span {
color: #666;
font-size: 14px;
display: flex;
margin-left: 20rpx;
}
}
.text-span-bold {
color: #333;
font-size: 15px;
font-weight: bold;
}
}
}
.right-item {
.right-image {
width: 30rpx;
height: 30rpx;
margin-top: 5rpx;
margin-right: 5rpx;
}
.right-text {
color: #377dff;
font-size: 13px;
margin-left: 5rpx;
margin-top: 20rpx;
}
}
}
}
</style>