fix : 페이지네이션 row 설정 에러 발생

This commit is contained in:
Yesol Choi
2025-05-28 11:03:14 +09:00
parent 7f8638d0fb
commit bd63114c80

View File

@@ -12,14 +12,17 @@ onBeforeMount(async () => {
const masks = ref({ const masks = ref({
modelValue: 'YYYY-MM-DD', modelValue: 'YYYY-MM-DD',
}) })
const totalItems = ref(0) // 전체 아이템 수
const currentPage = ref(0) // 현재 페이지
const itemsPerPage = 8
const searchParamsList = reactive({ const searchParamsList = reactive({
cateCd : '', //분야코드 cateCd : '', //분야코드
stCd : '', //등록상태 stCd : '', //등록상태
regNm : '', //담당자 regNm : '', //담당자
regSdt: '',//등록시작일 regSdt: '',//등록시작일
regEdt: '',//등록종료일 regEdt: '',//등록종료일
page: 1,//페이지
row: 5 //아이템갯수
}) })
const params = reactive({ const params = reactive({
sessionUser:'', sessionUser:'',
@@ -40,20 +43,27 @@ async function getPriceListData(){
before30.setDate(today.getDate() - 30) before30.setDate(today.getDate() - 30)
const after30 = new Date() const after30 = new Date()
after30.setDate(today.getDate() + 30) after30.setDate(today.getDate())
const priceBase = { const priceBase = {
params:{ params:{
regSdt: formatDatefromObject(before30), regSdt: formatDatefromObject(before30),
regEdt: formatDatefromObject(after30), regEdt: formatDatefromObject(after30),
page: searchParamsList.page, page: Number.parseInt(route.query.page as string) || 1,
row: searchParamsList.row row: 10
} }
} }
const result = await getPriceList(priceBase) const result = await getPriceList(priceBase)
params.priceData = result.content params.priceData = result.content
//페이지 관련 값 설정
currentPage.value = result.pageable.pageNumber + 1
totalItems.value = result.totalElements
console.log("currentPage.value",currentPage.value)
console.log("totalItems.value",totalItems.value)
} }
const route = useRoute()
const searchPrice = async () => { const searchPrice = async () => {
const searchParams = { const searchParams = {
params: { params: {
cateCd : searchParamsList.cateCd, //분야코드 cateCd : searchParamsList.cateCd, //분야코드
@@ -61,12 +71,20 @@ const searchPrice = async () => {
regNm : searchParamsList.regNm, //담당자 regNm : searchParamsList.regNm, //담당자
regSdt: formatDatefromString(searchParamsList.regSdt),//등록시작일 regSdt: formatDatefromString(searchParamsList.regSdt),//등록시작일
regEdt: formatDatefromString(searchParamsList.regEdt),//등록종료일 regEdt: formatDatefromString(searchParamsList.regEdt),//등록종료일
page: 1,//페이지 page: Number.parseInt(route.query.page as string) || 1,//페이지
row: 3 //아이템갯수 row: 10 //아이템갯수
} }
} }
console.log("searchParams", Number.parseInt(route.query.page as string))
const result = await getPriceList(searchParams) const result = await getPriceList(searchParams)
params.priceData = result.content params.priceData = result.content
currentPage.value = null
totalItems.value = null
//페이지 관련 값 설정
currentPage.value = result.pageable.pageNumber + 1
totalItems.value = result.totalElements
console.log("currentPage.value",currentPage.value)
console.log("totalItems.value",totalItems.value)
} }
function getPriceDetail(){ function getPriceDetail(){
@@ -77,6 +95,10 @@ function getPriceDetail(){
router.push({ path: '/app/priceDetail', state: { key: arguments[0].prcsNo }}) router.push({ path: '/app/priceDetail', state: { key: arguments[0].prcsNo }})
} }
} }
watch(() => route.query.page, (newPage) => {
searchPrice()
})
</script> </script>
<template> <template>
@@ -115,6 +137,7 @@ function getPriceDetail(){
v-model="searchParamsList.regNm" v-model="searchParamsList.regNm"
class="input custom-text-filter" class="input custom-text-filter"
placeholder="담당자" placeholder="담당자"
@keydown.enter="searchPrice"
> >
</VControl> </VControl>
</VField> </VField>
@@ -211,7 +234,14 @@ function getPriceDetail(){
등록 등록
</VButton> </VButton>
</VButtons> </VButtons>
<VFlexPagination
:item-per-page="itemsPerPage"
:total-items="totalItems"
:current-page="currentPage"
:max-links-displayed="5"
/>
</div> </div>
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">