PieChartDevice.vue
3.28 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
<template>
<div class="md:flex mt-4">
<Card
size="small"
class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:mr-4"
style="color: #666; width: 50%"
>
<div class="flex container">
<div class="mr-4 flex chart-top">
<PieChartDeviceSub :legendData="legendData" :seriesData="seriesData" />
</div>
<div class="ml-20 flex justify-around right-text">
<div class="text"> 直连设备:4个 </div>
<div class="text"> 网关设备:1个 </div>
<div class="text"> 网关子设备:6个 </div>
</div>
</div>
</Card>
<Card
size="small"
class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:ml-1"
style="color: #666; width: 50%"
>
<div class="flex container">
<div class="mr-4 flex chart-top">
<PieChartDeviceSub :legendData="legendStatusData" :seriesData="seriesStatusData" />
</div>
<div class="ml-20 flex justify-around right-text">
<div class="text"> 待激活设备:2个 </div>
<div class="text"> 在线设备:1个 </div>
<div class="text"> 离线设备:4个 </div>
</div>
</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 PieChartDeviceSub from './PieChartDeviceSub.vue';
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>();
const legendData = ref<string[]>(['gateway', 'directly', 'sub-device']);
const seriesData = ref([
{ value: 1048, name: 'gateway', itemStyle: { color: '#3aa0ff' } },
{ value: 735, name: 'directly', itemStyle: { color: '#36cbcb' } },
{ value: 580, name: 'sub-device', itemStyle: { color: '#4ecb73' } },
]);
const legendStatusData = ref<string[]>(['inactive', 'online', 'offline']);
const seriesStatusData = ref([
{ value: 1048, name: 'inactive', itemStyle: { color: '#3aa0ff' } },
{ value: 735, name: 'online', itemStyle: { color: '#36cbcb' } },
{ value: 580, name: 'offline', itemStyle: { color: '#4ecb73' } },
]);
onMounted(async () => {
const res = await getHomeData();
growCardList.value = res;
});
</script>
<style lang="css">
.right-text {
width: 40%;
flex-direction: column;
height: 240px;
margin: 10px 0 10px 50px;
}
.text {
color: #333;
font-weight: bold;
display: flex;
flex-wrap: nowrap;
}
.chart-top {
width: 60%;
height: 300px;
align-items: center;
margin-top: -30px;
}
.container {
width: 100%;
}
</style>