Fix offline entry detail saving

This commit is contained in:
openclaw 2026-07-24 00:20:29 +08:00
parent 0150a29e88
commit c2bb2e63a2
2 changed files with 22 additions and 15 deletions

View File

@ -147,6 +147,7 @@ export const useEntryStore = defineStore("entries", {
const updated: LedgerEntry = {
...existing,
...entry,
ledgerIds: [...new Set(entry.ledgerIds)],
updatedAt: new Date().toISOString(),
updatedBy: auth.user?.id ?? existing.updatedBy,
version: existing.version + 1,

View File

@ -163,21 +163,27 @@ async function saveEntry() {
saving.value = true;
errorMessage.value = "";
try {
const cents = Math.round(numericAmount * 100);
const exchangeRate = Number(entry.value.exchangeRate) || 1;
const updated = await store.updateEntry({
...entry.value,
amount: cents,
baseAmount: Math.round(cents * exchangeRate),
ledgerIds: ledgerIds.value,
ledgerIds: [...ledgerIds.value],
categoryId: childCategoryId.value || parentCategoryId.value,
note: note.value.trim(),
occurredAt: occurredDate.toISOString(),
});
hydrate(updated);
saving.value = false;
savedToast.value = true;
window.setTimeout(() => (savedToast.value = false), 1600);
} catch (error) {
console.error("Failed to save entry locally", error);
errorMessage.value = "保存失败,请重试";
} finally {
saving.value = false;
}
}
async function deleteEntry() {