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:
2026-07-09 19:57:10 +08:00
parent 8f28c172c4
commit 97c2ceccde
3 changed files with 14 additions and 14 deletions

View File

@@ -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[]),