diff --git a/src/pages/04_product-service/MainPage.vue b/src/pages/04_product-service/MainPage.vue index cd7d5f4c..21e2cfb2 100644 --- a/src/pages/04_product-service/MainPage.vue +++ b/src/pages/04_product-service/MainPage.vue @@ -190,32 +190,35 @@ const serviceTab = [ const workItems = ref([]); const workNameRef = ref(); +const selectProduct = ref([]); +const currentWorkIndex = ref(0); const currentServiceTab = ref('serviceInformation'); const propertiesDialog = ref(false); -const selectProduct = ref([]); - -const currentWorkIndex = ref(0); - const totalProduct = ref(0); const totalService = ref(0); const totalProductAndService = ref(0); -const currentPage = ref(1); -const maxPage = ref(1); -const pageSize = ref(30); +// แบ่งหน้า +const currentPageGroup = ref(1); +const maxPageGroup = ref(1); +const pageSizeGroup = ref(2); +const currentPageType = ref(1); +const maxPageType = ref(1); +const pageSizeType = ref(2); +// เก็บ id ที่เข้ามา const currentId = ref(''); const currentIdType = ref(''); const currentIdService = ref(''); const currentIdProduct = ref(''); +const currentStatus = ref('All'); + const resultSearchGroup = ref(); const resultSearchType = ref<(ProductGroup & { productGroupId: string })[]>(); -const currentStatus = ref('All'); - const inputFile = (() => { const element = document.createElement('input'); element.type = 'file'; @@ -308,6 +311,8 @@ async function featchStatsProduct() { async function fetchListType() { const res = await fetchListProductServiceType({ + page: currentPageType.value, + pageSize: pageSizeType.value, productGroupId: currentId.value, status: currentStatus.value === 'All' @@ -318,12 +323,16 @@ async function fetchListType() { }); if (res) { + currentPageType.value = res.page; + maxPageType.value = Math.ceil(res.total / pageSizeType.value); productType.value = res.result; } } async function fetchListGroups() { const res = await fetchListProductService({ + page: currentPageGroup.value, + pageSize: pageSizeGroup.value, status: currentStatus.value === 'All' ? undefined @@ -333,6 +342,8 @@ async function fetchListGroups() { }); if (res) { + currentPageGroup.value = res.page; + maxPageGroup.value = Math.ceil(res.total / pageSizeGroup.value); productGroup.value = res.result; } } @@ -891,6 +902,14 @@ watch(currentStatus, async () => { await fetchListType(); } }); + +watch(currentPageGroup, async () => { + await fetchListGroups(); +}); + +watch(currentPageType, async () => { + await fetchListType(); +});