From 8c8673dd889bdff844ce191d432b9a8e700b247d Mon Sep 17 00:00:00 2001 From: "STW_TTTY\\stwtt" Date: Fri, 26 Apr 2024 16:28:38 +0700 Subject: [PATCH] =?UTF-8?q?User=20=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=E0=B8=9F=E0=B8=B4=E0=B8=A5=E0=B8=94=E0=B9=8C=E0=B8=95?= =?UTF-8?q?=E0=B8=AD=E0=B8=99=E0=B8=AA=E0=B8=A3=E0=B9=89=E0=B8=B2=E0=B8=87?= =?UTF-8?q?=E0=B9=81=E0=B8=A5=E0=B8=B0=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84?= =?UTF-8?q?=E0=B8=82=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=9B=E0=B8=A3=E0=B8=B0?= =?UTF-8?q?=E0=B9=80=E0=B8=A1=E0=B8=B4=E0=B8=99=20=E0=B8=95=E0=B9=88?= =?UTF-8?q?=E0=B8=AD=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/KPI/api.kpis.ts | 1 + src/modules/08_KPI/views/form.vue | 164 +++++++++++++++++++++++++----- src/modules/08_KPI/views/main.vue | 102 +++++++++++++++++-- 3 files changed, 234 insertions(+), 33 deletions(-) diff --git a/src/api/KPI/api.kpis.ts b/src/api/KPI/api.kpis.ts index 99633c1..7786e09 100644 --- a/src/api/KPI/api.kpis.ts +++ b/src/api/KPI/api.kpis.ts @@ -31,4 +31,5 @@ export default { kpiUserCapacity: `${KpiUser}/capacity`, KpiEvaluation, Kpiorg, + kpiEvaluationCheck:`${kpiEvaluation}/check`, }; diff --git a/src/modules/08_KPI/views/form.vue b/src/modules/08_KPI/views/form.vue index 3e9cff3..8b80236 100644 --- a/src/modules/08_KPI/views/form.vue +++ b/src/modules/08_KPI/views/form.vue @@ -21,17 +21,19 @@ const isReadonly = (route.name === "KPIEditEvaluator" ? true : false); const store = useKpiDataStore(); const $q = useQuasar(); const mixin = useCounterMixin(); -const { showLoader, hideLoader, messageError, dialogConfirm } = mixin; +const { showLoader, hideLoader, messageError, dialogConfirm, success } = mixin; const evaluatorIdOp = ref([]); const commanderIdOp = ref([]); const commanderHighOp = ref([]); -const formEva = reactive({ - evaluatorId: "", - commanderId: "", - commanderHighId: "", -}); +const evaluatorIdMainOp = ref([]); +const commanderIdMainOp = ref([]); +const commanderHighMainOp = ref([]); + +const evaluatorId = ref(); +const commanderId = ref(); +const commanderHighId = ref(); const formProfile = reactive({ fullName: "", @@ -56,7 +58,7 @@ function fetchEvaluation() { formProfile.status = store.convertStatus(data.evaluationStatus); formProfile.result = store.convertResults(data.evaluationResults); fetchProfile(data.profileId); - console.log(store.dataEvaluation) + console.log(store.dataEvaluation); }) .catch((e) => { messageError($q, e); @@ -113,22 +115,113 @@ function close() { modalEdit.value = false; } -function clearDialog() { +async function clearDialog() { modalEdit.value = false; - formEva.evaluatorId = ""; - formEva.commanderId = ""; - formEva.commanderHighId = ""; + evaluatorId.value = null; + commanderId.value = null; + commanderHighId.value = null; + await fetchEvaluation(); + await getProfile(); + await getOrgOp(); } function onSubmit() { dialogConfirm($q, () => { - clearDialog(); + showLoader(); + http + .put(config.API.kpiEvaluationCheck + `/${id.value}`, { + evaluatorId: evaluatorId.value.id, + commanderId: commanderId.value.id, + commanderHighId: commanderHighId.value.id, + }) + .then((res) => { + success($q, "บันทึกสำเร็จ"); + clearDialog(); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); }); } -onMounted(() => { - fetchEvaluation(); - getProfile(); +function getOrgOp() { + http + .get(config.API.Kpiorg) + .then((res) => { + const data = res.data.result; + evaluatorIdMainOp.value = data.caregiver.map((i: any) => ({ + id: i.id, + name: `${i.prefix}${i.firstName} ${i.lastName}`, + })); + commanderIdMainOp.value = data.commander.map((i: any) => ({ + id: i.id, + name: `${i.prefix}${i.firstName} ${i.lastName}`, + })); + commanderHighMainOp.value = data.chairman.map((i: any) => ({ + id: i.id, + name: `${i.prefix}${i.firstName} ${i.lastName}`, + })); + + evaluatorId.value = data.caregiver + .map((i: any) => ({ + id: i.id, + name: `${i.prefix}${i.firstName} ${i.lastName}`, + })) + .find((i: any) => i.id == store.dataEvaluation.evaluatorId); + commanderId.value = data.caregiver + .map((i: any) => ({ + id: i.id, + name: `${i.prefix}${i.firstName} ${i.lastName}`, + })) + .find((i: any) => i.id == store.dataEvaluation.commanderId); + commanderHighId.value = data.caregiver + .map((i: any) => ({ + id: i.id, + name: `${i.prefix}${i.firstName} ${i.lastName}`, + })) + .find((i: any) => i.id == store.dataEvaluation.commanderHighId); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => {}); +} + +function filterOption(val: any, update: Function, refData: string) { + switch (refData) { + case "evaluatorIdOp": + update(() => { + evaluatorIdOp.value = evaluatorIdMainOp.value.filter( + (v: any) => v.name.indexOf(val) > -1 + ); + }); + break; + case "commanderIdOp": + update(() => { + commanderIdOp.value = commanderIdMainOp.value.filter( + (v: any) => v.name.indexOf(val) > -1 + ); + }); + break; + case "commanderHighOp": + update(() => { + commanderHighOp.value = commanderHighMainOp.value.filter( + (v: any) => v.name.indexOf(val) > -1 + ); + }); + break; + default: + break; + } +} + +onMounted(async () => { + await fetchEvaluation(); + await getProfile(); + await getOrgOp(); }); @@ -148,7 +241,13 @@ onMounted(() => { isReadonly ? router.push(`/KPI-evaluator`) : router.push(`/KPI`) " /> - {{ id ? `แก้ไขแบบประเมิน` : `เพิ่มแบบประเมิน` }} + {{ + isReadonly + ? "รายละเอียดการประเมินผลการปฏิบัติราชการระดับบุคคล" + : id + ? `แก้ไขแบบประเมิน` + : `เพิ่มแบบประเมิน` + }}