feat(entries): 내역 추가/수정 폼을 라우트(?entry) 바인딩 — 뒤로가기로 닫히는 페이지 전환
Deploy / deploy (push) Failing after 14m57s
Deploy / deploy (push) Failing after 14m57s
- openForm/closeForm: 폼 열 때 히스토리에 ?entry 추가, 닫을 때 뒤로가기로 URL 정리 - 뒤로가기(브라우저·앱 뒤로)로 폼 닫힘 → 페이지 전환처럼 동작 - AI 빠른입력·OCR·상환 로직은 목록에 그대로 두어 회귀 위험 없음 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script setup>
|
||||
import { computed, nextTick, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { accountApi } from '@/api/accountApi'
|
||||
import { reminders } from '@/native/reminders'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
@@ -85,8 +86,22 @@ function resetFilters() {
|
||||
load()
|
||||
}
|
||||
|
||||
// 추가/수정 모달
|
||||
// 추가/수정 폼 — 라우트(?entry) 바인딩으로 뒤로가기 시 닫힘(페이지 전환처럼 동작)
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const formOpen = ref(false)
|
||||
// 폼 열기: 상태 표시 + 히스토리에 ?entry 추가(브라우저 뒤로가기로 닫기)
|
||||
function openForm() {
|
||||
formOpen.value = true
|
||||
if (route.query.entry == null) router.push({ query: { ...route.query, entry: '1' } })
|
||||
}
|
||||
// 폼 닫기: 상태 내림 + URL 정리(뒤로가기)
|
||||
function closeForm() {
|
||||
formOpen.value = false
|
||||
if (route.query.entry != null) router.back()
|
||||
}
|
||||
// 브라우저 뒤로가기 등으로 ?entry 가 사라지면 폼 닫기
|
||||
watch(() => route.query.entry, (v) => { if (v == null) formOpen.value = false })
|
||||
const editId = ref(null)
|
||||
const form = reactive({ entryDate: '', type: 'EXPENSE', category: '', amount: null, memo: '', walletKind: '', walletId: '', toWalletKind: '', toWalletId: '', principal: null, interest: null, annualFee: null, installmentMonths: '', currency: 'KRW', foreignAmount: null, rate: null })
|
||||
// 분류 선택 바텀시트 — 최종 분류가 정해지면 자동 닫힘
|
||||
@@ -601,7 +616,7 @@ function openCreate() {
|
||||
selectedTagIds.value = []
|
||||
formError.value = null
|
||||
formInfo.value = ''
|
||||
formOpen.value = true
|
||||
openForm()
|
||||
tryClipboardOnOpen() // 문자/푸시 클립보드 자동 감지(있으면 배너)
|
||||
}
|
||||
// 내역 화면에서 바로 빠른입력: 추가 폼을 준비해 열고, 그 위에 빠른입력 모달을 띄운다.
|
||||
@@ -644,7 +659,7 @@ function openEdit(e) {
|
||||
pasteText.value = ''
|
||||
formError.value = null
|
||||
formInfo.value = ''
|
||||
formOpen.value = true
|
||||
openForm()
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
@@ -686,7 +701,7 @@ async function submit() {
|
||||
if (editId.value) {
|
||||
await accountApi.remove(editId.value)
|
||||
}
|
||||
formOpen.value = false
|
||||
closeForm()
|
||||
await load()
|
||||
} catch (e) {
|
||||
formError.value = e.response?.data?.message || '저장에 실패했습니다.'
|
||||
@@ -736,7 +751,7 @@ async function submit() {
|
||||
} else {
|
||||
await accountApi.create(payload)
|
||||
}
|
||||
formOpen.value = false
|
||||
closeForm()
|
||||
// 오늘 거래를 기록했으면 오늘자 가계부 리마인더 취소
|
||||
if (reminders.isNative() && payload.entryDate === todayStr()) reminders.clearTodayReminder()
|
||||
await load()
|
||||
@@ -811,7 +826,7 @@ async function doRegisterRecurring() {
|
||||
try {
|
||||
await accountApi.createRecurring(recurConfirm.payload)
|
||||
recurConfirm.open = false
|
||||
formOpen.value = false
|
||||
closeForm()
|
||||
flash('정기결제로 등록했습니다. 정기결제 화면에서 주기를 변경할 수 있어요.')
|
||||
} catch (e) {
|
||||
formError.value = e.response?.data?.message || '정기결제 등록에 실패했습니다.'
|
||||
@@ -945,7 +960,7 @@ function applyParsed(p) {
|
||||
pasteModalOpen.value = false
|
||||
pasteText.value = ''
|
||||
pasteError.value = ''
|
||||
formOpen.value = true // 내역 화면에서 바로 빠른입력한 경우에도 채워진 추가 폼이 보이도록 보장
|
||||
openForm() // 내역 화면에서 바로 빠른입력한 경우에도 채워진 추가 폼이 보이도록 보장
|
||||
}
|
||||
async function parseAndApply(text, { silent } = {}) {
|
||||
const t = (text || '').trim()
|
||||
@@ -1156,7 +1171,7 @@ onMounted(async () => {
|
||||
<Transition name="slide-up">
|
||||
<div v-if="formOpen" class="modal-backdrop entry-backdrop">
|
||||
<div class="modal entry-modal" role="dialog" aria-modal="true">
|
||||
<button class="close" type="button" @click="formOpen = false">×</button>
|
||||
<button class="close" type="button" @click="closeForm()">×</button>
|
||||
<h2>{{ editId ? '내역 수정' : '내역 추가' }}</h2>
|
||||
|
||||
<form class="entry-form" @submit.prevent="submit">
|
||||
@@ -1372,7 +1387,7 @@ onMounted(async () => {
|
||||
>⭐ 자주 쓰는 내역으로 저장</button>
|
||||
|
||||
<div class="buttons">
|
||||
<IconBtn icon="close" title="취소" @click="formOpen = false" />
|
||||
<IconBtn icon="close" title="취소" @click="closeForm()" />
|
||||
<IconBtn icon="save" :title="editId ? '수정' : '등록'" variant="primary" type="submit" :disabled="submitting" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user