From fc3018bfb27714352dcc0f6d52907e062681eb47 Mon Sep 17 00:00:00 2001 From: alwayssuper <191763414@qq.com> Date: Mon, 14 Apr 2025 11:25:01 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9Biothome?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/home/components/DeviceCountCard.vue | 87 ++++++++++++ .../home/components/DeviceStateCountCard.vue | 119 ++++++++++++++++ .../iot/home/components/MessageTrendCard.vue | 0 src/views/iot/home/index.vue | 133 +----------------- 4 files changed, 210 insertions(+), 129 deletions(-) create mode 100644 src/views/iot/home/components/DeviceCountCard.vue create mode 100644 src/views/iot/home/components/DeviceStateCountCard.vue create mode 100644 src/views/iot/home/components/MessageTrendCard.vue diff --git a/src/views/iot/home/components/DeviceCountCard.vue b/src/views/iot/home/components/DeviceCountCard.vue new file mode 100644 index 000000000..5b7ea5d42 --- /dev/null +++ b/src/views/iot/home/components/DeviceCountCard.vue @@ -0,0 +1,87 @@ + + + diff --git a/src/views/iot/home/components/DeviceStateCountCard.vue b/src/views/iot/home/components/DeviceStateCountCard.vue new file mode 100644 index 000000000..33415ea33 --- /dev/null +++ b/src/views/iot/home/components/DeviceStateCountCard.vue @@ -0,0 +1,119 @@ + + + diff --git a/src/views/iot/home/components/MessageTrendCard.vue b/src/views/iot/home/components/MessageTrendCard.vue new file mode 100644 index 000000000..e69de29bb diff --git a/src/views/iot/home/index.vue b/src/views/iot/home/index.vue index aa129d1c6..e88b219c3 100644 --- a/src/views/iot/home/index.vue +++ b/src/views/iot/home/index.vue @@ -42,43 +42,10 @@ - - -
-
+
- - - - -
-
- 在线设备 -
-
- -
-
- 离线设备 -
-
- -
-
- 待激活设备 -
-
-
-
+
@@ -134,6 +101,8 @@ import { } from '@/api/iot/statistics' import { formatDate } from '@/utils/formatTime' import ComparisonCard from './components/ComparisonCard.vue' +import DeviceCountCard from './components/DeviceCountCard.vue' +import DeviceStateCountCard from './components/DeviceStateCountCard.vue' // TODO @super:参考下 /Users/yunai/Java/yudao-ui-admin-vue3/src/views/mall/home/index.vue,拆一拆组件 @@ -252,104 +221,10 @@ const getStats = async () => { /** 初始化图表 */ const initCharts = () => { - // 设备数量统计 - echarts.init(deviceCountChartRef.value).setOption({ - tooltip: { - trigger: 'item' - }, - legend: { - top: '5%', - right: '10%', - align: 'left', - orient: 'vertical', - icon: 'circle' - }, - series: [ - { - name: 'Access From', - type: 'pie', - radius: ['50%', '80%'], - avoidLabelOverlap: false, - center: ['30%', '50%'], - label: { - show: false, - position: 'outside' - }, - emphasis: { - label: { - show: true, - fontSize: 20, - fontWeight: 'bold' - } - }, - labelLine: { - show: false - }, - data: Object.entries(statsData.value.productCategoryDeviceCounts).map(([name, value]) => ({ - name, - value - })) - } - ] - }) - - // 在线设备统计 - initGaugeChart(deviceOnlineCountChartRef.value, statsData.value.deviceOnlineCount, '#0d9') - // 离线设备统计 - initGaugeChart(deviceOfflineChartRef.value, statsData.value.deviceOfflineCount, '#f50') - // 待激活设备统计 - initGaugeChart(deviceActiveChartRef.value, statsData.value.deviceInactiveCount, '#05b') - // 消息量统计 initMessageChart() } -/** 初始化仪表盘图表 */ -const initGaugeChart = (el: any, value: number, color: string) => { - echarts.init(el).setOption({ - series: [ - { - type: 'gauge', - startAngle: 360, - endAngle: 0, - min: 0, - max: statsData.value.deviceCount || 100, // 使用设备总数作为最大值 - progress: { - show: true, - width: 12, - itemStyle: { - color: color - } - }, - axisLine: { - lineStyle: { - width: 12, - color: [[1, '#E5E7EB']] - } - }, - axisTick: { show: false }, - splitLine: { show: false }, - axisLabel: { show: false }, - pointer: { show: false }, - anchor: { show: false }, - title: { show: false }, - detail: { - valueAnimation: true, - fontSize: 24, - fontWeight: 'bold', - fontFamily: 'Inter, sans-serif', - color: color, - offsetCenter: [0, '0'], - formatter: (value: number) => { - return `${value} 个` - } - }, - data: [{ value: value }] - } - ] - }) -} - /** 初始化消息统计图表 */ const initMessageChart = () => { // 获取所有时间戳并排序