diff --git a/src/pages/03_customer-management/MainPage.vue b/src/pages/03_customer-management/MainPage.vue index 2f893b97..eb7c467b 100644 --- a/src/pages/03_customer-management/MainPage.vue +++ b/src/pages/03_customer-management/MainPage.vue @@ -6,6 +6,7 @@ import { Pagination } from 'src/stores/types'; import useCustomerStore from 'src/stores/customer'; import useEmployeeStore from 'src/stores/employee'; +import AddCardCompoent from 'src/components/AddCardCompoent.vue'; import PersonCard from 'components/home/PersonCard.vue'; import UsersDetailCardComponent from 'src/components/UsersDetailCardComponent.vue'; import SelectorList from 'components/SelectorList.vue'; @@ -225,6 +226,10 @@ const currentPageCustomer = ref(1); const maxPageCustomer = ref(1); const pageSizeCustomer = ref(30); +const currentPageEmployee = ref(1); +const maxPageEmployee = ref(1); +const pageSizeEmployee = ref(30); + const currentBranchId = ref(''); const currentCustomerName = ref(''); const currentCustomerUrlImage = ref(null); @@ -677,6 +682,17 @@ async function fetchListCustomer() { } } +async function fetchListEmployee() { + const resultListEmployee = await employeeStore.fetchList(); + if (resultListEmployee) { + currentPageEmployee.value = resultListEmployee.page; + maxPageEmployee.value = Math.ceil( + resultListEmployee.total / pageSizeEmployee.value, + ); + listEmployee.value = resultListEmployee.result; + } +} + async function onSubmitEdit(id: string) { if (selectorLabel.value === 'EMPLOYER') { if (!formData.value) return; @@ -990,8 +1006,17 @@ onMounted(async () => { const resultStatsEmployee = await employeeStore.getStatsEmployee(); if (resultStatsEmployee) statsEmployee.value = resultStatsEmployee; - const resultListEmployee = await employeeStore.fetchList(); - if (resultListEmployee) listEmployee.value = resultListEmployee.result; + const resultListEmployee = await employeeStore.fetchList({ + page: 1, + pageSize: pageSizeEmployee.value, + }); + + if (resultListEmployee) { + maxPageEmployee.value = Math.ceil( + resultListEmployee.total / pageSizeEmployee.value, + ); + listEmployee.value = resultListEmployee.result; + } const resultOption = await fetch('/option/option.json'); employeeStore.globalOption = await resultOption.json(); @@ -1012,7 +1037,11 @@ watch(locale, () => { }); watch(currentPageCustomer, async () => { - fetchListCustomer(); + await fetchListCustomer(); +}); + +watch(currentPageEmployee, async () => { + await fetchListEmployee(); }); watch(fieldSelectedCustomer, async () => { @@ -1190,9 +1219,15 @@ watch(fieldSelectedCustomer, async () => { >
+ + {
@@ -1308,6 +1345,17 @@ watch(fieldSelectedCustomer, async () => { @delete-card="onDelete" /> + +
+ +