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 = () => {
// 获取所有时间戳并排序