From 07b50dca80d6f059c371d39b9729dfb3bb1f51d9 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 27 Aug 2024 10:37:57 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A=E0=B8=B5?= =?UTF-8?q?=E0=B8=A2=E0=B8=99=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1?= =?UTF-8?q?=E0=B8=95=E0=B8=B4=20=3D=3D>=20=E0=B8=9B=E0=B8=A3=E0=B8=B1?= =?UTF-8?q?=E0=B8=9A=20load?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detail/PersonalInformation/01_Profile.vue | 11 +++++-- .../PersonalInformation/04_FamilyNew.vue | 31 +++++++++++-------- .../04_registryPerson/stores/profile.ts | 8 +++-- .../04_registryPerson/views/detailView.vue | 18 +++++------ 4 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/01_Profile.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/01_Profile.vue index 7fae81928..300a62a9b 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/01_Profile.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/01_Profile.vue @@ -423,10 +423,17 @@ watch( ); onMounted(() => { - getData(); + const promises = []; + + // Add the getData() promise + promises.push(getData()); + + // Check the condition and add fetchPerson() if needed if (store.Ops && store.Ops.prefixOps && store.Ops.prefixOps.length === 0) { - fetchPerson(); + promises.push(fetchPerson()); } + + Promise.all(promises); }); diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/04_FamilyNew.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/04_FamilyNew.vue index 487363119..5defd1310 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/04_FamilyNew.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/04_FamilyNew.vue @@ -172,9 +172,9 @@ const fromData = reactive({ /** * function fetch ข้อมูลบิดา */ -function fetchDataFather() { +async function fetchDataFather() { showLoader(); - http + await http .get( config.API.profileFamily(empType.value, "father") + `/${profileId.value}` ) @@ -201,9 +201,9 @@ function fetchDataFather() { /** * function fetch ข้อมูลมารดา */ -function fetchDataMother() { +async function fetchDataMother() { showLoader(); - http + await http .get( config.API.profileFamily(empType.value, "mother") + `/${profileId.value}` ) @@ -229,9 +229,9 @@ function fetchDataMother() { /** * function fetch ข้อมูลคู่สมรส */ -function fetchDataCouple() { +async function fetchDataCouple() { showLoader(); - http + await http .get( config.API.profileFamily(empType.value, "couple") + `/${profileId.value}` ) @@ -259,9 +259,9 @@ function fetchDataCouple() { /** * function fetch ข้อมูลบุตร */ -function fetchDataChildren() { +async function fetchDataChildren() { showLoader(); - http + await http .get( config.API.profileFamily(empType.value, "children") + `/${profileId.value}` @@ -412,7 +412,7 @@ function onOpenDialogHistory(type: string, id: string = "") { * function fetch ข้อมูลความสัมพันธ์ */ function fetchDataRelationship() { - showLoader(); + // showLoader(); http .get(config.API.orgRelationship) .then((res) => { @@ -426,7 +426,9 @@ function fetchDataRelationship() { messageError($q, err); }) .finally(() => { - hideLoader(); + // setTimeout(() => { + // hideLoader(); + // }, 2000); }); } @@ -472,14 +474,17 @@ function fetchHistory(id: string, type: string) { }); } -onMounted(() => { - Promise.all([ +onMounted(async () => { + showLoader(); + await Promise.all([ fetchDataFather(), fetchDataMother(), fetchDataCouple(), fetchDataChildren(), fetchDataRelationship(), - ]); + ]).then(() => { + hideLoader(); + }); }); diff --git a/src/modules/04_registryPerson/stores/profile.ts b/src/modules/04_registryPerson/stores/profile.ts index 1de06731e..52a3f62db 100644 --- a/src/modules/04_registryPerson/stores/profile.ts +++ b/src/modules/04_registryPerson/stores/profile.ts @@ -173,9 +173,13 @@ export const useProfileDataStore = defineStore("profile", () => { Ops.value.religionOps = optionreligions; OpsFilter.value.religionOps = optionreligions; }) - .catch((e: any) => {}) + .catch((e) => { + messageError($q, e); + }) .finally(() => { - hideLoader(); + setTimeout(() => { + hideLoader(); + }, 2500); }); }; diff --git a/src/modules/04_registryPerson/views/detailView.vue b/src/modules/04_registryPerson/views/detailView.vue index c432e35b3..8a12ad1e7 100644 --- a/src/modules/04_registryPerson/views/detailView.vue +++ b/src/modules/04_registryPerson/views/detailView.vue @@ -199,7 +199,7 @@ function uploadFileURL(uploadUrl: string, file: any) { } function fetchProfile(id: string) { - showLoader(); + // showLoader(); http .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, fileName.value)) .then(async (res) => { @@ -208,9 +208,9 @@ function fetchProfile(id: string) { .catch(() => { profilePicture.value = avatar; }) - .finally(() => { - hideLoader(); - }); + // .finally(() => { + // hideLoader(); + // }); } const reasonStatus = ref(false); @@ -254,7 +254,7 @@ async function fetchDataPersonal() { showLoader(); await http .get(config.API.registryNewByProfileId(profileId.value, empType.value)) - .then((res) => { + .then(async (res) => { formDetail.value = res.data.result; if (res.data.result.leaveReason) { @@ -275,7 +275,7 @@ async function fetchDataPersonal() { fileName.value = res.data.result.avatarName; if (formDetail.value?.avatarName) { - fetchProfile(profileId.value); + await fetchProfile(profileId.value); } else { profilePicture.value = avatar; } @@ -291,13 +291,13 @@ async function fetchDataPersonal() { } }) .finally(() => { - hideLoader(); + setTimeout(() => { + hideLoader(); + }, 2800); }); } function onClickDownloadKp7(type: string) { - console.log(empType.value); - showLoader(); const url = type === "FULL"