GrowCard.vue
7.02 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<template>
<div class="md:flex">
<Card size="small" class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:mr-4" style="color: #666">
<div class="flex" style="height: 100px">
<div class="mr-4"
><img src="/src/assets/images/device-count.png" style="width: 5.625rem; height: 5.625rem"
/></div>
<div class="flex-auto">
<div class="flex justify-between" style="align-items: center">
<div style="font-size: 1.625rem; color: #333; font-weight: bold">
<CountTo
v-if="growCardList?.deviceInfo?.sumCount"
:endVal="growCardList.deviceInfo.sumCount"
/>
<CountTo v-else :endVal="0" />
</div>
<img src="/src/assets/images/tip.png" style="width: 1.125rem; height: 1.125rem" />
</div>
<div> 设备数(个) </div>
</div>
</div>
<div class="ml-2 pt-4" style="border-top: 2px solid #f0f2f5">
<div class="flex" style="align-items: center"
><img
src="/src/assets/images/online.png"
class="mr-1"
style="width: 0.625rem; height: 0.625rem"
/>
<span>在线 {{ growCardList?.deviceInfo?.onLine }}</span>
<img
src="/src/assets/images/offline.png"
class="mr-1 ml-1"
style="width: 0.625rem; height: 0.625rem"
/>
<span> 离线 {{ growCardList?.deviceInfo?.offLine }} </span>
<img
src="/src/assets/images/inactive.png"
class="mr-1 ml-1"
style="width: 0.625rem; height: 0.625rem"
/>
<span> 未激活 {{ growCardList?.deviceInfo?.inActive }} </span>
</div></div
>
</Card>
<Card size="small" class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:mr-4" style="color: #666">
<div class="flex" style="height: 100px">
<div class="mr-4">
<img
v-if="!isAdmin(role)"
src="/src/assets/images/alarm-count.png"
style="width: 5.625rem; height: 5.625rem"
/>
<img v-else src="/src/assets/images/zh.png" style="width: 5.625rem; height: 5.625rem" />
</div>
<div class="flex-auto">
<div class="flex justify-between" style="align-items: center">
<div v-if="!isAdmin(role)" style="font-size: 1.625rem; color: #333; font-weight: bold">
<CountTo
v-if="growCardList?.alarmInfo?.sumCount"
:end-val="growCardList.alarmInfo.sumCount"
/>
<CountTo v-else :end-val="0" />
</div>
<div style="font-size: 1.625rem; color: #333; font-weight: bold" v-else>
<CountTo
v-if="growCardList?.tenantInfo?.sumCount"
:end-val="growCardList.tenantInfo.sumCount"
/>
<CountTo v-else :end-val="0" />
</div>
<img src="/src/assets/images/tip.png" style="width: 1.125rem; height: 1.125rem" />
</div>
<div> {{ !isAdmin(role) ? `告警数(条)` : '租户总量(个)' }}</div>
</div>
</div>
<div v-if="!isAdmin(role)" class="ml-2 pt-4" style="border-top: 2px solid #f0f2f5">
今日新增 {{ toThousands(growCardList?.alarmInfo?.todayAdd) }}</div
>
<div v-else class="ml-2 pt-4" style="border-top: 2px solid #f0f2f5">
今日新增 {{ toThousands(growCardList?.tenantInfo?.todayAdd) }}</div
>
</Card>
<Card size="small" class="md:w-1/3 w-full !md:mt-0 !mt-4" style="color: #666">
<div class="flex" style="height: 100px">
<div class="mr-4"
><img
v-if="!isAdmin(role)"
src="/src/assets/images/msg-count.png"
style="width: 5.625rem; height: 5.625rem"
/><img v-else src="/src/assets/images/kf.png" style="width: 5.625rem; height: 5.625rem" />
</div>
<div v-if="!isAdmin(role)" style="display: flex; align-items: center">
<div>
<div style="align-items: center">
<div style="font-size: 1.625rem; color: #333; font-weight: bold">
<CountTo
v-if="growCardList?.messageInfo?.messageCount"
:end-val="growCardList.messageInfo.messageCount"
/>
<CountTo v-else :end-val="0" />
</div>
消息量(条)
</div>
<div>
<span class="mr-2">数据点</span>
<CountTo
style="color: #333; font-weight: bold"
v-if="growCardList?.messageInfo?.dataPointsCount"
:end-val="growCardList.messageInfo.dataPointsCount"
/>
<CountTo style="color: #333; font-weight: bold" :end-val="0" v-else />
</div>
</div>
</div>
<div class="flex-auto" v-else>
<div class="flex justify-between" style="align-items: center">
<div style="font-size: 1.625rem; color: #333; font-weight: bold">
<CountTo
v-if="growCardList?.customerInfo?.sumCount"
:end-val="growCardList.customerInfo.sumCount"
/>
<CountTo :end-val="0" v-else />
</div>
<img src="/src/assets/images/tip.png" style="width: 1.125rem; height: 1.125rem" />
</div>
<div>客户总量(个)</div>
</div>
</div>
<div v-if="!isAdmin(role)" class="ml-2 pt-4" style="border-top: 2px solid #f0f2f5">
今日新增
<span class="ml-4"
>消息量 {{ toThousands(growCardList?.messageInfo?.todayMessageAdd) }}</span
>
<span class="ml-4"
>数据点 {{ toThousands(growCardList?.messageInfo?.todayDataPointsAdd) }}</span
>
</div>
<div v-else class="ml-2 pt-4" style="border-top: 2px solid #f0f2f5">
今日新增 {{ toThousands(growCardList?.customerInfo?.todayAdd) }}</div
>
</Card>
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted, defineComponent } from 'vue';
import { Card } from 'ant-design-vue';
import { getHomeData } from '/@/api/dashboard';
import { isAdmin } from '/@/enums/roleEnum';
import { toThousands } from '/@/utils/fnUtils';
import { CountTo } from '/@/components/CountTo/index';
defineProps<{
role: string;
}>();
defineExpose({
isAdmin,
toThousands,
});
defineComponent({
Card,
});
interface CardList {
deviceInfo: {
sumCount: number;
onLine: number;
offLine: number;
inActive: number;
todayAdd: number;
};
tenantInfo?: { sumCount: number; todayAdd: number };
customerInfo?: { sumCount: number; todayAdd: number };
alarmInfo?: {
sumCount: number;
todayAdd: number;
};
messageInfo?: {
dataPointsCount: number;
messageCount: number;
todayDataPointsAdd: number;
todayMessageAdd: number;
};
}
const growCardList = ref<CardList>();
onMounted(async () => {
const res = await getHomeData();
growCardList.value = res;
});
</script>