diff --git a/src/components/CardProfile.vue b/src/components/CardProfile.vue index 72fe7aad0..2b90d2468 100644 --- a/src/components/CardProfile.vue +++ b/src/components/CardProfile.vue @@ -8,6 +8,7 @@ import config from "@/app.config"; import type { PropType } from "vue"; import type { FormProfile } from "@/interface/main"; import type { DataProfile } from "@/modules/05_placement/interface/index/Main"; +import avatarMain from "@/assets/avatar_user.jpg"; /** importComponents*/ import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue"; @@ -91,8 +92,11 @@ function fetchProfile(id: string, name: string) { if (profile.avatar === "") { http .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, `${name}`)) - .then(async (res) => { + .then((res) => { profile.avatar = res.data.downloadUrl; + }) + .catch(() => { + profile.avatar = avatarMain; }); } } diff --git a/src/components/Dialogs/PopupPersonalNew.vue b/src/components/Dialogs/PopupPersonalNew.vue index 1b17f7efd..ffc275ee7 100644 --- a/src/components/Dialogs/PopupPersonalNew.vue +++ b/src/components/Dialogs/PopupPersonalNew.vue @@ -14,6 +14,7 @@ import type { GovermentEmpTemp, } from "@/components/information/interface/response/Government"; import type { Avatar } from "@/components/information/interface/response/avatar"; +import avatarMain from "@/assets/avatar_user.jpg"; /** importStore*/ import { useCounterMixin } from "@/stores/mixin"; @@ -167,9 +168,9 @@ async function fetchInformation(id: string) { avatar.position = data.position ? data.position : "-"; //ถ้ามีรูปเรียก Function fetchProfile เรียกข้อมูลรูปโปรไฟล์ if (data.avatarName) { - await fetchProfile(data.id as string, data.avatarName); + fetchProfile(data.id as string, data.avatarName); } else { - avatar.avatar = ""; + avatar.avatar = avatarMain; } if (props.id) { @@ -260,11 +261,14 @@ async function fetchProfileGovTemp(id: string) { * @param id profileID * @param avatarName ชื่อไฟล์ */ -async function fetchProfile(id: string, avatarName: string) { - await http +function fetchProfile(id: string, avatarName: string) { + http .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, avatarName)) - .then(async (res) => { - avatar.avatar = await res.data.downloadUrl; + .then((res) => { + avatar.avatar = res.data.downloadUrl; + }) + .catch(() => { + avatar.avatar = avatarMain; }); } diff --git a/src/modules/04_registryPerson/views/detailView.vue b/src/modules/04_registryPerson/views/detailView.vue index 33ca37200..4fdec72a9 100644 --- a/src/modules/04_registryPerson/views/detailView.vue +++ b/src/modules/04_registryPerson/views/detailView.vue @@ -323,10 +323,10 @@ async function uploadFileURL(uploadUrl: string, file: any) { * ฟังก์ชันดึงข้อมูลรูปโปรไฟล์ * @param id โปรไฟล์ */ -async function fetchProfile(id: string) { - await http +function fetchProfile(id: string) { + http .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, fileName.value)) - .then(async (res) => { + .then((res) => { profilePicture.value = res.data.downloadUrl; }) .catch(() => { @@ -403,7 +403,7 @@ async function fetchDataPersonal() { fileName.value = res.data.result.avatarName; if (formDetail.value?.avatarName) { - await fetchProfile(profileId.value); + fetchProfile(profileId.value); } else { profilePicture.value = avatar; } diff --git a/src/modules/13_salary/components/DialogInfoMain.vue b/src/modules/13_salary/components/DialogInfoMain.vue index 3da947277..c5bfc6762 100644 --- a/src/modules/13_salary/components/DialogInfoMain.vue +++ b/src/modules/13_salary/components/DialogInfoMain.vue @@ -52,7 +52,7 @@ function fetchInformation() { citizenId.value = data.citizenId; if (data.avatarName) { - await fetchProfile(data.id as string, data.avatarName); + fetchProfile(data.id as string, data.avatarName); } else { avatar.value = avatarMain; } @@ -70,11 +70,14 @@ function fetchInformation() { * @param id profileId * @param avatarName ชื้อไฟล์ */ -async function fetchProfile(id: string, avatarName: string) { +function fetchProfile(id: string, avatarName: string) { http .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, avatarName)) - .then(async (res) => { + .then((res) => { avatar.value = res.data.downloadUrl; + }) + .catch(() => { + avatar.value = avatarMain; }); } diff --git a/src/modules/14_KPI/views/detail.vue b/src/modules/14_KPI/views/detail.vue index aede8c187..81d3df41a 100644 --- a/src/modules/14_KPI/views/detail.vue +++ b/src/modules/14_KPI/views/detail.vue @@ -8,6 +8,7 @@ import { useQuasar } from "quasar"; import { useCounterMixin } from "@/stores/mixin"; import { useKpiDataStore } from "@/modules/14_KPI/store"; +import avatar from "@/assets/avatar_user.jpg"; import DialogHeader from "@/components/DialogHeader.vue"; import type { FormProfile } from "@/modules/14_KPI/interface/request/index"; @@ -65,7 +66,7 @@ async function fetchEvaluation() { await store.checkCompetency(); await store.checkCompetencyDefaultCompetencyLevel(); - await fetchProfile(data.profileId); + fetchProfile(data.profileId); plannedPoint.value = data.plannedPoint == null ? "" : data.plannedPoint; rolePoint.value = data.rolePoint == null ? "" : data.rolePoint; @@ -81,8 +82,8 @@ async function fetchEvaluation() { // }); } -async function fetchProfile(id: string) { - await http +function fetchProfile(id: string) { + http .get( config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, `profile-${id}`) ) @@ -90,6 +91,7 @@ async function fetchProfile(id: string) { store.dataEvaluation.avartar = res.data.downloadUrl; }) .catch(() => { + store.dataEvaluation.avartar = avatar; // profilePicture.value = avatar; }); } diff --git a/src/views/MainLayout.vue b/src/views/MainLayout.vue index 3812a311d..33e733b0b 100644 --- a/src/views/MainLayout.vue +++ b/src/views/MainLayout.vue @@ -532,25 +532,29 @@ async function fetchKeycloakPosition() { await http .get(config.API.keycloakPosition()) .then(async (res) => { - const data = await res.data.result; + const data = res.data.result; usePositionKeycloakStore().setPositionKeycloak(data); if (data.avatarName) { - await getImg(data.profileId, data.avatarName); + getImg(data.profileId, data.avatarName); } else { profileImg.value = avatar; } }) .catch((err) => { messageError($q, err); + profileImg.value = avatar; }); } const profileImg = ref(""); -async function getImg(id: string, pathName: string) { - await http +function getImg(id: string, pathName: string) { + http .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, pathName)) .then((res) => { profileImg.value = res.data.downloadUrl; + }) + .catch((err) => { + profileImg.value = avatar; }); }