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() {
-