From ef81a93690ea867af64e0ec15cd63b5e13a9674e Mon Sep 17 00:00:00 2001 From: puriphatt Date: Thu, 30 Jan 2025 10:10:15 +0700 Subject: [PATCH] refactor: 03 => screen.xs fetch scroll --- src/pages/03_customer-management/MainPage.vue | 1056 +++++++++-------- src/pages/07_agencies-management/MainPage.vue | 22 +- 2 files changed, 565 insertions(+), 513 deletions(-) diff --git a/src/pages/03_customer-management/MainPage.vue b/src/pages/03_customer-management/MainPage.vue index 54f1c77f..c8b8b9dc 100644 --- a/src/pages/03_customer-management/MainPage.vue +++ b/src/pages/03_customer-management/MainPage.vue @@ -84,7 +84,6 @@ import { DialogContainer, DialogHeader } from 'components/dialog'; import KebabAction from 'src/components/shared/KebabAction.vue'; import { nextTick } from 'vue'; import FormEmployeeVisa from 'components/03_customer-management/FormEmployeeVisa.vue'; -import { group } from 'node:console'; import PaginationPageSize from 'src/components/PaginationPageSize.vue'; import { AddButton } from 'components/button'; @@ -224,10 +223,12 @@ watch( if (tabName === 'employer') { currentPageCustomer.value = 1; currentBtnOpen.value = []; + listCustomer.value = []; await fetchListCustomer(true); } if (tabName === 'employee') { currentPageEmployee.value = 1; + listEmployee.value = []; await fetchListEmployee({ fetchStats: true }); } @@ -383,8 +384,8 @@ async function fetchListCustomer(fetchStats = false) { customerType: ( { all: undefined, - customerLegalEntity: 'CORP', - customerNaturalPerson: 'PERS', + customerLegalEntity: CustomerType.Corporate, + customerNaturalPerson: CustomerType.Person, } as const )[customerTypeSelected.value.value], }); @@ -392,7 +393,9 @@ async function fetchListCustomer(fetchStats = false) { if (resultList) { currentPageCustomer.value = resultList.page; maxPageCustomer.value = Math.ceil(resultList.total / pageSize.value); - listCustomer.value = resultList.result; + $q.screen.xs + ? listCustomer.value.push(...resultList.result) + : (listCustomer.value = resultList.result); } if (fetchStats) { @@ -426,7 +429,9 @@ async function fetchListEmployee(opt?: { maxPageEmployee.value = Math.ceil( resultListEmployee.total / pageSize.value, ); - listEmployee.value = resultListEmployee.result; + $q.screen.xs + ? listEmployee.value.push(...resultListEmployee.result) + : (listEmployee.value = resultListEmployee.result); } if (opt && opt.fetchStats) @@ -1098,7 +1103,7 @@ const emptyCreateDialog = ref(false); class="q-px-md row q-gutter-x-sm items-center" >