fix: 周期账单弹窗 — Numpad 移到 scroll-view 外 + 防重复提交 + @confirm 绑定
This commit is contained in:
@@ -135,9 +135,11 @@
|
|||||||
</picker>
|
</picker>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 数字键盘(内嵌模式,不固定在底部) -->
|
|
||||||
<Numpad v-model="amountStr" :fixed="false" />
|
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
|
<!-- 数字键盘:在滚动区外,始终可见,避免 scroll-view 吞事件 -->
|
||||||
|
<Numpad v-model="amountStr" :fixed="false" @confirm="handleSubmit" />
|
||||||
|
|
||||||
<view class="modal-footer" @tap="handleSubmit">
|
<view class="modal-footer" @tap="handleSubmit">
|
||||||
<text class="submit-text">{{ editingId ? '保存修改' : '添加' }}</text>
|
<text class="submit-text">{{ editingId ? '保存修改' : '添加' }}</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -167,6 +169,7 @@ const loading = ref(true)
|
|||||||
const showModal = ref(false)
|
const showModal = ref(false)
|
||||||
const editingId = ref<number | null>(null)
|
const editingId = ref<number | null>(null)
|
||||||
const amountStr = ref('')
|
const amountStr = ref('')
|
||||||
|
const saving = ref(false)
|
||||||
const syncCount = ref(0)
|
const syncCount = ref(0)
|
||||||
|
|
||||||
const freqMap: Record<string, string> = {
|
const freqMap: Record<string, string> = {
|
||||||
@@ -254,6 +257,7 @@ async function toggleActive(item: RecurringTemplate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
|
if (saving.value) return
|
||||||
const amount = Math.round(parseFloat(amountStr.value || '0') * 100)
|
const amount = Math.round(parseFloat(amountStr.value || '0') * 100)
|
||||||
if (isNaN(amount) || amount <= 0) {
|
if (isNaN(amount) || amount <= 0) {
|
||||||
uni.showToast({ title: '请输入金额', icon: 'none' })
|
uni.showToast({ title: '请输入金额', icon: 'none' })
|
||||||
@@ -264,6 +268,7 @@ async function handleSubmit() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saving.value = true
|
||||||
try {
|
try {
|
||||||
const data = {
|
const data = {
|
||||||
amount,
|
amount,
|
||||||
@@ -284,6 +289,8 @@ async function handleSubmit() {
|
|||||||
uni.showToast({ title: editingId.value ? '已更新' : '已添加', icon: 'success' })
|
uni.showToast({ title: editingId.value ? '已更新' : '已添加', icon: 'success' })
|
||||||
} catch {
|
} catch {
|
||||||
uni.showToast({ title: '保存失败', icon: 'none' })
|
uni.showToast({ title: '保存失败', icon: 'none' })
|
||||||
|
} finally {
|
||||||
|
saving.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,7 +433,7 @@ function goBack() { uni.navigateBack() }
|
|||||||
&:active { background: darken($border, 5%); }
|
&:active { background: darken($border, 5%); }
|
||||||
}
|
}
|
||||||
.modal-close-text { font-size: $font-2xl; color: $text-sec; line-height: 1; }
|
.modal-close-text { font-size: $font-2xl; color: $text-sec; line-height: 1; }
|
||||||
.modal-body { flex: 1; padding: $space-md $space-xl; max-height: 60vh; }
|
.modal-body { flex: 1; padding: $space-md $space-xl; max-height: 45vh; }
|
||||||
.modal-footer {
|
.modal-footer {
|
||||||
padding: $space-md $space-xl; border-top: 2rpx solid $border;
|
padding: $space-md $space-xl; border-top: 2rpx solid $border;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user