fix: 修复账单删除功能并支持分析页面删除操作
Some checks failed
Deploy BillAI / Deploy to Production (push) Has been cancelled
Some checks failed
Deploy BillAI / Deploy to Production (push) Has been cancelled
- 将删除接口从 DELETE /api/bills/:id 改为 POST /api/bills/:id/delete 以兼容 SvelteKit 代理 - 分析页面组件 (TopExpenses/BillRecordsTable/DailyTrendChart) 支持删除并同步更新统计数据 - Review 接口改为直接查询 MongoDB 而非读取文件 - 软删除时记录 updated_at 时间戳 - 添加 .dockerignore 文件优化构建 - 完善 AGENTS.md 文档
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
pageSize?: number;
|
||||
categories?: string[];
|
||||
onUpdate?: (updated: UIBill, original: UIBill) => void;
|
||||
onDelete?: (deleted: UIBill) => void;
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -24,7 +25,8 @@
|
||||
showDescription = true,
|
||||
pageSize = 10,
|
||||
categories = [],
|
||||
onUpdate
|
||||
onUpdate,
|
||||
onDelete
|
||||
}: Props = $props();
|
||||
|
||||
// 排序状态
|
||||
@@ -112,6 +114,24 @@
|
||||
onUpdate?.(updated, original);
|
||||
}
|
||||
|
||||
function handleRecordDeleted(deleted: UIBill) {
|
||||
const idx = records.findIndex(r => r === deleted);
|
||||
const finalIdx = idx !== -1
|
||||
? idx
|
||||
: records.findIndex(r =>
|
||||
r.time === deleted.time &&
|
||||
r.merchant === deleted.merchant &&
|
||||
r.amount === deleted.amount
|
||||
);
|
||||
|
||||
if (finalIdx !== -1) {
|
||||
records.splice(finalIdx, 1);
|
||||
records = [...records];
|
||||
}
|
||||
|
||||
onDelete?.(deleted);
|
||||
}
|
||||
|
||||
// 重置分页(当记录变化时)
|
||||
$effect(() => {
|
||||
records;
|
||||
@@ -280,4 +300,6 @@
|
||||
viewDescription="查看这笔支出的详细信息"
|
||||
editDescription="修改这笔支出的信息"
|
||||
onUpdate={handleRecordUpdated}
|
||||
onDelete={handleRecordDeleted}
|
||||
allowDelete={true}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user