diff --git a/src/modules/08_KPI/views/form.vue b/src/modules/08_KPI/views/form.vue index f1fa5f2..9a32cc8 100644 --- a/src/modules/08_KPI/views/form.vue +++ b/src/modules/08_KPI/views/form.vue @@ -71,22 +71,20 @@ async function fetchEvaluation() { formProfile.status = store.convertStatus(data.evaluationStatus); formProfile.result = store.convertResults(data.evaluationResults); store.checkCompetencyDefaultCompetencyLevel(); + await getAvatar(data.profileId); }) .catch((e) => { messageError($q, e); }); } -/** ดึงข้อมูลโปรไฟล์ */ -async function getProfile() { +async function getAvatar(id: string) { await http - .get(config.API.profilePosition()) + .get(config.API.orgCheckAvatar(id)) .then(async (res) => { const data = await res.data.result; - store.dataProfile = await data; - if (data.avatarName) { - await fetchProfile(data.profileId, data.avatarName); + await fetchProfile(id, data.avatarName); } }) .catch((e) => { @@ -222,7 +220,7 @@ function filterOption(val: string, update: Function, refData: string) { /** ดึงข้อมูลทั้งหมดในหน้า */ async function getAll() { - await Promise.all([fetchEvaluation(), getProfile(), getOrgOp()]); + await Promise.all([fetchEvaluation(), getOrgOp()]); await store.checkStep(); } @@ -321,7 +319,7 @@ function openGovernment() { /** เช็ค สถานะการทดลองงาน */ function openStatus() { - router.push(`/probation-detail/${store.dataEvaluation.profileId}`); + router.push(`/probation-detail/${store.dataEvaluation.id}`); } /** ส่งให้ผู้ประเมิน */ @@ -532,7 +530,7 @@ onMounted(async () => { : "" }}

- {{ findOrgName(store.dataProfile) }} + {{ findOrgName(store.dataEvaluation) }}

diff --git a/src/modules/11_probation/views/mainDetail.vue b/src/modules/11_probation/views/mainDetail.vue index 530bb52..8bcec15 100644 --- a/src/modules/11_probation/views/mainDetail.vue +++ b/src/modules/11_probation/views/mainDetail.vue @@ -3,7 +3,7 @@ import avatar from "@/assets/avatar_user.jpg"; import { ref, reactive, onMounted } from "vue"; import { useCounterMixin } from "@/stores/mixin"; -import { useRouter } from "vue-router"; +import { useRouter, useRoute } from "vue-router"; import http from "@/plugins/http"; import config from "@/app.config"; @@ -32,6 +32,7 @@ const rowsData = ref([]); const mode = ref($q.screen.gt.xs); const profileImg = ref(""); const router = useRouter(); +const route = useRoute(); const formData = reactive({ prefix: "", @@ -113,7 +114,8 @@ function onResize(size: any) { function getMain() { showLoader(); http - .get(config.API.profilePosition()) + .get(config.API.kpiEvaluation + `/${route.params.id.toString()}`) + // .get(config.API.profilePosition()) .then(async (res) => { const data = await res.data.result; formData.prefix = data.prefix; @@ -129,24 +131,35 @@ function getMain() { profileId.value = data.profileId; const promises = []; promises.push(getList(data.profileId)); - if (data.avatarName) { - promises.push(getImg(data.profileId, data.avatarName)); - } else { - profileImg.value = avatar; - } + promises.push(getAvatar(data.profileId)); await Promise.all(promises); + hideLoader(); }) .catch((e) => { messageError($q, e); - }) - .finally(() => { hideLoader(); + }) + .finally(() => {}); +} + +async function getAvatar(id: string) { + await http + .get(config.API.orgCheckAvatar(id)) + .then(async (res) => { + const data = await res.data.result; + if (data.avatarName) { + getImg(id, data.avatarName); + } else { + profileImg.value = avatar; + } + }) + .catch((e) => { + messageError($q, e); }); } function getList(id: string) { - showLoader(); http .get(config.API.probationMain(id)) .then((res) => { @@ -156,14 +169,11 @@ function getList(id: string) { }) .catch((e) => { messageError($q, e); - }) - .finally(() => { hideLoader(); }); } async function getImg(id: string, pathName: string) { - showLoader(); await http .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, pathName)) .then((res) => { @@ -171,8 +181,6 @@ async function getImg(id: string, pathName: string) { }) .catch((e) => { messageError($q, e); - }) - .finally(() => { hideLoader(); }); } @@ -242,7 +250,11 @@ onMounted(async () => { {{ formData.position ? formData.position : "-" }} - {{ formData.isProbation ? `(ทดลองปฏิบัติหน้าที่ราชการฯ)` : "" }} + {{ + formData.isProbation + ? `(ทดลองปฏิบัติหน้าที่ราชการฯ)` + : "" + }}