From be92fd509a77d27d5e9254b5b6977f1620d877d9 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Wed, 12 Jun 2024 09:57:34 +0000 Subject: [PATCH] feat: employee stats --- src/pages/03_customer-management/MainPage.vue | 31 ++++++++++--------- src/stores/employee/index.ts | 24 ++++++++++++++ 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/pages/03_customer-management/MainPage.vue b/src/pages/03_customer-management/MainPage.vue index 65a30280..4c511575 100644 --- a/src/pages/03_customer-management/MainPage.vue +++ b/src/pages/03_customer-management/MainPage.vue @@ -119,6 +119,7 @@ const formDataEmployeeTab = ref('personalInfo'); const infoDrawerEmployee = ref(false); const infoDrawerEmployeeEdit = ref(false); const infoEmployeePersonCard = ref(); +const statsEmployee = ref(0); const formDataEmployee = ref({ image: null, customerBranchId: '', @@ -319,7 +320,7 @@ const selectorList = computed(() => [ }, { label: 'EMPLOYEE', - count: listEmployee.value ? listEmployee.value.length : 0, + count: statsEmployee.value ?? 0, }, ]); @@ -593,6 +594,9 @@ async function onSubmit() { const resultList = await employeeStore.fetchList(); if (resultList) listEmployee.value = resultList.result; + const resultStatsEmployee = await employeeStore.getStatsEmployee(); + if (resultStatsEmployee) statsEmployee.value = resultStatsEmployee; + clearFormEmployee(); } } @@ -897,7 +901,6 @@ onMounted(async () => { page: 1, pageSize: pageSizeCustomer.value, }); - const resultListEmployee = await employeeStore.fetchList(); if (resultStats) statsCustomerType.value = resultStats; @@ -919,6 +922,10 @@ onMounted(async () => { listCustomer.value = resultList.result; } + const resultStatsEmployee = await employeeStore.getStatsEmployee(); + if (resultStatsEmployee) statsEmployee.value = resultStatsEmployee; + + const resultListEmployee = await employeeStore.fetchList(); if (resultListEmployee) listEmployee.value = resultListEmployee.result; const resultOption = await fetch('/option/option.json'); @@ -1030,19 +1037,13 @@ watch(fieldSelectedCustomer, async () => { diff --git a/src/stores/employee/index.ts b/src/stores/employee/index.ts index 32f32ef4..6e449b76 100644 --- a/src/stores/employee/index.ts +++ b/src/stores/employee/index.ts @@ -204,6 +204,29 @@ const useEmployeeStore = defineStore('api-employee', () => { } } + async function getStatsEmployee( + customerBranchId?: string, + flow?: { + sessionId: string; + refTransactionId: string; + transactionId: string; + }, + ) { + const res = await api.get( + `/employee/stats${customerBranchId ? '?customerBranchId=' + customerBranchId : ''}/`, + { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId, + 'X-Tid': flow?.transactionId, + }, + }, + ); + if (res && res.status === 200) { + return res.data; + } + } + return { data, globalOption, @@ -216,6 +239,7 @@ const useEmployeeStore = defineStore('api-employee', () => { fetchCheckup, fetchWork, fetchOther, + getStatsEmployee, }; });