Skip to content

Commit 9a3d1ad

Browse files
committed
feat: home 1
1 parent b7d6c94 commit 9a3d1ad

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

src/views/iot/home/index.vue

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<div class="flex flex-col">
99
<div class="flex justify-between items-center mb-1">
1010
<span class="text-gray-500 text-base font-medium">品类数量</span>
11-
<Icon icon="ep:menu" class="text-2xl text-blue-400" />
11+
<Icon icon="ep:menu" class="text-[32px] text-blue-400" />
1212
</div>
1313
<span class="text-3xl font-bold text-gray-700">{{ statsData.categoryTotal }}</span>
1414
<el-divider class="my-2" />
@@ -24,7 +24,7 @@
2424
<div class="flex flex-col">
2525
<div class="flex justify-between items-center mb-1">
2626
<span class="text-gray-500 text-base font-medium">产品数量</span>
27-
<Icon icon="ep:box" class="text-2xl text-orange-400" />
27+
<Icon icon="ep:box" class="text-[32px] text-orange-400" />
2828
</div>
2929
<span class="text-3xl font-bold text-gray-700">{{ statsData.productTotal }}</span>
3030
<el-divider class="my-2" />
@@ -40,7 +40,7 @@
4040
<div class="flex flex-col">
4141
<div class="flex justify-between items-center mb-1">
4242
<span class="text-gray-500 text-base font-medium">设备数量</span>
43-
<Icon icon="ep:cpu" class="text-2xl text-purple-400" />
43+
<Icon icon="ep:cpu" class="text-[32px] text-purple-400" />
4444
</div>
4545
<span class="text-3xl font-bold text-gray-700">{{ statsData.deviceTotal }}</span>
4646
<el-divider class="my-2" />
@@ -56,7 +56,7 @@
5656
<div class="flex flex-col">
5757
<div class="flex justify-between items-center mb-1">
5858
<span class="text-gray-500 text-base font-medium">物模型消息</span>
59-
<Icon icon="ep:message" class="text-2xl text-teal-400" />
59+
<Icon icon="ep:message" class="text-[32px] text-teal-400" />
6060
</div>
6161
<span class="text-3xl font-bold text-gray-700">{{ statsData.reportTotal }}</span>
6262
<el-divider class="my-2" />
@@ -236,12 +236,19 @@ const initCharts = () => {
236236
237237
/** 初始化仪表盘图表 */
238238
const initGaugeChart = (el: any, value: number, color: string) => {
239+
// 计算百分比,保留1位小数
240+
const percentage = statsData.value.deviceTotal > 0
241+
? Number(((value / statsData.value.deviceTotal) * 100).toFixed(1))
242+
: 0
243+
239244
echarts.init(el).setOption({
240245
series: [
241246
{
242247
type: 'gauge',
243248
startAngle: 360,
244249
endAngle: 0,
250+
min: 0,
251+
max: 100, // 将最大值设为100
245252
progress: {
246253
show: true,
247254
width: 12,
@@ -263,16 +270,29 @@ const initGaugeChart = (el: any, value: number, color: string) => {
263270
title: { show: false },
264271
detail: {
265272
valueAnimation: true,
266-
fontSize: 24,
273+
fontSize: 20,
267274
fontWeight: 'bold',
268275
fontFamily: 'Inter, sans-serif',
269276
color: color,
270277
offsetCenter: [0, '0'],
271278
formatter: (value: number) => {
272-
return value + ''
279+
return `${value}%\n(${statsData.value.deviceTotal > 0 ? Math.round((value / 100) * statsData.value.deviceTotal) : 0}个)`
280+
},
281+
rich: {
282+
value: {
283+
fontSize: 20,
284+
fontWeight: 'bold',
285+
color: color,
286+
padding: [0, 0, 10, 0]
287+
},
288+
unit: {
289+
fontSize: 14,
290+
color: '#6B7280',
291+
padding: [0, 0, 0, 0]
292+
}
273293
}
274294
},
275-
data: [{ value: value }]
295+
data: [{ value: percentage }]
276296
}
277297
]
278298
})

0 commit comments

Comments
 (0)