fix: await API fileByFile
This commit is contained in:
parent
7d46985570
commit
176b22e756
6 changed files with 38 additions and 21 deletions
|
|
@ -8,6 +8,7 @@ import config from "@/app.config";
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import type { FormProfile } from "@/interface/main";
|
import type { FormProfile } from "@/interface/main";
|
||||||
import type { DataProfile } from "@/modules/05_placement/interface/index/Main";
|
import type { DataProfile } from "@/modules/05_placement/interface/index/Main";
|
||||||
|
import avatarMain from "@/assets/avatar_user.jpg";
|
||||||
|
|
||||||
/** importComponents*/
|
/** importComponents*/
|
||||||
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
|
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
|
||||||
|
|
@ -91,8 +92,11 @@ function fetchProfile(id: string, name: string) {
|
||||||
if (profile.avatar === "") {
|
if (profile.avatar === "") {
|
||||||
http
|
http
|
||||||
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, `${name}`))
|
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, `${name}`))
|
||||||
.then(async (res) => {
|
.then((res) => {
|
||||||
profile.avatar = res.data.downloadUrl;
|
profile.avatar = res.data.downloadUrl;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
profile.avatar = avatarMain;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import type {
|
||||||
GovermentEmpTemp,
|
GovermentEmpTemp,
|
||||||
} from "@/components/information/interface/response/Government";
|
} from "@/components/information/interface/response/Government";
|
||||||
import type { Avatar } from "@/components/information/interface/response/avatar";
|
import type { Avatar } from "@/components/information/interface/response/avatar";
|
||||||
|
import avatarMain from "@/assets/avatar_user.jpg";
|
||||||
|
|
||||||
/** importStore*/
|
/** importStore*/
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
|
@ -167,9 +168,9 @@ async function fetchInformation(id: string) {
|
||||||
avatar.position = data.position ? data.position : "-";
|
avatar.position = data.position ? data.position : "-";
|
||||||
//ถ้ามีรูปเรียก Function fetchProfile เรียกข้อมูลรูปโปรไฟล์
|
//ถ้ามีรูปเรียก Function fetchProfile เรียกข้อมูลรูปโปรไฟล์
|
||||||
if (data.avatarName) {
|
if (data.avatarName) {
|
||||||
await fetchProfile(data.id as string, data.avatarName);
|
fetchProfile(data.id as string, data.avatarName);
|
||||||
} else {
|
} else {
|
||||||
avatar.avatar = "";
|
avatar.avatar = avatarMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.id) {
|
if (props.id) {
|
||||||
|
|
@ -260,11 +261,14 @@ async function fetchProfileGovTemp(id: string) {
|
||||||
* @param id profileID
|
* @param id profileID
|
||||||
* @param avatarName ชื่อไฟล์
|
* @param avatarName ชื่อไฟล์
|
||||||
*/
|
*/
|
||||||
async function fetchProfile(id: string, avatarName: string) {
|
function fetchProfile(id: string, avatarName: string) {
|
||||||
await http
|
http
|
||||||
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, avatarName))
|
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, avatarName))
|
||||||
.then(async (res) => {
|
.then((res) => {
|
||||||
avatar.avatar = await res.data.downloadUrl;
|
avatar.avatar = res.data.downloadUrl;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
avatar.avatar = avatarMain;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -323,10 +323,10 @@ async function uploadFileURL(uploadUrl: string, file: any) {
|
||||||
* ฟังก์ชันดึงข้อมูลรูปโปรไฟล์
|
* ฟังก์ชันดึงข้อมูลรูปโปรไฟล์
|
||||||
* @param id โปรไฟล์
|
* @param id โปรไฟล์
|
||||||
*/
|
*/
|
||||||
async function fetchProfile(id: string) {
|
function fetchProfile(id: string) {
|
||||||
await http
|
http
|
||||||
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, fileName.value))
|
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, fileName.value))
|
||||||
.then(async (res) => {
|
.then((res) => {
|
||||||
profilePicture.value = res.data.downloadUrl;
|
profilePicture.value = res.data.downloadUrl;
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|
@ -403,7 +403,7 @@ async function fetchDataPersonal() {
|
||||||
|
|
||||||
fileName.value = res.data.result.avatarName;
|
fileName.value = res.data.result.avatarName;
|
||||||
if (formDetail.value?.avatarName) {
|
if (formDetail.value?.avatarName) {
|
||||||
await fetchProfile(profileId.value);
|
fetchProfile(profileId.value);
|
||||||
} else {
|
} else {
|
||||||
profilePicture.value = avatar;
|
profilePicture.value = avatar;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ function fetchInformation() {
|
||||||
citizenId.value = data.citizenId;
|
citizenId.value = data.citizenId;
|
||||||
|
|
||||||
if (data.avatarName) {
|
if (data.avatarName) {
|
||||||
await fetchProfile(data.id as string, data.avatarName);
|
fetchProfile(data.id as string, data.avatarName);
|
||||||
} else {
|
} else {
|
||||||
avatar.value = avatarMain;
|
avatar.value = avatarMain;
|
||||||
}
|
}
|
||||||
|
|
@ -70,11 +70,14 @@ function fetchInformation() {
|
||||||
* @param id profileId
|
* @param id profileId
|
||||||
* @param avatarName ชื้อไฟล์
|
* @param avatarName ชื้อไฟล์
|
||||||
*/
|
*/
|
||||||
async function fetchProfile(id: string, avatarName: string) {
|
function fetchProfile(id: string, avatarName: string) {
|
||||||
http
|
http
|
||||||
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, avatarName))
|
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, avatarName))
|
||||||
.then(async (res) => {
|
.then((res) => {
|
||||||
avatar.value = res.data.downloadUrl;
|
avatar.value = res.data.downloadUrl;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
avatar.value = avatarMain;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import { useQuasar } from "quasar";
|
||||||
|
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useKpiDataStore } from "@/modules/14_KPI/store";
|
import { useKpiDataStore } from "@/modules/14_KPI/store";
|
||||||
|
import avatar from "@/assets/avatar_user.jpg";
|
||||||
|
|
||||||
import DialogHeader from "@/components/DialogHeader.vue";
|
import DialogHeader from "@/components/DialogHeader.vue";
|
||||||
import type { FormProfile } from "@/modules/14_KPI/interface/request/index";
|
import type { FormProfile } from "@/modules/14_KPI/interface/request/index";
|
||||||
|
|
@ -65,7 +66,7 @@ async function fetchEvaluation() {
|
||||||
await store.checkCompetency();
|
await store.checkCompetency();
|
||||||
await store.checkCompetencyDefaultCompetencyLevel();
|
await store.checkCompetencyDefaultCompetencyLevel();
|
||||||
|
|
||||||
await fetchProfile(data.profileId);
|
fetchProfile(data.profileId);
|
||||||
|
|
||||||
plannedPoint.value = data.plannedPoint == null ? "" : data.plannedPoint;
|
plannedPoint.value = data.plannedPoint == null ? "" : data.plannedPoint;
|
||||||
rolePoint.value = data.rolePoint == null ? "" : data.rolePoint;
|
rolePoint.value = data.rolePoint == null ? "" : data.rolePoint;
|
||||||
|
|
@ -81,8 +82,8 @@ async function fetchEvaluation() {
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchProfile(id: string) {
|
function fetchProfile(id: string) {
|
||||||
await http
|
http
|
||||||
.get(
|
.get(
|
||||||
config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, `profile-${id}`)
|
config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, `profile-${id}`)
|
||||||
)
|
)
|
||||||
|
|
@ -90,6 +91,7 @@ async function fetchProfile(id: string) {
|
||||||
store.dataEvaluation.avartar = res.data.downloadUrl;
|
store.dataEvaluation.avartar = res.data.downloadUrl;
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
store.dataEvaluation.avartar = avatar;
|
||||||
// profilePicture.value = avatar;
|
// profilePicture.value = avatar;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -532,25 +532,29 @@ async function fetchKeycloakPosition() {
|
||||||
await http
|
await http
|
||||||
.get(config.API.keycloakPosition())
|
.get(config.API.keycloakPosition())
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
const data = await res.data.result;
|
const data = res.data.result;
|
||||||
usePositionKeycloakStore().setPositionKeycloak(data);
|
usePositionKeycloakStore().setPositionKeycloak(data);
|
||||||
if (data.avatarName) {
|
if (data.avatarName) {
|
||||||
await getImg(data.profileId, data.avatarName);
|
getImg(data.profileId, data.avatarName);
|
||||||
} else {
|
} else {
|
||||||
profileImg.value = avatar;
|
profileImg.value = avatar;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
profileImg.value = avatar;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const profileImg = ref<string>("");
|
const profileImg = ref<string>("");
|
||||||
async function getImg(id: string, pathName: string) {
|
function getImg(id: string, pathName: string) {
|
||||||
await http
|
http
|
||||||
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, pathName))
|
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, pathName))
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
profileImg.value = res.data.downloadUrl;
|
profileImg.value = res.data.downloadUrl;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
profileImg.value = avatar;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue