From e95048fe263d435f7349d61bafc0691ef1f10fcc Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 15 May 2024 18:35:47 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=9B=E0=B8=A3?= =?UTF-8?q?=E0=B8=B0=E0=B8=A7=E0=B8=B1=E0=B8=95=E0=B8=B4=E0=B8=A3=E0=B8=B9?= =?UTF-8?q?=E0=B8=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../04_registryNew/views/detailView.vue | 92 ++++++++++--------- 1 file changed, 48 insertions(+), 44 deletions(-) diff --git a/src/modules/04_registryNew/views/detailView.vue b/src/modules/04_registryNew/views/detailView.vue index 115e0a983..3a3a79db3 100644 --- a/src/modules/04_registryNew/views/detailView.vue +++ b/src/modules/04_registryNew/views/detailView.vue @@ -93,26 +93,27 @@ function selectFile() { imageActive(null); } -function imageActive(n: any){ +function imageActive(n: any) { activeImage.value = n; -}; - -function uploadImg(){ - http - .post(config.API.orgProfileAvatar,{ - profileId:profileId.value - }) - .then((res)=>{ - console.log(res.data) - uploadProfile(res.data.result.avatar) - }).catch((e)=>{ - messageError($q,e) - }).finally(()=>{ - - }) } -async function uploadProfile(path:string) { +function uploadImg() { + http + .post(config.API.orgProfileAvatar, { + profileId: profileId.value, + }) + .then((res) => { + console.log(res.data); + fileName.value = res.data.result.avatarName; + uploadProfile(res.data.result.avatar); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => {}); +} + +async function uploadProfile(path: string) { await http .post(config.API.fileByPath(path), { replace: true, @@ -125,7 +126,7 @@ async function uploadProfile(path:string) { .then(async (res) => { uploadUrl.value = res.data[fileName.value].uploadUrl; uploadFileURL(uploadUrl.value, profileFile.value); - dialogImage.value = false + dialogImage.value = false; }) .catch((err) => { messageError($q, err); @@ -176,6 +177,7 @@ async function fetchDataPersonal() { .get(config.API.registryNewByProfileId(profileId.value, empType.value)) .then((res) => { formDetail.value = res.data.result; + fileName.value = res.data.result.avatarName; }) .catch((err) => { messageError($q, err); @@ -335,32 +337,34 @@ async function clickSaveDeceased() { function openDialogImg() { dialogImage.value = true; - showLoader() + showLoader(); http - .get(config.API.orgProfileAvatar+`/${profileId.value}`) - .then((res)=>{ - let data = res.data.result; - for(let i = 0;i < data.length; i++){ - getImg(data[i]) - } + .get(config.API.orgProfileAvatar + `/${profileId.value}`) + .then((res) => { + let data = res.data.result; + for (let i = 0; i < data.length; i++) { + getImg(data[i]); + } // images.value = data - }).catch((e)=>{ - messageError($q,e) - }).finally(()=>{ - hideLoader() - }) + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); } -function getImg(dataList:any){ +function getImg(dataList: any) { http - .get(config.API.fileByPath(`${dataList.avatar}/${dataList.avatarName}`)) - .then((res)=>{ - console.log(res) - }).catch((e)=>{ - messageError($q,e) - }).finally(()=>{ - - }) + .get(config.API.fileByPath(`${dataList.avatar}/${dataList.avatarName}`)) + .then((res) => { + console.log(res); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => {}); } function closeImage() { @@ -399,7 +403,7 @@ async function selectAvatarHistory() { }) .then((res) => { dialogImage.value = false; - fileName.value = `profile-${profileId.value}`; + // fileName.value = `profile-${profileId.value}`; fetchProfile(profileId.value); fetchDataPersonal(); }) @@ -407,14 +411,14 @@ async function selectAvatarHistory() { messageError($q, e); }) .finally(() => { - hideLoader() + hideLoader(); }); } onMounted(async () => { - fileName.value = `profile-${profileId.value}`; - fetchProfile(profileId.value); - fetchDataPersonal(); + // fileName.value = `profile-${profileId.value}`; + await fetchDataPersonal(); + await fetchProfile(profileId.value); });