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 = { const updated: LedgerEntry = {
...existing, ...existing,
...entry, ...entry,
ledgerIds: [...new Set(entry.ledgerIds)],
updatedAt: new Date().toISOString(), updatedAt: new Date().toISOString(),
updatedBy: auth.user?.id ?? existing.updatedBy, updatedBy: auth.user?.id ?? existing.updatedBy,
version: existing.version + 1, version: existing.version + 1,

View File

@ -163,21 +163,27 @@ async function saveEntry() {
saving.value = true; saving.value = true;
errorMessage.value = ""; errorMessage.value = "";
const cents = Math.round(numericAmount * 100); try {
const exchangeRate = Number(entry.value.exchangeRate) || 1; const cents = Math.round(numericAmount * 100);
const updated = await store.updateEntry({ const exchangeRate = Number(entry.value.exchangeRate) || 1;
...entry.value, const updated = await store.updateEntry({
amount: cents, ...entry.value,
baseAmount: Math.round(cents * exchangeRate), amount: cents,
ledgerIds: ledgerIds.value, baseAmount: Math.round(cents * exchangeRate),
categoryId: childCategoryId.value || parentCategoryId.value, ledgerIds: [...ledgerIds.value],
note: note.value.trim(), categoryId: childCategoryId.value || parentCategoryId.value,
occurredAt: occurredDate.toISOString(), note: note.value.trim(),
}); occurredAt: occurredDate.toISOString(),
hydrate(updated); });
saving.value = false; hydrate(updated);
savedToast.value = true; savedToast.value = true;
window.setTimeout(() => (savedToast.value = false), 1600); 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() { async function deleteEntry() {