From 8aa280db98aa19ad96ce79698579f81aa663a4b3 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 29 Aug 2024 16:56:29 +0700 Subject: [PATCH] =?UTF-8?q?KPI=20=3D=3D>=20=E0=B8=9B=E0=B8=A3=E0=B8=B1?= =?UTF-8?q?=E0=B8=9A=20fetch=20profile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/08_KPI/views/form.vue | 171 ++++++++---------------------- 1 file changed, 44 insertions(+), 127 deletions(-) diff --git a/src/modules/08_KPI/views/form.vue b/src/modules/08_KPI/views/form.vue index 1a94f9f..272baad 100644 --- a/src/modules/08_KPI/views/form.vue +++ b/src/modules/08_KPI/views/form.vue @@ -13,21 +13,14 @@ import DialogHeader from "@/components/DialogHeader.vue"; import type { FormProfile } from "@/modules/08_KPI/interface/request/index"; import type { DataOptions } from "@/modules/08_KPI/interface/index/Main"; import DialogGovernment from "@/modules/08_KPI/components/Tab/Dialog/DialogGovernment.vue"; -// import DialogStatus from "@/modules/08_KPI/components/Tab/Dialog/DialogStatus.vue"; const modalGovernment = ref(false); -// const modalStatus = ref(false); -// const modalScore = ref(false); + const modalEdit = ref(false); const route = useRoute(); const id = ref(route.params.id as string); const isReadonly = (route.name === "KPIEditEvaluator" ? true : false); -// const plannedPoint = ref(""); -// const rolePoint = ref(""); -// const specialPoint = ref(""); -// const capacityPoint = ref(""); - const store = useKpiDataStore(); const $q = useQuasar(); const mixin = useCounterMixin(); @@ -68,28 +61,17 @@ const router = useRouter(); async function fetchEvaluation() { await http .get(config.API.kpiEvaluation + `/${id.value}`) - .then((res) => { - const data = res.data.result; + .then(async (res) => { + const data = await res.data.result; store.dataEvaluation = res.data.result; - formProfile.status = store.convertStatus(data.evaluationStatus); - formProfile.result = store.convertResults(data.evaluationResults); + formProfile.status = await store.convertStatus(data.evaluationStatus); + formProfile.result = await store.convertResults(data.evaluationResults); // store.checkCompetency(); store.checkCompetencyDefaultCompetencyLevel(); - - fetchProfile(data.profileId); - - // plannedPoint.value = data.plannedPoint == null ? "" : data.plannedPoint; - // rolePoint.value = data.rolePoint == null ? "" : data.rolePoint; - // specialPoint.value = data.specialPoint == null ? "" : data.specialPoint; - // capacityPoint.value = - // data.capacityPoint == null ? "" : data.capacityPoint; }) .catch((e) => { messageError($q, e); }); - // .finally(() => { - // hideLoader(); - // }); } async function getProfile() { @@ -98,37 +80,23 @@ async function getProfile() { .then(async (res) => { const data = await res.data.result; store.dataProfile = await data; + + if (data.avatarName) { + await fetchProfile(data.profileId, data.avatarName); + } + await store.checkStep(); }) .catch((e) => { messageError($q, e); }); - // .finally(() => { - // hideLoader(); - // }); } -async function fetchProfile(id: string) { - await http - .get(config.API.orgCheckAvatar(id)) +async function fetchProfile(id: string, avatarName: string) { + http + .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, avatarName)) .then(async (res) => { - if (res.data.result.avatarName) { - http - .get( - config.API.fileByFile( - "ทะเบียนประวัติ", - "โปรไฟล์", - id, - res.data.result.avatarName - ) - ) - .then(async (res) => { - store.dataEvaluation.avartar = res.data.downloadUrl; - }); - } - }) - .catch(() => { - // profilePicture.value = avatar; + store.dataEvaluation.avartar = res.data.downloadUrl; }); } @@ -156,11 +124,10 @@ function onSubmit() { ? commanderHighId.value.id : null, }) - .then((res) => { - fetchEvaluation(); - getOrgOp(); - close(); + .then(async () => { + await Promise.all([fetchEvaluation(), getOrgOp()]); success($q, "บันทึกสำเร็จ"); + close(); }) .catch((e) => { messageError($q, e); @@ -243,41 +210,8 @@ function filterOption(val: any, update: Function, refData: string) { } } -// function onSubmitScore() { -// showLoader(); -// http -// .put(config.API.kpiScoreTotal() + `/${id.value}`, { -// plannedPoint: plannedPoint.value, -// rolePoint: rolePoint.value, -// specialPoint: specialPoint.value, -// capacityPoint: capacityPoint.value, -// }) -// .then(async (res) => { -// await fetchEvaluation(); -// success($q, "บันทึกสำเร็จ"); -// modalScore.value = false; -// }) -// .catch((e) => { -// messageError($q, e); -// }) -// .finally(() => { -// hideLoader(); -// }); -// } - -// async function clearScore() { -// modalScore.value = false; -// plannedPoint.value = ""; -// rolePoint.value = ""; -// specialPoint.value = ""; -// capacityPoint.value = ""; -// getAll(); -// } - async function getAll() { - await fetchEvaluation(); - await getProfile(); - await getOrgOp(); + await Promise.all([fetchEvaluation(), getProfile(), getOrgOp()]); } function sendToEvaluatore() { @@ -290,9 +224,9 @@ function sendToEvaluatore() { .put(config.API.kpiSendToStatus(id.value), { status: "NEW_EVALUATOR", }) - .then((res) => { - success($q, "ส่งข้อตกลงให้ผู้ประเมินอนุมัติสำเร็จ"); - fetchEvaluation(); + .then(async () => { + await fetchEvaluation(); + await success($q, "ส่งข้อตกลงให้ผู้ประเมินอนุมัติสำเร็จ"); }) .catch((e) => { messageError($q, e); @@ -307,6 +241,9 @@ function sendToEvaluatore() { ); } +/** + * ยืนยันการส่งให้ผู้ประเมินรายงานผลสำเร็จของงาน + */ function sendToEvaluateEvaluatore() { dialogConfirm( $q, @@ -317,9 +254,9 @@ function sendToEvaluateEvaluatore() { .put(config.API.kpiSendToStatus(id.value), { status: "EVALUATING_EVALUATOR", }) - .then((res) => { - success($q, "ส่งให้ผู้ประเมินรายงานผลสำเร็จของงานสำเร็จ"); - fetchEvaluation(); + .then(async () => { + await fetchEvaluation(); + await success($q, "ส่งให้ผู้ประเมินรายงานผลสำเร็จของงานสำเร็จ"); }) .catch((e) => { messageError($q, e); @@ -333,31 +270,10 @@ function sendToEvaluateEvaluatore() { "ต้องการยืนยันส่งให้ผู้ประเมินรายงานผลสำเร็จของงานใช่หรือไม่?" ); } -// function sendToSummary(status: string) { -// dialogConfirm( -// $q, -// () => { -// if (id.value) { -// showLoader(); -// http -// .get(config.API.kpiSendToSummary(id.value)) -// .then((res) => { -// success($q, "ส่งไปสรุปผลการประเมินสำเร็จ"); -// getAll(); -// store.tabMain = "4"; -// }) -// .catch((e) => { -// messageError($q, e); -// }) -// .finally(() => { -// hideLoader(); -// }); -// } -// }, -// "ยืนยันการส่งไปสรุปผลการประเมิน", -// "ต้องการยืนยันส่งไปสรุปผลการประเมินใช่หรือไม่?" -// ); -// } + +/** + * ยืนยันการขอแก้ไขข้อตกลง + */ function requireEdit() { dialogConfirm( $q, @@ -368,9 +284,9 @@ function requireEdit() { .put(config.API.kpiReqEdit(id.value), { status: "EVALUATOR", }) - .then((res) => { - success($q, "ขอแก้ไขสำเร็จ"); - fetchEvaluation(); + .then(async (res) => { + await fetchEvaluation(); + await success($q, "ขอแก้ไขสำเร็จ"); }) .catch((e) => { messageError($q, e); @@ -388,11 +304,9 @@ function requireEdit() { function openGovernment() { modalGovernment.value = true; } + function openStatus() { - // router.push(`/probation/${store.dataEvaluation.profileId}`); - // router.push(`/probation`); router.push(`/probation-detail/${store.dataEvaluation.profileId}`); - // modalStatus.value = true; } function sendToEvauator() { @@ -403,7 +317,7 @@ function sendToEvauator() { status: "EVALUATING", id: [store.dataEvaluation.id], }) - .then(async (res) => { + .then(async () => { await getAll(); store.tabMain = "3"; }) @@ -416,6 +330,9 @@ function sendToEvauator() { }); } +/** + * ยืนยันการส่งไปสรุปผลการประเมิน + */ async function goToSummary() { dialogConfirm( $q, @@ -423,7 +340,7 @@ async function goToSummary() { showLoader(); await http .get(config.API.sendToSummary(store.dataEvaluation.id)) - .then(async (res) => { + .then(async () => { await http .put( config.API.updatePoint(store.dataEvaluation.id), @@ -493,13 +410,13 @@ const evaluator = ref({ isPosmasterAct: false, posmasterAct: [], }); + async function fetchProfileEvaluator(id: string) { showLoader(); http .get(config.API.orgPosition + `/${id}`) - .then((res) => { - console.log(res.data.result); - const data = res.data.result; + .then(async (res) => { + const data = await res.data.result; evaluator.value.fullName = data.prefix + data.firstName + " " + data.lastName; evaluator.value.position = data.position; @@ -507,7 +424,7 @@ async function fetchProfileEvaluator(id: string) { evaluator.value.posLevelName = data.posLevelName; evaluator.value.isPosmasterAct = data.isPosmasterAct; evaluator.value.posmasterAct = data.posmasterAct[0]; - evaluator.value.org = findOrgName(data); + evaluator.value.org = await findOrgName(data); }) .catch((e) => { messageError($q, e);