diff --git a/src/components/pages/MallsPage.tsx b/src/components/pages/MallsPage.tsx
index da043e3..bddce79 100644
--- a/src/components/pages/MallsPage.tsx
+++ b/src/components/pages/MallsPage.tsx
@@ -22,8 +22,6 @@ import {
Plus,
Search,
MapPin,
- Users,
- Shield,
ChevronDown,
ChevronRight,
Store,
@@ -507,54 +505,6 @@ export default function MallsPage() {
)}
- {/* 统计卡片 */}
-
-
-
- 商场总数
-
-
-
- {malls.length}
-
- 正常运营 {malls.filter((m) => m.status === "1").length} 个
-
-
-
-
-
- 商户总数
-
-
-
- 0
- 分布在 {malls.length} 个商场
-
-
-
-
- 设备总数
-
-
-
- 0
-
- 平均每商场 0 台
-
-
-
-
-
- 经销商覆盖
-
-
-
- {new Set(malls.map((m) => m.mallUser)).size}
- 商场管理员数量
-
-
-
-
{/* 搜索和筛选 */}
diff --git a/src/components/pages/MerchantsPage.tsx b/src/components/pages/MerchantsPage.tsx
index 66c8fd0..0451689 100644
--- a/src/components/pages/MerchantsPage.tsx
+++ b/src/components/pages/MerchantsPage.tsx
@@ -1,4 +1,4 @@
-import React, { useState, useEffect } from "react"
+import { useState, useEffect } from "react"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../ui/card"
import { Button } from "../ui/button"
import { Input } from "../ui/input"
@@ -13,9 +13,8 @@ import {
DialogDescription,
DialogHeader,
DialogTitle,
- DialogTrigger,
} from "../ui/dialog"
-import { Plus, Search, Filter, Download, Calendar, AlertTriangle, Store, Eye, Building2, MapPin, ChevronLeft, ChevronRight } from "lucide-react"
+import { Plus, Search, Filter, Download, Store, Eye, Building2, MapPin, ChevronLeft, ChevronRight } from "lucide-react"
import { apiGet, apiPost, apiPut } from "../../lib/services/api"
// 总商户数据类型
@@ -382,16 +381,6 @@ export default function MerchantsPage() {
}
}
- const getMerchantStatusBadge = (merchant: any) => {
- if (merchant.expiredCount > 0) {
- return 有设备过期
- } else if (merchant.expiringCount > 0) {
- return 有设备即将到期
- } else {
- return 设备正常
- }
- }
-
// 打开编辑对话框
const handleEditMerchant = (merchant: any) => {
setEditMerchant({
@@ -529,64 +518,6 @@ export default function MerchantsPage() {
)}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{/* Filters and Search */}
diff --git a/src/components/pages/StatisticsPage.tsx b/src/components/pages/StatisticsPage.tsx
index 0cee260..9e4d4bb 100644
--- a/src/components/pages/StatisticsPage.tsx
+++ b/src/components/pages/StatisticsPage.tsx
@@ -56,9 +56,25 @@ interface DealerDistributionData {
totalCount: number
}
+// 定义设备状态分布数据接口
+interface DeviceDistribution {
+ name: string
+ value: number
+}
+
+// 定义月度工单趋势数据接口
+interface WorkOrderTrend {
+ month: string
+ completed: number
+ pending: number
+ total: number | string // total 可能是字符串或数字
+}
+
export default function StatisticsPage() {
const [statisticsData, setStatisticsData] = useState(null)
const [dealerDistributionData, setDealerDistributionData] = useState([])
+ const [deviceDistributionData, setDeviceDistributionData] = useState([])
+ const [workOrderTrendData, setWorkOrderTrendData] = useState([])
const [loading, setLoading] = useState(true)
const userData = getUserData()
@@ -68,6 +84,8 @@ export default function StatisticsPage() {
useEffect(() => {
fetchStatistics()
fetchDealerDistribution()
+ fetchDeviceDistribution()
+ fetchWorkOrderTrend()
}, [])
const fetchStatistics = async () => {
@@ -95,6 +113,28 @@ export default function StatisticsPage() {
}
}
+ const fetchDeviceDistribution = async () => {
+ try {
+ const response = await apiGet<{ code: number; msg: string; data: DeviceDistribution[] }>('/back/statistics/deviceDistribution')
+ if (response.code === 200) {
+ setDeviceDistributionData(response.data)
+ }
+ } catch (error) {
+ console.error('获取设备状态分布数据失败:', error)
+ }
+ }
+
+ const fetchWorkOrderTrend = async () => {
+ try {
+ const response = await apiGet<{ code: number; msg: string; data: WorkOrderTrend[] }>('/back/statistics/workOrderCompletionTrend')
+ if (response.code === 200) {
+ setWorkOrderTrendData(response.data)
+ }
+ } catch (error) {
+ console.error('获取月度工单趋势数据失败:', error)
+ }
+ }
+
const stats = {
totalEquipment: statisticsData?.equipmentTotal || 0,
activeWorkOrders: statisticsData?.completedWorkOrders || 0,
@@ -153,22 +193,32 @@ export default function StatisticsPage() {
],
}
- // 设备状态分布数据
- const equipmentStatusData = [
- { name: "正常运行", value: 1156, color: "#10B981" },
- { name: "即将到期", value: 67, color: "#F59E0B" },
- { name: "已过期", value: 25, color: "#EF4444" },
- ]
+ // 根据状态名称获取颜色
+ const getColorByStatusName = (name: string): string => {
+ const colorMap: { [key: string]: string } = {
+ '正常': '#10B981',
+ '正常运行': '#10B981',
+ '即将到期': '#F59E0B',
+ '已过期': '#EF4444',
+ '过期': '#EF4444',
+ }
+ return colorMap[name] || '#6B7280' // 默认灰色
+ }
- // 月度工单完成情况
- const monthlyWorkOrderData = [
- { month: "1月", completed: 145, pending: 23, total: 168 },
- { month: "2月", completed: 132, pending: 18, total: 150 },
- { month: "3月", completed: 156, pending: 25, total: 181 },
- { month: "4月", completed: 142, pending: 19, total: 161 },
- { month: "5月", completed: 167, pending: 22, total: 189 },
- { month: "6月", completed: 158, pending: 27, total: 185 },
- ]
+ // 设备状态分布数据 - 从接口获取并添加颜色
+ const equipmentStatusData = deviceDistributionData.map(item => ({
+ name: item.name,
+ value: item.value,
+ color: getColorByStatusName(item.name)
+ }))
+
+ // 月度工单完成情况 - 从接口获取
+ const monthlyWorkOrderData = workOrderTrendData.map(item => ({
+ month: item.month,
+ completed: typeof item.completed === 'string' ? Number(item.completed) : item.completed,
+ pending: typeof item.pending === 'string' ? Number(item.pending) : item.pending,
+ total: typeof item.total === 'string' ? Number(item.total) : item.total,
+ }))
// provinceData 已从接口获取,存储在 dealerDistributionData 中
diff --git a/src/components/pages/WorkersPage.tsx b/src/components/pages/WorkersPage.tsx
index 93bb36a..70c9880 100644
--- a/src/components/pages/WorkersPage.tsx
+++ b/src/components/pages/WorkersPage.tsx
@@ -16,20 +16,16 @@ import { Label } from "../ui/label"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "../ui/table"
import {
- Users,
Plus,
Search,
MapPin,
- Shield,
ChevronDown,
ChevronRight,
User,
Edit,
Trash2,
Phone,
- Award,
Wrench,
- CheckCircle,
} from "lucide-react"
import { apiPost, apiGet, apiPut, apiDelete } from "../../lib/services/api"
import { getProvinces } from '../../lib/services/region'
@@ -805,60 +801,6 @@ export default function WorkersPage() {
- {/* 统计卡片 */}
-
-
-
- 工人总数
-
-
-
- {workers.length}
-
- 在职 {workers.filter((w) => w.status === "active").length} 人
-
-
-
-
-
- 高级技师
-
-
-
- {workers.filter((w) => w.skillLevel === "高级技师").length}
-
- 占比 {workers.length > 0 ? Math.round((workers.filter((w) => w.skillLevel === "高级技师").length / workers.length) * 100) : 0}%
-
-
-
-
-
- 完成工单
-
-
-
- {workers.reduce((sum, w) => sum + w.completedOrders, 0)}
-
- 平均每人 {workers.length > 0 ? Math.round(workers.reduce((sum, w) => sum + w.completedOrders, 0) / workers.length) : 0} 单
-
-
-
-
-
- 平均评分
-
-
-
-
- {workers.filter((w) => w.rating > 0).length > 0
- ? (workers.reduce((sum, w) => sum + w.rating, 0) / workers.filter((w) => w.rating > 0).length).toFixed(1)
- : '-'}
-
- 满分 5.0 分
-
-
-
-
{/* 搜索和筛选 */}