feat: add pagination

This commit is contained in:
Methapon Metanipat 2024-10-01 09:48:03 +07:00
parent 32b51ff84b
commit fde6335706

View file

@ -225,10 +225,6 @@ const pageState = reactive({
quotationModal: false, quotationModal: false,
employeeModal: false, employeeModal: false,
productServiceModal: false, productServiceModal: false,
currentMaxPage: 1,
currentPage: 1,
pageSize: 30,
}); });
const statData = ref< const statData = ref<
@ -445,33 +441,32 @@ onMounted(async () => {
flowStore.rotate(); flowStore.rotate();
}); });
watch( async function fetchQuotationList() {
() => pageState.currentTab, const ret = await quotationStore.getQuotationList({
async () => { page: quotationPage.value,
const ret = await quotationStore.getQuotationList({ pageSize: quotationPageSize.value,
page: quotationPage.value, payCondition:
pageSize: quotationPageSize.value, pageState.currentTab !== 'all'
payCondition: ? (
pageState.currentTab !== 'all' {
? ( fullAmountCash: 'Full',
{ installmentsCash: 'Split',
fullAmountCash: 'Full', fullAmountBill: 'BillFull',
installmentsCash: 'Split', installmentsBill: 'BillSplit',
fullAmountBill: 'BillFull', } as const
installmentsBill: 'BillSplit', )[pageState.currentTab]
} as const : undefined,
)[pageState.currentTab] });
: undefined,
});
if (ret) { if (ret) {
quotationData.value = ret.result; quotationData.value = ret.result;
quotationPageMax.value = Math.floor(ret.total / quotationPageSize.value); quotationPageMax.value = Math.floor(ret.total / quotationPageSize.value);
} }
flowStore.rotate(); flowStore.rotate();
}, }
);
watch(() => pageState.currentTab, fetchQuotationList);
</script> </script>
<template> <template>
@ -804,10 +799,10 @@ watch(
</div> </div>
<nav class="col-4 row justify-end"> <nav class="col-4 row justify-end">
<PaginationComponent <PaginationComponent
v-model:current-page="pageState.currentPage" v-model:current-page="quotationPage"
v-model:max-page="pageState.currentMaxPage" v-model:max-page="quotationPageMax"
:fetch-data="fetchQuotationList"
/> />
<!-- :fetch-data="async () => await fetchUserList()" -->
</nav> </nav>
</footer> </footer>
</div> </div>