diff --git a/src/components/pages/EquipmentPage.tsx b/src/components/pages/EquipmentPage.tsx index 8927e92..e778f51 100644 --- a/src/components/pages/EquipmentPage.tsx +++ b/src/components/pages/EquipmentPage.tsx @@ -85,6 +85,28 @@ export default function EquipmentPage() { pageSize: 10, total: 0 }) + const [equipmentStats, setEquipmentStats] = useState({ + count: 0, + totalCount: 0, + countEnd: 0, + countExpire: 0 + }) + const [loadingStats, setLoadingStats] = useState(false) + + // 获取设备统计数据 + const fetchEquipmentStats = async () => { + setLoadingStats(true) + try { + const response = await apiGet('/back/equipment/user/count') + if (response.code === 200) { + setEquipmentStats(response.data) + } + } catch (error) { + console.error('获取设备统计数据失败:', error) + } finally { + setLoadingStats(false) + } + } // 获取设备类型列表 const fetchEquipmentTypes = async () => { @@ -167,6 +189,7 @@ export default function EquipmentPage() { } useEffect(() => { + fetchEquipmentStats() fetchEquipmentTypes() fetchEquipmentList() }, []) @@ -669,6 +692,57 @@ export default function EquipmentPage() { + {/* 统计卡片 */} +
+ + +
+
+

设备正常

+

+ {loadingStats ? '-' : equipmentStats.count} +

+
+
+ +
+
+
+
+ + + +
+
+

有设备即将到期

+

+ {loadingStats ? '-' : equipmentStats.countEnd} +

+
+
+ +
+
+
+
+ + + +
+
+

有设备过期

+

+ {loadingStats ? '-' : equipmentStats.countExpire} +

