From df333c6db157081231616eadc2b1b7cf4641576f Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Thu, 8 Aug 2024 17:58:40 +0700 Subject: [PATCH] fixing change name in registry --- .../02_NameChangeHistory.vue | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/02_NameChangeHistory.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/02_NameChangeHistory.vue index d18533934..c4db7e7c3 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/02_NameChangeHistory.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/02_NameChangeHistory.vue @@ -268,10 +268,9 @@ function onSubmit() { () => { showLoader(); dialogStatus.value === "create" ? addData() : editData(editId.value); + // if (!!fileUpload.value) { + closeDialog(); - if (!!fileUpload.value) { - uploadProfile(fileUpload.value); - } }, "ยืนยันการบันทึกข้อมูล", "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" @@ -279,14 +278,14 @@ function onSubmit() { } } -async function uploadProfile(file: File | undefined) { +async function uploadProfile(id: string) { await http .post( config.API.subFile( "ทะเบียนประวัติ", "ประวัติการเปลี่ยนชื่อ-นามสกุล", profileId.value, - subId.value + id ), { replace: true, @@ -299,7 +298,7 @@ async function uploadProfile(file: File | undefined) { ) .then(async (res) => { uploadUrl.value = res.data["เอกสารหลักฐาน"].uploadUrl; - uploadFileURL(uploadUrl.value, file); + uploadFileURL(uploadUrl.value, fileUpload.value); }) .catch((err) => { messageError($q, err); @@ -379,11 +378,13 @@ async function addData() { status: changeNameData.status, documentId: changeNameData.documentId, }) - .then((res) => { - subId.value = res.data.result; + .then(async (res) => { + subId.value = await res.data.result; + uploadProfile(res.data.result); fetchData(profileId.value); props?.fetchDataPersonal?.(); + fetchDataPersonal(); success($q, "บันทึกข้อมูลสำเร็จ"); }) .catch((err) => { @@ -404,8 +405,11 @@ function editData(idData: string) { } ) .then(() => { + uploadProfile(subId.value); + fetchData(profileId.value); props.fetchDataPersonal?.(); + fetchDataPersonal(); success($q, "บันทึกข้อมูลสำเร็จ"); }) .catch((err) => {