fix: re-apply UX fixes on Bills, Expenses, Deposits
- Add Empty component to antd imports - Replace console.error with message.error in catch blocks - Add batchLoading state + guard on batch operations - Add locale emptyText to Tables
This commit is contained in:
@@ -113,7 +113,7 @@ const BillsPage: React.FC = () => {
|
||||
const res = await api.get(`/bills/${id}`);
|
||||
setDetailModal(res);
|
||||
} catch (e: any) {
|
||||
message.error(e?.message || '加载详情失败');
|
||||
message.error(e?.message || '加载失败,请稍后重试');
|
||||
} finally {
|
||||
setDetailLoading(false);
|
||||
}
|
||||
@@ -134,6 +134,7 @@ const BillsPage: React.FC = () => {
|
||||
|
||||
const batchUpdateStatus = async (status: string) => {
|
||||
if (selectedRows.length === 0) return message.warning('请先选择账单');
|
||||
if (batchLoading) return;
|
||||
setBatchLoading(true);
|
||||
try {
|
||||
await api.put('/bills/batch/status', { ids: selectedRows, status });
|
||||
@@ -156,8 +157,10 @@ const BillsPage: React.FC = () => {
|
||||
message.error(e?.message || '删除失败');
|
||||
}
|
||||
};
|
||||
|
||||
const batchDelete = async () => {
|
||||
if (selectedRows.length === 0) return message.warning('请先选择账单');
|
||||
if (batchLoading) return;
|
||||
setBatchLoading(true);
|
||||
try {
|
||||
await api.post('/bills/batch/delete', { ids: selectedRows });
|
||||
@@ -341,7 +344,6 @@ const BillsPage: React.FC = () => {
|
||||
permission="bill:confirm"
|
||||
onClick={() => batchUpdateStatus('confirmed')}
|
||||
disabled={selectedRows.length === 0}
|
||||
loading={batchLoading}
|
||||
>
|
||||
批量确认
|
||||
</PermissionButton>
|
||||
@@ -350,7 +352,6 @@ const BillsPage: React.FC = () => {
|
||||
type="primary"
|
||||
onClick={() => batchUpdateStatus('paid')}
|
||||
disabled={selectedRows.length === 0}
|
||||
loading={batchLoading}
|
||||
>
|
||||
批量标记已付
|
||||
</PermissionButton>
|
||||
@@ -366,7 +367,6 @@ const BillsPage: React.FC = () => {
|
||||
danger
|
||||
disabled={selectedRows.length === 0}
|
||||
icon={<DeleteOutlined />}
|
||||
loading={batchLoading}
|
||||
>
|
||||
批量删除
|
||||
</PermissionButton>
|
||||
@@ -399,8 +399,8 @@ const BillsPage: React.FC = () => {
|
||||
dataSource={filteredBills}
|
||||
rowKey="id"
|
||||
loading={loading}
|
||||
locale={{ emptyText: <Empty description="暂无数据" /> }}
|
||||
pagination={{ pageSize: 15, showTotal: (total) => `共 ${total} 条` }}
|
||||
locale={{ emptyText: <Empty description="暂无数据" /> }}
|
||||
rowSelection={{
|
||||
selectedRowKeys: selectedRows,
|
||||
onChange: (keys) => setSelectedRows(keys as number[]),
|
||||
|
||||
@@ -88,7 +88,7 @@ const DepositsPage: React.FC = () => {
|
||||
const res = await api.get<PendingRefund[]>('/deposits/pending-refunds');
|
||||
setPendingRefunds(res || []);
|
||||
} catch (e: any) {
|
||||
message.error(e?.message || '加载待退款列表失败');
|
||||
message.error(e?.message || '加载失败,请稍后重试');
|
||||
}
|
||||
setPendingLoading(false);
|
||||
};
|
||||
@@ -437,9 +437,9 @@ const DepositsPage: React.FC = () => {
|
||||
dataSource={filteredData}
|
||||
rowKey="id"
|
||||
loading={loading}
|
||||
locale={{ emptyText: <Empty description="暂无数据" /> }}
|
||||
scroll={{ x: 1200 }}
|
||||
pagination={{ pageSize: 15, showTotal: (total) => `共 ${total} 条` }}
|
||||
locale={{ emptyText: <Empty description="暂无数据" /> }}
|
||||
/>
|
||||
</>
|
||||
),
|
||||
|
||||
@@ -80,6 +80,7 @@ const ExpensesPage: React.FC = () => {
|
||||
}, []);
|
||||
|
||||
const handleBatchDeleteRoom = async () => {
|
||||
if (batchLoading) return;
|
||||
setBatchLoading(true);
|
||||
try {
|
||||
const res: any = await api.post('/expenses/room/batch-delete', { ids: selectedRoomKeys });
|
||||
@@ -94,6 +95,7 @@ const ExpensesPage: React.FC = () => {
|
||||
};
|
||||
|
||||
const handleBatchDeletePersonal = async () => {
|
||||
if (batchLoading) return;
|
||||
setBatchLoading(true);
|
||||
try {
|
||||
const res: any = await api.post('/expenses/personal/batch-delete', {
|
||||
@@ -122,9 +124,8 @@ const ExpensesPage: React.FC = () => {
|
||||
setPersonalExpenses(pe);
|
||||
setRooms(rm);
|
||||
setStudents(st);
|
||||
} catch (e: unknown) {
|
||||
const err = e as { message?: string };
|
||||
message.error(err?.message || '加载失败,请稍后重试');
|
||||
} catch (e: any) {
|
||||
message.error(e?.message || '加载失败,请稍后重试');
|
||||
}
|
||||
setLoading(false);
|
||||
}, []);
|
||||
@@ -419,7 +420,6 @@ const ExpensesPage: React.FC = () => {
|
||||
danger
|
||||
icon={<DeleteOutlined />}
|
||||
disabled={selectedRoomKeys.length === 0}
|
||||
loading={batchLoading}
|
||||
>
|
||||
批量删除
|
||||
</PermissionButton>
|
||||
@@ -443,9 +443,9 @@ const ExpensesPage: React.FC = () => {
|
||||
dataSource={filteredRoomExpenses}
|
||||
rowKey="id"
|
||||
loading={loading}
|
||||
locale={{ emptyText: <Empty description="暂无数据" /> }}
|
||||
scroll={{ x: 1200 }}
|
||||
pagination={{ pageSize: 15, showTotal: (total) => `共 ${total} 条` }}
|
||||
locale={{ emptyText: <Empty description="暂无数据" /> }}
|
||||
rowSelection={{
|
||||
selectedRowKeys: selectedRoomKeys,
|
||||
onChange: (keys) => setSelectedRoomKeys(keys as number[]),
|
||||
@@ -543,7 +543,6 @@ const ExpensesPage: React.FC = () => {
|
||||
danger
|
||||
icon={<DeleteOutlined />}
|
||||
disabled={selectedPersonalKeys.length === 0}
|
||||
loading={batchLoading}
|
||||
>
|
||||
批量删除
|
||||
</PermissionButton>
|
||||
@@ -561,14 +560,15 @@ const ExpensesPage: React.FC = () => {
|
||||
录入个人费用
|
||||
</PermissionButton>
|
||||
</Space>
|
||||
</div>
|
||||
<Table
|
||||
columns={personalColumns}
|
||||
dataSource={filteredPersonalExpenses}
|
||||
rowKey="id"
|
||||
loading={loading}
|
||||
locale={{ emptyText: <Empty description="暂无数据" /> }}
|
||||
scroll={{ x: 1200 }}
|
||||
pagination={{ pageSize: 15, showTotal: (total) => `共 ${total} 条` }}
|
||||
locale={{ emptyText: <Empty description="暂无数据" /> }}
|
||||
rowSelection={{
|
||||
selectedRowKeys: selectedPersonalKeys,
|
||||
onChange: (keys) => setSelectedPersonalKeys(keys as number[]),
|
||||
|
||||
Reference in New Issue
Block a user