fix: 金额编辑器小数位溢出挤位 + 编辑页自动聚焦 + 周期账单移除冗余聚焦
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
|
||||
|
||||
@@ -195,6 +195,7 @@ onMounted(async () => {
|
||||
// 等待分类列表渲染完成后滚动到选中项
|
||||
nextTick(() => {
|
||||
setTimeout(() => { scrollToCat.value = 'cat-' + existing.category_id }, 200)
|
||||
amountEditorRef.value?.focus()
|
||||
})
|
||||
} else {
|
||||
uni.showToast({ title: '记录不存在', icon: 'none' })
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, nextTick } from 'vue'
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { waitForReady } from '@/utils/app-ready'
|
||||
import { statusBarHeight, capsuleRight } from '@/utils/system'
|
||||
import { formatAmount } from '@/utils/format'
|
||||
@@ -233,7 +233,6 @@ function openAddModal() {
|
||||
if (cats.length > 0) form.value.category_id = cats[0].id
|
||||
amountStr.value = ''
|
||||
showModal.value = true
|
||||
nextTick(() => amountEditorRef.value?.focus())
|
||||
}
|
||||
|
||||
function openEditModal(item: RecurringTemplate) {
|
||||
@@ -248,7 +247,6 @@ function openEditModal(item: RecurringTemplate) {
|
||||
}
|
||||
amountStr.value = (item.amount / 100).toString()
|
||||
showModal.value = true
|
||||
nextTick(() => amountEditorRef.value?.focus())
|
||||
}
|
||||
|
||||
async function toggleActive(item: RecurringTemplate) {
|
||||
|
||||
Reference in New Issue
Block a user