From f586f9e1170817b15ced6c7c528bb48290311d87 Mon Sep 17 00:00:00 2001 From: wangxiaogang <1433729587@qq.com> Date: Tue, 9 Jun 2026 16:54:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=91=E9=A2=9D=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E5=B0=8F=E6=95=B0=E4=BD=8D=E6=BA=A2=E5=87=BA=E6=8C=A4?= =?UTF-8?q?=E4=BD=8D=20+=20=E7=BC=96=E8=BE=91=E9=A1=B5=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=81=9A=E7=84=A6=20+=20=E5=91=A8=E6=9C=9F=E8=B4=A6=E5=8D=95?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=86=97=E4=BD=99=E8=81=9A=E7=84=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/AmountEditor/amount-edit.ts | 12 +++++++++++- client/src/pages/add/index.vue | 1 + client/src/pages/recurring/index.vue | 4 +--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/client/src/components/AmountEditor/amount-edit.ts b/client/src/components/AmountEditor/amount-edit.ts index 6e085d9..24ffda7 100644 --- a/client/src/components/AmountEditor/amount-edit.ts +++ b/client/src/components/AmountEditor/amount-edit.ts @@ -48,9 +48,19 @@ export function insertAmountKey( } const normalizedInsert = normalizeInsert(value, safeCursor, key) - const next = value.slice(0, safeCursor) + normalizedInsert + value.slice(safeCursor) + let next = value.slice(0, safeCursor) + normalizedInsert + value.slice(safeCursor) if (!isValidAmountInput(next, options)) { + // 小数位超出上限时,从右侧挤出一个字符(小数部分左移) + const dotIdx = next.indexOf('.') + if (dotIdx >= 0 && next.length - dotIdx - 1 > MAX_DECIMAL_PLACES) { + next = next.slice(0, -1) + const newCursor = Math.min(safeCursor + normalizedInsert.length, next.length) + if (!isValidAmountInput(next, options)) { + return { value, cursorIndex: safeCursor, accepted: false } + } + return { value: next, cursorIndex: newCursor, accepted: true } + } return { value, cursorIndex: safeCursor, accepted: false } } diff --git a/client/src/pages/add/index.vue b/client/src/pages/add/index.vue index 7c64974..2b5dd0f 100644 --- a/client/src/pages/add/index.vue +++ b/client/src/pages/add/index.vue @@ -195,6 +195,7 @@ onMounted(async () => { // 等待分类列表渲染完成后滚动到选中项 nextTick(() => { setTimeout(() => { scrollToCat.value = 'cat-' + existing.category_id }, 200) + amountEditorRef.value?.focus() }) } else { uni.showToast({ title: '记录不存在', icon: 'none' }) diff --git a/client/src/pages/recurring/index.vue b/client/src/pages/recurring/index.vue index 9c9e10b..9b66678 100644 --- a/client/src/pages/recurring/index.vue +++ b/client/src/pages/recurring/index.vue @@ -153,7 +153,7 @@