GrowCard.vue
4.93 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
<template>
<div class="md:flex">
<Card size="small" class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:mr-4">
<div class="flex" style="height: 100px">
<div class="mr-4"
><img src="/src/assets/images/device-count.png" style="width: 5rem; height: 5rem"
/></div>
<div class="flex-auto">
<div class="flex justify-between" style="align-items: center">
<div style="font-size: 1.625rem; color: #333">{{
growCardList?.deviceInfo?.sumCount
}}</div>
<img src="/src/assets/images/tip.png" style="width: 1.4rem; height: 1.4rem" />
</div>
<div> 设备数(个) </div>
<div class="flex mt-2">
<div class="flex mr-1" style="align-items: center; font-size: 0.75rem"
><img src="/src/assets/images/online.png" class="mr-1" />
<span>在线{{ growCardList?.deviceInfo?.onLine }}</span>
</div>
<div class="flex mr-1" style="align-items: center; font-size: 0.75rem">
<img src="/src/assets/images/offline.png" class="mr-1" />
<span> 离线{{ growCardList?.deviceInfo?.offLine }} </span>
</div>
<div class="flex mr-1" style="align-items: center; font-size: 0.75rem">
<img src="/src/assets/images/inactive.png" class="mr-1" />
<span> 未激活{{ growCardList?.deviceInfo?.inActive }} </span>
</div>
</div>
</div>
</div>
<div class="ml-2 pt-4" style="border-top: 2px solid #f0f2f5">
今日新增 {{ growCardList?.deviceInfo?.todayAdd }}</div
>
</Card>
<Card size="small" class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:mr-4">
<div class="flex" style="height: 100px">
<div class="mr-4">
<img
v-if="!isAdmin(role)"
src="/src/assets/images/alarm-count.png"
style="width: 5rem; height: 5rem"
/>
<img v-else src="/src/assets/images/zh.png" style="width: 5rem; height: 5rem" />
</div>
<div class="flex-auto">
<div class="flex justify-between" style="align-items: center">
<div style="font-size: 1.625rem; color: #333">{{
growCardList?.tenantInfo?.sumCount
}}</div>
<img src="/src/assets/images/tip.png" style="width: 1.4rem; height: 1.4rem" />
</div>
<div> {{ !isAdmin(role) ? `${currentMonth}月告警数(条)` : '租户总量(个)' }}</div>
</div>
</div>
<div class="ml-2 pt-4" style="border-top: 2px solid #f0f2f5">
今日新增 {{ growCardList?.tenantInfo?.todayAdd }}</div
>
</Card>
<Card size="small" class="md:w-1/3 w-full !md:mt-0 !mt-4">
<div class="flex" style="height: 100px">
<div class="mr-4"
><img
v-if="!isAdmin(role)"
src="/src/assets/images/msg-count.png"
style="width: 5rem; height: 5rem"
/><img v-else src="/src/assets/images/kf.png" style="width: 5rem; height: 5rem" />
</div>
<div style="display: flex; align-items: center">
<div v-if="!isAdmin(role)">
<div>
{{ `${currentMonth}月数据点(条)` }}
<span>{{ growCardList?.messageInfo?.dataPointsCount }}</span>
</div>
<div>
{{ `${currentMonth}月消息量(条)` }}
<span>{{ growCardList?.messageInfo?.messageCount }}</span>
</div>
</div>
<div v-else>客户总量(个)</div>
</div>
</div>
<div class="ml-2 pt-4" style="border-top: 2px solid #f0f2f5">
<div>
今日新增
<span class="ml-8">数据点 ({{ growCardList?.messageInfo?.todayDataPointsAdd }})</span>
<span class="ml-8">消息量 ({{ growCardList?.messageInfo?.todayMessageAdd }})</span>
</div>
</div>
</Card>
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted, computed } from 'vue';
import { Card } from 'ant-design-vue';
import { getHomeData } from '/@/api/dashboard';
import { isAdmin } from '/@/enums/roleEnum';
defineProps<{
role: string;
}>();
defineExpose({
isAdmin,
});
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;
});
// 获取当前月份0-11 +1
const currentMonth = computed(() => {
return new Date().getMonth() + 1;
});
</script>