diff --git a/src/pages/04_product-service/MainPage.vue b/src/pages/04_product-service/MainPage.vue index cd7806bf..ae66ade6 100644 --- a/src/pages/04_product-service/MainPage.vue +++ b/src/pages/04_product-service/MainPage.vue @@ -207,6 +207,15 @@ const pageSizeGroup = ref(30); const currentPageType = ref(1); const maxPageType = ref(1); const pageSizeType = ref(30); +const currentPageServiceAndProduct = ref(1); +const maxPageServiceAndProduct = ref(1); +const pageSizeServiceAndProduct = ref(30); +const currentPageProduct = ref(1); +const maxPageProduct = ref(1); +const pageSizeProduct = ref(30); +const currentPageService = ref(1); +const maxPageService = ref(1); +const pageSizeService = ref(30); // เก็บ id ที่เข้ามา const currentId = ref(''); @@ -350,6 +359,8 @@ async function fetchListGroups() { async function fetchListOfProduct(productTypeId: string) { const res = await fetchListProduct({ + page: currentPageProduct.value, + pageSize: pageSizeProduct.value, status: currentStatus.value === 'INACTIVE' ? 'INACTIVE' @@ -360,6 +371,9 @@ async function fetchListOfProduct(productTypeId: string) { }); if (res) { + currentPageProduct.value = res.page; + maxPageProduct.value = Math.ceil(res.total / pageSizeProduct.value); + product.value = res.result.map((v) => { return { ...v, @@ -371,6 +385,8 @@ async function fetchListOfProduct(productTypeId: string) { async function fetchListOfService() { const res = await fetchListService({ + page: currentPageService.value, + pageSize: pageSizeService.value, status: currentStatus.value === 'INACTIVE' ? 'INACTIVE' @@ -381,6 +397,8 @@ async function fetchListOfService() { }); if (res) { + currentPageService.value = res.page; + maxPageService.value = Math.ceil(res.total / pageSizeService.value); service.value = res.result.map((v) => { return { ...v, @@ -469,6 +487,8 @@ async function toggleStatusGroup(id: string, status: Status) { async function fetchListOfProductAndService() { const res = await fetchListProductAndService({ + page: currentPageServiceAndProduct.value, + pageSize: pageSizeServiceAndProduct.value, status: currentStatus.value === 'INACTIVE' ? 'INACTIVE' @@ -482,6 +502,11 @@ async function fetchListOfProductAndService() { if (currentStatus.value === 'All') { totalProductAndService.value = res.total; } + + currentPageServiceAndProduct.value = res.page; + maxPageServiceAndProduct.value = Math.ceil( + res.total / pageSizeServiceAndProduct.value, + ); productAndService.value = res.result; } } @@ -910,6 +935,18 @@ watch(currentPageGroup, async () => { watch(currentPageType, async () => { await fetchListType(); }); + +watch(currentPageServiceAndProduct, async () => { + await fetchListOfProductAndService(); +}); + +watch(currentPageProduct, async () => { + await fetchListOfProduct(currentIdType.value); +}); + +watch(currentPageService, async () => { + await fetchListOfService(); +});