diff --git a/apps/web/src/components/QuickEntryDrawer.vue b/apps/web/src/components/QuickEntryDrawer.vue index 142ff43..d92234d 100644 --- a/apps/web/src/components/QuickEntryDrawer.vue +++ b/apps/web/src/components/QuickEntryDrawer.vue @@ -76,7 +76,9 @@ const selectedLedgerLabel = computed(() => { const names = visibleNames.slice(0, 3).join(","); return visibleNames.length > 1 ? `${names} 等 ${visibleNames.length} 个账本` : names; }); +const occurredAtValid = computed(() => Boolean(occurredAt.value) && !Number.isNaN(new Date(occurredAt.value).getTime())); const dateLabel = computed(() => { + if (!occurredAtValid.value) return "选择时间"; const date = new Date(occurredAt.value); const now = new Date(); const datePart = isSameDay(date, now) @@ -84,6 +86,10 @@ const dateLabel = computed(() => { : `${date.getMonth() + 1}月${date.getDate()}日`; return `${datePart} ${pad(date.getHours())}:${pad(date.getMinutes())}`; }); +const canSave = computed(() => { + const amount = Math.round(calculatedAmount.value * 100); + return Number.isFinite(amount) && amount > 0 && occurredAtValid.value; +}); const selectorOptions = computed<(EntryTypeOption | Category)[]>(() => { if (selectorLevel.value === "type") { const current = entryTypes.find((option) => option.id === entryType.value); @@ -345,7 +351,7 @@ function toggleLedger(ledgerId: string) { function saveEntry() { const amount = Math.round(calculatedAmount.value * 100); - if (!Number.isFinite(amount) || amount <= 0) return; + if (!canSave.value) return; emit("save", { type: entryType.value, @@ -377,7 +383,7 @@ function saveEntry() { - @@ -514,7 +520,7 @@ function saveEntry() { - diff --git a/apps/web/src/styles.css b/apps/web/src/styles.css index a0eb2bf..339c4be 100644 --- a/apps/web/src/styles.css +++ b/apps/web/src/styles.css @@ -761,6 +761,12 @@ input:focus-visible { white-space: nowrap; } +.header-date-button.invalid { + border-color: #e9a79c; + background: #fff2ef; + color: #c94635; +} + .native-date-input { position: absolute; right: 14px; @@ -910,6 +916,11 @@ input:focus-visible { color: #ffffff; } +.save-key:disabled { + background: #d8e1de; + color: #8a9894; +} + .category-focus-scrim { position: absolute; inset: 0;