gaoluyang
2026-06-24 712aa51536236d43e87273e4ce45ac5691dffad8
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
<script lang="ts" setup>
import type { StatsData } from './data';
 
import { onMounted, ref } from 'vue';
 
import { ComparisonCard, Page } from '..\..\..\packages\effects\common-ui\src';
 
import { Col, Row } from 'ant-design-vue';
 
import { getStatisticsSummary } from '#/api/iot/statistics';
 
import { defaultStatsData } from './data';
import DeviceCountCard from './modules/device-count-card.vue';
import DeviceMapCard from './modules/device-map-card.vue';
import DeviceStateCountCard from './modules/device-state-count-card.vue';
import MessageTrendCard from './modules/message-trend-card.vue';
 
const loading = ref(true);
const statsData = ref<StatsData>(defaultStatsData);
 
/** 加载数据 */
async function loadData() {
  loading.value = true;
  try {
    statsData.value = await getStatisticsSummary();
  } finally {
    loading.value = false;
  }
}
 
/** 初始化 */
onMounted(() => {
  loadData();
});
</script>
 
<template>
  <Page>
    <!-- 第一行:统计卡片 -->
    <Row :gutter="16" class="mb-4">
      <Col :span="6">
        <ComparisonCard
          title="分类数量"
          :value="statsData.productCategoryCount"
          :today-count="statsData.productCategoryTodayCount"
          icon="menu"
          icon-color="text-blue-500"
          :loading="loading"
        />
      </Col>
      <Col :span="6">
        <ComparisonCard
          title="产品数量"
          :value="statsData.productCount"
          :today-count="statsData.productTodayCount"
          icon="box"
          icon-color="text-orange-500"
          :loading="loading"
        />
      </Col>
      <Col :span="6">
        <ComparisonCard
          title="设备数量"
          :value="statsData.deviceCount"
          :today-count="statsData.deviceTodayCount"
          icon="cpu"
          icon-color="text-purple-500"
          :loading="loading"
        />
      </Col>
      <Col :span="6">
        <ComparisonCard
          title="设备消息数"
          :value="statsData.deviceMessageCount"
          :today-count="statsData.deviceMessageTodayCount"
          icon="message"
          icon-color="text-teal-500"
          :loading="loading"
        />
      </Col>
    </Row>
 
    <!-- 第二行:图表 -->
    <Row :gutter="16" class="mb-4">
      <Col :span="12">
        <DeviceCountCard :stats-data="statsData" :loading="loading" />
      </Col>
      <Col :span="12">
        <DeviceStateCountCard :stats-data="statsData" :loading="loading" />
      </Col>
    </Row>
 
    <!-- 第三行:消息统计 -->
    <Row :gutter="16" class="mb-4">
      <Col :span="24">
        <MessageTrendCard />
      </Col>
    </Row>
 
    <!-- 第四行:设备分布地图 -->
    <Row :gutter="16">
      <Col :span="24">
        <DeviceMapCard />
      </Col>
    </Row>
  </Page>
</template>