StoreItem.vue
3.52 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
<template>
<view class="store-list-item">
<view class="store-header" @click="toggleFold(item)">
<view class="header-left-part">
<uv-image src="/static/inspection/store-black-2x.png" width="40rpx" height="40rpx"
style="margin-right: 16rpx;"></uv-image>
<view class="store-name">
<uv-text :lines="1" :text="item[options.label]" color="#202328" :bold="true" size="28rpx">
</uv-text>
</view>
</view>
<view class="header-right-part" style="display: flex;flex-direction: row;align-items: center;">
<view class="store-number">
<text class="store-number-text">
{{getMonitorTotal(item)}}
</text>
</view>
<view class="fold-sign">
<uv-icon :name="item.isFold?'arrow-down':'arrow-up'" size="26rpx" color="#90949D"></uv-icon>
</view>
</view>
</view>
<view class="store-body" :class="item.isFold ? 'store-body-hidden' : 'store-body-show'">
<view v-if="item?.mallOrgs?.length>0">
<view v-for="orgItem in item.mallOrgs" style="border-bottom: 1px dashed rgba(144, 148, 157, 0.3);margin-bottom: 22rpx;">
<view class="s-b-title">
<text class="s-b-title_text">{{orgItem.name}}</text>
</view>
<StoreItemVideo :list="orgItem?.patrolGates||[]"></StoreItemVideo>
</view>
</view>
<!-- 区域列表 -->
<view class="s-b-title" v-if="item?.mallOrgs?.length>0 && item[options.children].length>0">
<text class="s-b-title_text">{{ t('app.title.defaultVideoGroup') }}</text>
</view>
<StoreItemVideo :list="item[options.children]"></StoreItemVideo>
</view>
</view>
</template>
<script setup>
import StoreItemVideo from './StoreItemVideo.vue'
const props = defineProps({
item: {
type: Object,
required: true
},
options: {
type: Object,
default: () => ({
label: 'name',
children: 'patrolGates'
})
}
})
// 折叠
function toggleFold(data) {
data.isFold = !data.isFold
}
const getMallOrgsPatrolGates = (data)=>{
if(data.mallOrgs){
return data.mallOrgs.map(item=>item.patrolGates).flat(1)
}
return []
}
function getMonitorTotal(data) {
if (data.patrolGates) {
const list = [...getMallOrgsPatrolGates(data),...data.patrolGates]
// 1 在线;0 离线
// const onlineNum = list.map(item => item.status === 1).length
const onlineNum = list.filter(item => item.status === 1).length
return `${onlineNum}/${list.length}`
} else {
return ''
}
}
</script>
<style lang="scss" scoped>
.store-list-item {
background-color: #FFF;
border-radius: 16rpx;
}
.store-number {
margin-right: 14rpx;
.store-number-text {
color: #90949D;
font-size: 28rpx;
}
}
.store-header {
display: flex;
flex-direction: row;
justify-content: space-between;
padding: 0px 10px;
height: 46px;
align-items: center;
border-bottom: 1px solid #EEF0F3;
font-size: 14px;
.header-left-part {
display: flex;
flex-direction: row;
flex: 1;
.store-icon {
margin-right: 6px;
}
.store-name {
flex: 1;
}
}
}
.store-body.store-body-hidden {
padding: 0;
height: 0;
overflow: hidden;
}
.store-body {
padding: 24rpx 24rpx 8rpx;
.s-b-title{
&_text{
margin-bottom: 22rpx;
font-weight: bold;
font-size: 26rpx;
color: #202328;
}
}
}
</style>