diff --git a/src/pages/04_product-service/MainPage.vue b/src/pages/04_product-service/MainPage.vue index a17b5467..bc87fcb9 100644 --- a/src/pages/04_product-service/MainPage.vue +++ b/src/pages/04_product-service/MainPage.vue @@ -200,7 +200,7 @@ const maxPageGroup = ref(1); const pageSizeGroup = ref(30); const currentPageType = ref(1); const maxPageType = ref(1); -const pageSizeType = ref(30); +const pageSizeType = ref(1); const currentPageServiceAndProduct = ref(1); const maxPageServiceAndProduct = ref(1); const pageSizeServiceAndProduct = ref(30); @@ -219,9 +219,6 @@ const currentIdProduct = ref(''); const currentStatus = ref('All'); -const resultSearchGroup = ref(); -const resultSearchType = ref<(ProductGroup & { productGroupId: string })[]>(); - const inputFile = (() => { const element = document.createElement('input'); element.type = 'file'; @@ -242,17 +239,6 @@ const inputFile = (() => { return element; })(); -async function searchGroup() { - const resultList = await fetchListProductService({ - query: inputSearch.value, - }); - - if (resultList) { - resultSearchGroup.value = resultList.result; - } - flowStore.rotate(); -} - async function searchProductAndService() { const res = await fetchListProductAndService({ query: inputSearchProductAndService.value, @@ -322,6 +308,7 @@ async function fetchListType() { const res = await fetchListProductServiceType({ page: currentPageType.value, pageSize: pageSizeType.value, + query: !!inputSearch.value ? inputSearch.value : undefined, productGroupId: currentId.value, status: currentStatus.value === 'All' @@ -342,6 +329,7 @@ async function fetchListGroups() { const res = await fetchListProductService({ page: currentPageGroup.value, pageSize: pageSizeGroup.value, + query: !!inputSearch.value ? inputSearch.value : undefined, status: currentStatus.value === 'All' ? undefined @@ -382,6 +370,9 @@ async function fetchListOfProduct(productTypeId: string) { const res = await fetchListProduct({ page: currentPageProduct.value, pageSize: pageSizeProduct.value, + query: !!inputSearchProductAndService.value + ? inputSearchProductAndService.value + : undefined, status: currentStatus.value === 'INACTIVE' ? 'INACTIVE' @@ -407,6 +398,9 @@ async function fetchListOfProduct(productTypeId: string) { async function fetchListOfService() { const res = await fetchListService({ page: currentPageService.value, + query: !!inputSearchProductAndService.value + ? inputSearchProductAndService.value + : undefined, pageSize: pageSizeService.value, status: currentStatus.value === 'INACTIVE' @@ -429,17 +423,6 @@ async function fetchListOfService() { } } -async function searchType() { - const res = await fetchListProductServiceType({ - query: inputSearch.value, - productGroupId: currentId.value, - }); - - if (res) { - resultSearchType.value = res.result; - } -} - async function submitType() { if (drawerInfo.value) { await editProductServiceType(currentIdType.value, { @@ -1037,6 +1020,16 @@ watch(currentPageService, async () => { await fetchListOfService(); flowStore.rotate(); }); + +watch(inputSearch, async () => { + if (productMode.value === 'group') { + await fetchListGroups(); + } + + if (productMode.value === 'type') { + await fetchListType(); + } +});