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[]),
|
||||
|
||||
Reference in New Issue
Block a user