+
+
+ +
+
+
+
+
+
diff --git a/src/components/pages/UsersPage.tsx b/src/components/pages/UsersPage.tsx index 185921e..a8faff8 100644 --- a/src/components/pages/UsersPage.tsx +++ b/src/components/pages/UsersPage.tsx @@ -132,61 +132,6 @@ export default function UsersPage() {
- {/* Stats Cards */} -
- - -
-
-

总用户数

-

{users.length}

-
- -
-
-
- - - -
-
-

活跃用户

-

{users.filter((u) => u.status === "active").length}

-
- -
-
-
- - - -
-
-

总订单数

-

- {users.reduce((sum, user) => sum + user.orderCount, 0)} -

-
- -
-
-
- - - -
-
-

总消费金额

-

- ¥{users.reduce((sum, user) => sum + user.totalSpent, 0)} -

-
- -
-
-
-
- {/* Filters and Search */} diff --git a/src/components/pages/WorkOrderArchivePage.tsx b/src/components/pages/WorkOrderArchivePage.tsx index ff0ade6..2e51005 100644 --- a/src/components/pages/WorkOrderArchivePage.tsx +++ b/src/components/pages/WorkOrderArchivePage.tsx @@ -6,7 +6,7 @@ import { Badge } from "../ui/badge"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "../ui/dialog"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "../ui/table"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select"; -import { Search, Eye, Download, FileText, CheckCircle, User, Building, ChevronLeft, ChevronRight, FileDown } from "lucide-react"; +import { Search, Eye, Download, FileText, CheckCircle, XCircle, ChevronLeft, ChevronRight, FileDown } from "lucide-react"; import { apiGet, API_BASE_URL } from "../../lib/services/api"; import { getUserToken } from "../../lib/utils/storage"; @@ -50,12 +50,33 @@ export default function WorkOrderArchivePage() { pageSize: 10, total: 0 }); + const [archiveCount, setArchiveCount] = useState({ + count: 0, + hcount: 0, + ncount: 0 + }); + + // 获取归档统计数据 + const fetchArchiveCount = async () => { + try { + const response = await apiGet('/back/workers/archiveCount'); + if (response.code === 200 && response.data) { + setArchiveCount({ + count: response.data.count || 0, + hcount: response.data.hcount || 0, + ncount: response.data.ncount || 0 + }); + } + } catch (error) { + console.error('获取归档统计数据失败:', error); + } + }; // 获取归档工单列表 const fetchArchivedOrders = async (pageNum = 1, pageSize = 10) => { setLoading(true); try { - const response = await apiGet(`/client/work/list?queryStaus=6&pageNum=${pageNum}&pageSize=${pageSize}`); + const response = await apiGet(`/client/work/list?queryStaus=7&pageNum=${pageNum}&pageSize=${pageSize}`); if (response.code === 200) { setArchivedOrders(response.data || []); setPagination({ @@ -72,6 +93,7 @@ export default function WorkOrderArchivePage() { }; useEffect(() => { + fetchArchiveCount(); fetchArchivedOrders(); }, []); @@ -165,13 +187,13 @@ export default function WorkOrderArchivePage() { {/* Statistics Cards */} -
+

归档总数

-

{pagination.total}

+

{archiveCount.count}

@@ -182,8 +204,8 @@ export default function WorkOrderArchivePage() {
-

当前页

-

{archivedOrders.length}

+

合格报告数量

+

{archiveCount.hcount}

@@ -194,22 +216,10 @@ export default function WorkOrderArchivePage() {
-

页码

-

{pagination.pageNum}/{Math.ceil(pagination.total / pagination.pageSize)}

+

不合格报告数量

+

{archiveCount.ncount}

- -
-
-
- - - -
-
-

每页数量

-

{pagination.pageSize}

-
- +
diff --git a/src/components/pages/WorkOrdersPage.tsx b/src/components/pages/WorkOrdersPage.tsx index c77eac0..b6c5f77 100644 --- a/src/components/pages/WorkOrdersPage.tsx +++ b/src/components/pages/WorkOrdersPage.tsx @@ -21,13 +21,13 @@ import { Download, Clock, CheckCircle, - AlertCircle, User, Calendar, MapPin, MoreHorizontal, ChevronLeft, ChevronRight, + Wrench, } from "lucide-react" import { apiGet, apiPost } from "../../lib/services/api" @@ -106,9 +106,6 @@ interface Worker { jobNum: string } -// 优先级数据类型接口 - API返回键值对格式 -type PriorityData = Record - // 工单状态枚举 enum WorkOrderStatus { PENDING_ACCEPT = 1, @@ -165,6 +162,23 @@ export default function WorkOrdersPage() { const [totalWorkOrders, setTotalWorkOrders] = useState(0) const [currentPage, setCurrentPage] = useState(1) const [pageSize, setPageSize] = useState(10) + const [statusCounts, setStatusCounts] = useState>({}) + + // 获取工单状态统计 + const fetchStatusCounts = async () => { + try { + const response = await apiGet('/back/orders/statusCount') + if (response.code === 200 && response.data) { + const counts: Record = {} + response.data.forEach((item: { num: string; status: number }) => { + counts[item.status] = parseInt(item.num) || 0 + }) + setStatusCounts(counts) + } + } catch (error) { + console.error('获取工单状态统计失败:', error) + } + } // 获取工单列表 const fetchWorkOrders = async (page = currentPage, size = pageSize) => { @@ -196,9 +210,10 @@ export default function WorkOrdersPage() { fetchWorkOrders(1, size) } - // 组件加载时获取工单列表 + // 组件加载时获取工单列表和状态统计 useEffect(() => { fetchWorkOrders() + fetchStatusCounts() }, []) const getStatusBadge = (status: string | number) => { @@ -224,29 +239,6 @@ export default function WorkOrdersPage() { } } - const getPriorityBadge = (priority: string) => { - switch (priority) { - case "1": - return 紧急 - case "2": - return - case "3": - return - case "4": - return - case "urgent": - return 紧急 - case "high": - return - case "medium": - return - case "low": - return - default: - return 未知 - } - } - const getTypeBadge = (type: string) => { switch (type) { case "设备检测": @@ -306,6 +298,7 @@ export default function WorkOrdersPage() { { setIsCreateDialogOpen(false) fetchWorkOrders(currentPage, pageSize) + fetchStatusCounts() }} /> @@ -317,8 +310,10 @@ export default function WorkOrdersPage() {
-

待分配

-

2

+

待接单

+

+ {statusCounts[1] || 0} +

@@ -332,7 +327,9 @@ export default function WorkOrdersPage() {

进行中

-

1

+

+ {statusCounts[3] || 0} +

@@ -345,11 +342,13 @@ export default function WorkOrdersPage() {
-

已完成

-

1

+

维修中

+

+ {statusCounts[4] || 0} +

-
- +
+
@@ -359,11 +358,13 @@ export default function WorkOrdersPage() {
-

逾期工单

-

0

+

已完成

+

+ {statusCounts[7] || 0} +

-
- +
+
diff --git a/src/lib/services/api.ts b/src/lib/services/api.ts index 772d6dc..256699f 100644 --- a/src/lib/services/api.ts +++ b/src/lib/services/api.ts @@ -1,7 +1,9 @@ import { getUserToken, removeStorageItem, runOnClient } from '@/lib/utils/storage' // API 客户端工具,统一处理请求和认证 -const API_BASE_URL = 'http://localhost:8080/api' +const API_BASE_URL = 'http://116.204.124.80:8080/api' +//const API_BASE_URL = 'http://localhost:8080/api' + // 获取存储的 token function getToken(): string | null { diff --git a/src/services/api.ts b/src/services/api.ts index 1806e16..9a68d24 100644 --- a/src/services/api.ts +++ b/src/services/api.ts @@ -1,7 +1,9 @@ import { getUserToken, removeStorageItem, runOnClient } from '@/utils/storage' // API 客户端工具,统一处理请求和认证 -const API_BASE_URL = 'http://localhost:8080/api' +const API_BASE_URL = 'http://116.204.124.80:8080/api' +//const API_BASE_URL = 'http://localhost:8080/api' + // 获取存储的 token function getToken(): string | null {