- BottomSheet.vue: 아래에서 올라오는 콘텐츠 높이 시트(재사용) - SheetSelect.vue: 필드형 트리거 → 바텀시트 단일 선택(계좌/카드) - 정기결제 폼: 계좌는 SheetSelect, 분류는 트리거 → 시트 안 CategoryPicker (선택 전에는 목록 미노출, 선택 시 값 채움) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,93 @@
|
|||||||
|
<script setup>
|
||||||
|
// 아래에서 올라오는 바텀시트(콘텐츠 높이). 선택 항목(계좌·분류 등)에 사용.
|
||||||
|
defineProps({
|
||||||
|
modelValue: { type: Boolean, required: true },
|
||||||
|
title: { type: String, default: '' },
|
||||||
|
})
|
||||||
|
defineEmits(['update:modelValue'])
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Teleport to="body">
|
||||||
|
<Transition name="bs">
|
||||||
|
<div v-if="modelValue" class="bs-wrap" @click.self="$emit('update:modelValue', false)">
|
||||||
|
<div class="bs-panel" role="dialog" aria-modal="true">
|
||||||
|
<div class="bs-grip" @click="$emit('update:modelValue', false)"></div>
|
||||||
|
<div class="bs-head">
|
||||||
|
<span class="bs-title">{{ title }}</span>
|
||||||
|
<button type="button" class="bs-close" aria-label="닫기" @click="$emit('update:modelValue', false)">×</button>
|
||||||
|
</div>
|
||||||
|
<div class="bs-body"><slot /></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Transition>
|
||||||
|
</Teleport>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.bs-wrap {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 1100;
|
||||||
|
background: rgba(0, 0, 0, 0.4);
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
.bs-panel {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 560px;
|
||||||
|
margin: 0 auto;
|
||||||
|
background: var(--color-background);
|
||||||
|
border-radius: 16px 16px 0 0;
|
||||||
|
max-height: 85vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 0.4rem 1.1rem calc(1rem + env(safe-area-inset-bottom, 0));
|
||||||
|
box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.25);
|
||||||
|
}
|
||||||
|
.bs-grip {
|
||||||
|
width: 40px;
|
||||||
|
height: 4px;
|
||||||
|
border-radius: 2px;
|
||||||
|
background: var(--color-border);
|
||||||
|
margin: 0.4rem auto 0.2rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.bs-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0.3rem 0 0.6rem;
|
||||||
|
}
|
||||||
|
.bs-title {
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
.bs-close {
|
||||||
|
border: 0;
|
||||||
|
background: transparent;
|
||||||
|
font-size: 1.4rem;
|
||||||
|
line-height: 1;
|
||||||
|
color: var(--color-text);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.bs-enter-active {
|
||||||
|
transition: background 0.2s ease;
|
||||||
|
}
|
||||||
|
.bs-leave-active {
|
||||||
|
transition: background 0.18s ease;
|
||||||
|
}
|
||||||
|
.bs-enter-from,
|
||||||
|
.bs-leave-to {
|
||||||
|
background: rgba(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
.bs-enter-active .bs-panel {
|
||||||
|
transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
|
||||||
|
}
|
||||||
|
.bs-leave-active .bs-panel {
|
||||||
|
transition: transform 0.2s cubic-bezier(0.4, 0, 1, 1);
|
||||||
|
}
|
||||||
|
.bs-enter-from .bs-panel,
|
||||||
|
.bs-leave-to .bs-panel {
|
||||||
|
transform: translateY(100%);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
<script setup>
|
||||||
|
// 필드형 트리거를 누르면 바텀시트로 옵션을 보여주고 단일 선택. (계좌·카드 선택 등)
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
|
import BottomSheet from './BottomSheet.vue'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: { type: [String, Number], default: '' },
|
||||||
|
options: { type: Array, default: () => [] }, // [{ value, label }]
|
||||||
|
placeholder: { type: String, default: '선택하세요' },
|
||||||
|
title: { type: String, default: '선택' },
|
||||||
|
disabled: { type: Boolean, default: false },
|
||||||
|
emptyText: { type: String, default: '선택할 항목이 없습니다' },
|
||||||
|
})
|
||||||
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
|
||||||
|
const open = ref(false)
|
||||||
|
const selected = computed(() => props.options.find((o) => o.value === props.modelValue) || null)
|
||||||
|
function pick(o) {
|
||||||
|
emit('update:modelValue', o.value)
|
||||||
|
open.value = false
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<button
|
||||||
|
type="button" class="ss-trigger" :class="{ empty: !selected }"
|
||||||
|
:disabled="disabled" @click="open = true"
|
||||||
|
>
|
||||||
|
<span class="ss-label">{{ selected ? selected.label : placeholder }}</span>
|
||||||
|
<span class="ss-caret">▾</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<BottomSheet v-model="open" :title="title">
|
||||||
|
<ul v-if="options.length" class="ss-list">
|
||||||
|
<li v-for="o in options" :key="o.value">
|
||||||
|
<button
|
||||||
|
type="button" class="ss-opt" :class="{ active: o.value === modelValue }"
|
||||||
|
@click="pick(o)"
|
||||||
|
>
|
||||||
|
<span>{{ o.label }}</span>
|
||||||
|
<span v-if="o.value === modelValue" class="ss-check">✓</span>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p v-else class="ss-empty">{{ emptyText }}</p>
|
||||||
|
</BottomSheet>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.ss-trigger {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.5rem;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.55rem 0.75rem;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: 6px;
|
||||||
|
background: var(--color-background-soft);
|
||||||
|
color: var(--color-text);
|
||||||
|
font-size: 0.9rem;
|
||||||
|
cursor: pointer;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.ss-trigger:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
.ss-trigger.empty .ss-label {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
.ss-label {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.ss-caret {
|
||||||
|
opacity: 0.5;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.ss-list {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.ss-opt {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.85rem 0.4rem;
|
||||||
|
border: 0;
|
||||||
|
border-bottom: 1px solid var(--color-border);
|
||||||
|
background: transparent;
|
||||||
|
color: var(--color-text);
|
||||||
|
font-size: 0.95rem;
|
||||||
|
cursor: pointer;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.ss-opt.active {
|
||||||
|
color: hsla(160, 100%, 37%, 1);
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
.ss-check {
|
||||||
|
color: hsla(160, 100%, 37%, 1);
|
||||||
|
}
|
||||||
|
.ss-empty {
|
||||||
|
padding: 1.2rem 0.4rem;
|
||||||
|
opacity: 0.6;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onMounted, reactive, ref } from 'vue'
|
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { accountApi } from '@/api/accountApi'
|
import { accountApi } from '@/api/accountApi'
|
||||||
import IconBtn from '@/components/ui/IconBtn.vue'
|
import IconBtn from '@/components/ui/IconBtn.vue'
|
||||||
import CategoryPicker from '@/components/ui/CategoryPicker.vue'
|
import CategoryPicker from '@/components/ui/CategoryPicker.vue'
|
||||||
import ChipSelect from '@/components/ui/ChipSelect.vue'
|
import SheetSelect from '@/components/ui/SheetSelect.vue'
|
||||||
|
import BottomSheet from '@/components/ui/BottomSheet.vue'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -16,6 +17,7 @@ const categories = ref([])
|
|||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const submitting = ref(false)
|
const submitting = ref(false)
|
||||||
const formError = ref(null)
|
const formError = ref(null)
|
||||||
|
const catSheet = ref(false)
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
title: '',
|
title: '',
|
||||||
@@ -35,6 +37,8 @@ const form = reactive({
|
|||||||
endDate: '',
|
endDate: '',
|
||||||
active: true,
|
active: true,
|
||||||
})
|
})
|
||||||
|
// 분류가 최종 선택(비어있지 않은 값)되면 시트 닫기
|
||||||
|
watch(() => form.category, (v) => { if (v) catSheet.value = false })
|
||||||
|
|
||||||
const TYPES = [
|
const TYPES = [
|
||||||
{ value: 'EXPENSE', label: '지출', cls: 'chip-expense' },
|
{ value: 'EXPENSE', label: '지출', cls: 'chip-expense' },
|
||||||
@@ -227,11 +231,12 @@ async function submit() {
|
|||||||
@click="form.walletKind = k.value; onWalletKindChange()"
|
@click="form.walletKind = k.value; onWalletKindChange()"
|
||||||
>{{ k.label }}</button>
|
>{{ k.label }}</button>
|
||||||
</div>
|
</div>
|
||||||
<ChipSelect
|
<SheetSelect
|
||||||
v-if="form.walletKind"
|
v-if="form.walletKind"
|
||||||
v-model="form.walletId"
|
v-model="form.walletId"
|
||||||
:options="fromWalletOptions"
|
:options="fromWalletOptions"
|
||||||
:disabled="submitting"
|
:disabled="submitting"
|
||||||
|
title="계좌 선택" placeholder="계좌를 선택하세요"
|
||||||
empty-text="등록된 계좌가 없습니다"
|
empty-text="등록된 계좌가 없습니다"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -247,18 +252,28 @@ async function submit() {
|
|||||||
@click="form.toWalletKind = k.value; onToWalletKindChange()"
|
@click="form.toWalletKind = k.value; onToWalletKindChange()"
|
||||||
>{{ k.label }}</button>
|
>{{ k.label }}</button>
|
||||||
</div>
|
</div>
|
||||||
<ChipSelect
|
<SheetSelect
|
||||||
v-if="form.toWalletKind"
|
v-if="form.toWalletKind"
|
||||||
v-model="form.toWalletId"
|
v-model="form.toWalletId"
|
||||||
:options="toWalletOptions"
|
:options="toWalletOptions"
|
||||||
:disabled="submitting"
|
:disabled="submitting"
|
||||||
|
title="입금 계좌 선택" placeholder="계좌를 선택하세요"
|
||||||
empty-text="등록된 계좌가 없습니다"
|
empty-text="등록된 계좌가 없습니다"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 분류 — CategoryPicker (이체 제외) -->
|
<!-- 분류 — 트리거 → 바텀시트(CategoryPicker) (이체 제외) -->
|
||||||
<div v-if="form.type !== 'TRANSFER'" class="field">
|
<div v-if="form.type !== 'TRANSFER'" class="field">
|
||||||
<span class="field-label">분류</span>
|
<span class="field-label">분류</span>
|
||||||
|
<button
|
||||||
|
type="button" class="sheet-trigger" :class="{ empty: !form.category }"
|
||||||
|
:disabled="submitting" @click="catSheet = true"
|
||||||
|
>
|
||||||
|
<span class="st-label">{{ form.category || '분류를 선택하세요' }}</span>
|
||||||
|
<span class="st-caret">▾</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<BottomSheet v-model="catSheet" title="분류 선택">
|
||||||
<CategoryPicker
|
<CategoryPicker
|
||||||
v-model="form.category"
|
v-model="form.category"
|
||||||
:type="form.type"
|
:type="form.type"
|
||||||
@@ -266,7 +281,7 @@ async function submit() {
|
|||||||
:disabled="submitting"
|
:disabled="submitting"
|
||||||
@category-added="loadCategories()"
|
@category-added="loadCategories()"
|
||||||
/>
|
/>
|
||||||
</div>
|
</BottomSheet>
|
||||||
|
|
||||||
<label>메모<input v-model="form.memo" type="text" placeholder="(선택)" :disabled="submitting" /></label>
|
<label>메모<input v-model="form.memo" type="text" placeholder="(선택)" :disabled="submitting" /></label>
|
||||||
|
|
||||||
@@ -405,4 +420,37 @@ async function submit() {
|
|||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
}
|
}
|
||||||
|
/* 분류 시트 트리거(필드형) */
|
||||||
|
.sheet-trigger {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.5rem;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.55rem 0.75rem;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: 6px;
|
||||||
|
background: var(--color-background-soft);
|
||||||
|
color: var(--color-text);
|
||||||
|
font-size: 0.9rem;
|
||||||
|
cursor: pointer;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.sheet-trigger:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
.sheet-trigger.empty .st-label {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
.st-label {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.st-caret {
|
||||||
|
opacity: 0.5;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user