fix(admin): UX improvements — silent fetch failures, empty states, batch loading guards, dashboard refresh

- Replace console.error-only catches with message.error user-facing notifications
  across Bills, Classes, ClassroomRentals, ClassroomSchedule, Classrooms, Deposits,
  Expenses, OperationLogs, Permissions, Roles, RoomVisual, Rooms, Students,
  Tenants, Users
- Add Empty component via Table locale prop on list pages: Bills, Classes,
  ClassroomRentals, Classrooms, Deposits, Expenses (room+personal), Occupancies,
  Rooms, Students, Tenants, Roles
- Add batchLoading state to batch delete/update operations: Bills (batchDelete,
  batchUpdateStatus), Expenses (batchDeleteRoom, batchDeletePersonal),
  Occupancies (batchCheckOut, batchDelete), Rooms (batchDelete),
  Students (batchDelete)
- Add refreshLoading indicator to Dashboard header when re-fetching data
- Consistent error pattern: catch (e: unknown) { const err = e as { message?: string }; message.error(...); }
This commit is contained in:
2026-07-09 18:03:42 +08:00
parent 6029d8e2fd
commit c59fd6ce92
17 changed files with 141 additions and 59 deletions

View File

@@ -14,8 +14,8 @@ import {
Popconfirm,
Upload,
Switch,
Alert,
Tooltip,
Empty,
} from 'antd';
import {
PlusOutlined,
@@ -50,6 +50,7 @@ const OccupanciesPage: React.FC = () => {
const [batchCheckOutModal, setBatchCheckOutModal] = useState(false);
const [selectedRowKeys, setSelectedRowKeys] = useState<number[]>([]);
const [saving, setSaving] = useState(false);
const [batchLoading, setBatchLoading] = useState(false);
const [checkInForm] = Form.useForm();
const [checkOutForm] = Form.useForm();
const [transferForm] = Form.useForm();
@@ -187,6 +188,7 @@ const OccupanciesPage: React.FC = () => {
const handleBatchCheckOut = async () => {
const values = await batchCheckOutForm.validateFields();
setBatchLoading(true);
try {
const res: any = await api.post('/occupancies/batch-check-out', {
ids: selectedRowKeys,
@@ -201,10 +203,13 @@ const OccupanciesPage: React.FC = () => {
fetchData();
} catch (e: any) {
message.error(e?.message || '批量退宿失败');
} finally {
setBatchLoading(false);
}
};
const handleBatchDelete = async () => {
setBatchLoading(true);
try {
const res: any = await api.post('/occupancies/batch-delete', { ids: selectedRowKeys });
message.success(res?.message || `已删除 ${selectedRowKeys.length}`);
@@ -212,6 +217,8 @@ const OccupanciesPage: React.FC = () => {
fetchData();
} catch (e: any) {
message.error(e?.message || '批量删除失败');
} finally {
setBatchLoading(false);
}
};
@@ -447,6 +454,7 @@ const OccupanciesPage: React.FC = () => {
setBatchCheckOutModal(true);
}}
style={{ marginLeft: 12 }}
loading={batchLoading}
>
退宿
</PermissionButton>
@@ -463,6 +471,7 @@ const OccupanciesPage: React.FC = () => {
size="small"
icon={<DeleteOutlined />}
style={{ marginLeft: 12 }}
loading={batchLoading}
>
</PermissionButton>
@@ -482,12 +491,11 @@ const OccupanciesPage: React.FC = () => {
dataSource={filteredData}
rowKey="id"
loading={loading}
locale={{ emptyText: <Empty description="暂无数据" /> }}
scroll={{ x: 1300 }}
pagination={{ pageSize: 15, showTotal: (total) => `${total}` }}
rowSelection={rowSelection}
/>
{/* 入住登记弹窗 */}
<Modal
title="入住登记"
open={checkInModal}