KPI ==> ปรับ fetch profile

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-08-29 16:56:29 +07:00
parent b5b281f991
commit 8aa280db98

View file

@ -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<boolean>(false);
// const modalStatus = ref<boolean>(false);
// const modalScore = ref<boolean>(false);
const modalEdit = ref<boolean>(false);
const route = useRoute();
const id = ref<string>(route.params.id as string);
const isReadonly = <boolean>(route.name === "KPIEditEvaluator" ? true : false);
// const plannedPoint = ref<string>("");
// const rolePoint = ref<string>("");
// const specialPoint = ref<string>("");
// const capacityPoint = ref<string>("");
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<any>({
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);