From d2edb445406d91eb3d5e930b7fcc194dce500afe Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 11 Jun 2024 16:34:25 +0700 Subject: [PATCH] CardProfile => CheckAvatar --- src/api/02_organizational/api.organization.ts | 11 +++++++---- src/components/CardProfile.vue | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index 59f15364e..4695b7b57 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -20,10 +20,10 @@ export default { /** position*/ orgPosPosition: `${orgPos}/position`, orgPosPositionById: (id: string) => `${orgPos}/position/${id}`, - orgPosPositionExecutive : () => `${orgPos}/position/executive`, + orgPosPositionExecutive: () => `${orgPos}/position/executive`, orgPosExecutive: `${orgPos}/executive`, orgPosType: `${orgPos}/type`, - orgPosTypeId: (id: string) => `${orgPos}/type/${id}`, + orgPosTypeId: (id: string) => `${orgPos}/type/${id}`, orgPosLevel: `${orgPos}/level`, orgPosMaster: `${orgPos}/master`, orgPosMasterById: (id: string) => `${orgPos}/master/${id}`, @@ -86,7 +86,10 @@ export default { orgProfileEmp: `${orgEmployeePos}/profile`, orgSearchProfileEmp: `${orgProfile}-employee/search`, - orgProfileById:(id:string,type:string)=>`${orgProfile}${type}/${id}`, + orgProfileById: (id: string, type: string) => `${orgProfile}${type}/${id}`, - orgDeceasedProfile:`${orgPos}/profile/search` + orgDeceasedProfile: `${orgPos}/profile/search`, + + // + orgCheckAvatar: (id: string) => `${orgProfile}/avatar/profileId/${id}`, }; diff --git a/src/components/CardProfile.vue b/src/components/CardProfile.vue index af2afff71..b275af850 100644 --- a/src/components/CardProfile.vue +++ b/src/components/CardProfile.vue @@ -38,7 +38,7 @@ const profileId = ref(""); function fetchDataProfile(data: DataProfile) { if (data.profileId) { - fetchProfile(data.profileId); + fetchCheckAvatar(data.profileId); } profile.id = data.profileId; profile.fullName = `${data.prefix ?? ""}${data.firstName ?? ""} ${ @@ -72,12 +72,19 @@ function fetchDataProfile(data: DataProfile) { } } -function fetchProfile(id: string) { +function fetchCheckAvatar(id: string) { + http.get(config.API.orgCheckAvatar(id)).then((res) => { + const data = res.data.result; + if (data.avatarName) { + fetchProfile(id, data.avatarName); + } + }); +} + +function fetchProfile(id: string, name: string) { if (profile.avatar === "") { http - .get( - config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, `profile-${id}`) - ) + .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, `${name}`)) .then(async (res) => { profile.avatar = res.data.downloadUrl; });