From 940b587df9c871eb053eb26417b9a12374a6de29 Mon Sep 17 00:00:00 2001 From: wangziqi Date: Sun, 5 Jul 2026 21:35:03 +0800 Subject: [PATCH] fix: remove nested button patterns across all pages, remove Dashboard gantt --- apps/admin/src/pages/Bills/index.tsx | 47 ++++---- .../src/pages/ClassroomRentals/index.tsx | 18 ++- apps/admin/src/pages/Classrooms/index.tsx | 34 +++--- apps/admin/src/pages/Dashboard/index.tsx | 66 +---------- apps/admin/src/pages/Deposits/index.tsx | 49 ++++---- apps/admin/src/pages/Expenses/index.tsx | 112 +++++++++--------- apps/admin/src/pages/Occupancies/index.tsx | 61 +++++----- apps/admin/src/pages/Roles/index.tsx | 12 +- apps/admin/src/pages/Students/index.tsx | 69 ++++++----- apps/admin/src/pages/Tenants/index.tsx | 22 ++-- apps/admin/src/pages/Users/index.tsx | 12 +- 11 files changed, 214 insertions(+), 288 deletions(-) diff --git a/apps/admin/src/pages/Bills/index.tsx b/apps/admin/src/pages/Bills/index.tsx index 220c0e1..9a834fd 100644 --- a/apps/admin/src/pages/Bills/index.tsx +++ b/apps/admin/src/pages/Bills/index.tsx @@ -285,18 +285,16 @@ const BillsPage: React.FC = () => { > PDF - - handleDelete(record.id)} - okText="删除" - cancelText="取消" - > - - - + handleDelete(record.id)} + okText="删除" + cancelText="取消" + > + }> + 删除 + + ), }, @@ -350,19 +348,22 @@ const BillsPage: React.FC = () => { > 批量标记已付 - - + } > - - - + 批量删除 + + { openEdit(record)}> 编辑 - - handleDelete(record.id)} - > - - - + handleDelete(record.id)} + > + + 删除 + + ), }, diff --git a/apps/admin/src/pages/Classrooms/index.tsx b/apps/admin/src/pages/Classrooms/index.tsx index f301594..515ebf7 100644 --- a/apps/admin/src/pages/Classrooms/index.tsx +++ b/apps/admin/src/pages/Classrooms/index.tsx @@ -150,13 +150,11 @@ const ClassroomsPage: React.FC = () => { render: (_: any, record: any) => ( {record.status === 'archived' ? ( - - handleRestore(record.id)}> - - - + handleRestore(record.id)}> + } type="link"> + 恢复 + + ) : ( <> { > 编辑 - - handleArchive(record.id)} - okText="归档" - cancelText="取消" - > - - - + handleArchive(record.id)} + okText="归档" + cancelText="取消" + > + }> + 归档 + + )} diff --git a/apps/admin/src/pages/Dashboard/index.tsx b/apps/admin/src/pages/Dashboard/index.tsx index ce97939..8fda22c 100644 --- a/apps/admin/src/pages/Dashboard/index.tsx +++ b/apps/admin/src/pages/Dashboard/index.tsx @@ -22,7 +22,6 @@ const DashboardPage: React.FC = () => { const screens = Grid.useBreakpoint(); const isMobile = !screens.sm; const [stats, setStats] = useState(null); - const [ganttData, setGanttData] = useState([]); const [expenseStats, setExpenseStats] = useState([]); const [roomRanking, setRoomRanking] = useState([]); const [loading, setLoading] = useState(true); @@ -34,9 +33,8 @@ const DashboardPage: React.FC = () => { const fetchData = async () => { setLoading(true); try { - const [s, g, e, r] = await Promise.all([ + const [s, e, r] = await Promise.all([ api.get('/dashboard/stats'), - api.get('/dashboard/gantt', { params: { periodStart: period[0], periodEnd: period[1] } }), api.get('/dashboard/expense-stats', { params: { periodStart: period[0], periodEnd: period[1] }, }), @@ -45,7 +43,6 @@ const DashboardPage: React.FC = () => { }), ]); setStats(s); - setGanttData(g as any); setExpenseStats(e as any); setRoomRanking(r as any); } catch (e) { @@ -70,56 +67,6 @@ const DashboardPage: React.FC = () => { other: '其他', }; - // 甘特图配置 - const ganttOption = () => { - if (!ganttData.length) return {}; - const rooms = ganttData.map((d) => d.roomNumber); - const pStart = new Date(period[0]).getTime(); - const pEnd = new Date(period[1]).getTime(); - - const data: any[] = []; - ganttData.forEach((room, roomIdx) => { - room.occupancies.forEach((occ: any, i: number) => { - const start = Math.max(new Date(occ.checkInDate).getTime(), pStart); - const end = occ.checkOutDate ? Math.min(new Date(occ.checkOutDate).getTime(), pEnd) : pEnd; - data.push({ - name: occ.studentName, - value: [roomIdx, start, end, occ.studentName], - itemStyle: { color: COLORS[(occ.studentId || i) % COLORS.length] }, - }); - }); - }); - - return { - tooltip: { - formatter: (p: any) => { - const v = p.value; - return `${p.name}
宿舍: ${rooms[v[0]]}
入住: ${dayjs(v[1]).format('MM-DD')} ~ ${dayjs(v[2]).format('MM-DD')}`; - }, - }, - grid: { left: 80, right: 30, top: 20, bottom: 30 }, - xAxis: { type: 'time', min: pStart, max: pEnd }, - yAxis: { type: 'category', data: rooms, inverse: true }, - series: [ - { - type: 'custom', - renderItem: (_params: any, api: any) => { - const catIdx = api.value(0); - const start = api.coord([api.value(1), catIdx]); - const end = api.coord([api.value(2), catIdx]); - const height = api.size([0, 1])[1] * 0.6; - return { - type: 'rect', - shape: { x: start[0], y: start[1] - height / 2, width: end[0] - start[0], height }, - style: { ...api.style(), fill: api.visual('color'), stroke: '#fff', lineWidth: 1 }, - }; - }, - encode: { x: [1, 2], y: 0 }, - data, - }, - ], - }; - }; // 费用饼图 const pieOption = { @@ -298,17 +245,6 @@ const DashboardPage: React.FC = () => { - - {ganttData.length > 0 ? ( - - ) : ( -
暂无入住数据
- )} -
- diff --git a/apps/admin/src/pages/Deposits/index.tsx b/apps/admin/src/pages/Deposits/index.tsx index 92989e7..59735ff 100644 --- a/apps/admin/src/pages/Deposits/index.tsx +++ b/apps/admin/src/pages/Deposits/index.tsx @@ -256,22 +256,25 @@ const DepositsPage: React.FC = () => { )} - - { - try { - await api.delete(`/deposits/${record.id}`); - message.success('删除成功'); - fetchData(); - } catch (e: any) { - message.error(e?.message || '删除失败'); - } - }} - > - - - + 批量删除 + + { - - + } disabled={selectedPersonalKeys.length === 0} > - - - + 批量删除 + + { ) : ( 已退宿 - - { - try { - await api.delete(`/occupancies/${record.id}`); - message.success('删除成功'); - fetchData(); - } catch (e: any) { - message.error(e?.message || '删除失败'); - } - }} - > - - - + 批量删除 + + )} - - + handleDelete(record.id)}> + }> + 删除 + + )} ), diff --git a/apps/admin/src/pages/Students/index.tsx b/apps/admin/src/pages/Students/index.tsx index a0de7de..f7fb748 100644 --- a/apps/admin/src/pages/Students/index.tsx +++ b/apps/admin/src/pages/Students/index.tsx @@ -187,18 +187,16 @@ const StudentsPage: React.FC = () => { render: (_: any, record: any) => ( {record.status === 'archived' ? ( - - handleRestore(record.id)} - okText="恢复" - cancelText="取消" - > - - - + handleRestore(record.id)} + okText="恢复" + cancelText="取消" + > + } type="link"> + 恢复 + + ) : ( <> { > 编辑 - - handleArchive(record.id)} - okText="归档" - cancelText="取消" - > - - - + handleArchive(record.id)} + okText="归档" + cancelText="取消" + > + }> + 归档 + + )} @@ -251,19 +247,22 @@ const StudentsPage: React.FC = () => { - - + } disabled={selectedRowKeys.length === 0} > - - - + 批量归档 + + { > 编辑 - - handleArchive(record.id)} - okText="归档" - cancelText="取消" - > - - - + handleArchive(record.id)} + okText="归档" + cancelText="取消" + > + }> + 归档 + + ), }, diff --git a/apps/admin/src/pages/Users/index.tsx b/apps/admin/src/pages/Users/index.tsx index 8476da4..4509436 100644 --- a/apps/admin/src/pages/Users/index.tsx +++ b/apps/admin/src/pages/Users/index.tsx @@ -180,13 +180,11 @@ const UsersPage: React.FC = () => { 重置密码 {record.username !== 'admin' && ( - - handleDelete(record.id)}> - - - + handleDelete(record.id)}> + }> + 删除 + + )} ),