From b211a206d770f61cf9994efcdb5251056b75f533 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Wed, 10 Apr 2024 19:10:13 +0700 Subject: [PATCH 1/2] feat: Personnel => Main submit function --- .../02_personnel-management/MainPage.vue | 56 +++++++++++-------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/src/pages/02_personnel-management/MainPage.vue b/src/pages/02_personnel-management/MainPage.vue index 03e786af..db50b1e5 100644 --- a/src/pages/02_personnel-management/MainPage.vue +++ b/src/pages/02_personnel-management/MainPage.vue @@ -114,11 +114,6 @@ const userOption = ref({ brOpts: [], }); -const brOpts = ref([ - { label: '0000000001-1', value: '1' }, - { label: '0000000001-2', value: '2' }, -]); - const selectorList = [ { label: 'personnelSelector1', count: 0 }, { label: 'personnelSelector2', count: 0 }, @@ -159,7 +154,7 @@ async function fetchBrOption(id: string) { const res = await branchStore.fetchById(id, { includeSubBranch: true, }); - if (res) { + if (res.branch) { res.branch.map((item) => { userOption.value.brOpts.push({ label: item.code, @@ -215,10 +210,11 @@ async function openDialog(id?: string) { : null; formData.value.responsibleArea = foundUser.responsibleArea; userId.value = foundUser.id; - hqId.value = foundUser.branch[0].id; - brId.value = foundUser.branch; + hqId.value = foundUser.branch[0].headOfficeId as string; + brId.value = foundUser.branch[0].id; code.value = foundUser.code; isEdit.value = true; + console.log(hqId.value); } } } @@ -235,17 +231,26 @@ function onClose() { } async function onSubmit() { - try { - if (isEdit.value === true && userId.value) { - await userStore.editById(userId.value, formData.value); - } else { - formData.value.keycloakId = await createKeycloak(); - await userStore.create(formData.value); + console.log('enter'); + if (isEdit.value === true && userId.value) { + console.log('edit'); + await userStore.editById(userId.value, formData.value); + } else { + console.log('post'); + formData.value.keycloakId = await createKeycloak(); + if (formData.value.keycloakId) { + const result = await userStore.create(formData.value); + console.log('Result after create:', result); + console.log('bb'); + if (result) { + console.log('hi3'); + console.log(result.id); + // await branchStore.addUser(result.id, userId.value); + } } - } finally { - modal.value = false; - await userStore.fetchList(); } + onClose(); + userStore.fetchList(); } async function onDelete(id: string) { @@ -268,8 +273,9 @@ function mapUserType(label: string) { onMounted(async () => { await userStore.fetchList({ includeBranch: true }); typeStats.value = await userStore.typeStats(); - if ((await branchStore.userStats(formData.value.userType)) !== false) { - userStats.value = await branchStore.userStats(formData.value.userType); + const res = await branchStore.userStats(formData.value.userType); + if (res) { + userStats.value = res; } }); @@ -277,8 +283,9 @@ watch( () => selectorLabel.value, async (label) => { mapUserType(label); - if ((await branchStore.userStats(label)) !== false) { - userStats.value = await branchStore.userStats(label); + const res = await branchStore.userStats(label); + if (res) { + userStats.value = res; } }, ); @@ -311,7 +318,8 @@ watch(
- {{ $t('personnelStatTitle') + $t(selectorLabel) }} + {{ $t('personnelStatTitle') }} + {{ selectorLabel === '' ? '' : $t(selectorLabel) }}
+ Date: Wed, 10 Apr 2024 19:10:54 +0700 Subject: [PATCH 2/2] fix: remove i18n statcard --- src/components/StatCardComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/StatCardComponent.vue b/src/components/StatCardComponent.vue index e542a05d..81a2430a 100644 --- a/src/components/StatCardComponent.vue +++ b/src/components/StatCardComponent.vue @@ -38,7 +38,7 @@ const color = ['pink', 'purple'];
{{ v.amount }}
-
{{ $t(v.label) }}
+
{{ v.label }}