kpi updated

This commit is contained in:
Warunee Tamkoo 2024-05-14 23:48:29 +07:00
parent 56a38622e5
commit 6c532a0202
8 changed files with 266 additions and 182 deletions

View file

@ -16,19 +16,6 @@ import { useCounterMixin } from "@/stores/mixin";
import { useKpiDataStore } from "@/modules/08_KPI/store";
import type { ListCriteria } from "@/modules/08_KPI/interface/request/index";
const indicatorWeightTotal = defineModel("indicatorWeightTotal", {
type: Number,
default: 0,
});
const indicatorWeight1Total = defineModel("indicatorWeight1Total", {
type: Number,
default: 0,
});
const indicatorWeight2Total = defineModel("indicatorWeight2Total", {
type: Number,
default: 0,
});
const dataListCriteria = ref<ListCriteria[]>([]);
const modalCriteria = ref<boolean>(false);
@ -58,6 +45,9 @@ const totalResults3 = ref<number>(0);
const weightPlanned = ref<number>(0);
const weightRole = ref<number>(0);
const weightAssigned = ref<number>(0);
const resultPlanned = ref<number>(0);
const resultRole = ref<number>(0);
const resultAssigned = ref<number>(0);
function fetchListPlanned() {
http
.get(config.API.kpiAchievement("planned") + `?id=${evaluationId.value}`)
@ -70,21 +60,23 @@ function fetchListPlanned() {
rows_01.value = newRow;
if (newRow.length > 0) {
const result = newRow.reduce(
resultPlanned.value = newRow.reduce(
(sum: number, e: any) => sum + e.evaluationResults,
0
);
store.excusiveIndicator1PercentVal = resultPlanned.value;
const weight = newRow.reduce(
(sum: number, e: any) => sum + e.weight,
0
);
weightPlanned.value = weight;
indicatorWeight1Total.value = Number(weight);
store.indicatorScoreVal = result;
store.indicatorWeight1Total = Number(weight);
totalResults1.value =
(result * store.dataEvaluation.plannedPoint) / weight;
(resultPlanned.value * store.excusiveIndicator1Weight) / weight;
store.excusiveIndicator1ScoreVal = totalResults1.value;
}
})
.catch((err) => {
@ -104,20 +96,17 @@ function fetchListRole() {
rows_02.value = newRow;
if (newRow.length > 0) {
const result = newRow.reduce(
resultRole.value = newRow.reduce(
(sum: number, e: any) => sum + e.evaluationResults,
0
);
const weight = newRow.reduce(
(sum: number, e: any) => sum + e.weight,
0
);
weightRole.value = weight;
indicatorWeight1Total.value = Number(weight);
totalResults2.value =
(result * store.dataEvaluation.rolePoint) / weight;
}
})
.catch((err) => {
@ -138,19 +127,24 @@ function fetchAssigned() {
rows_03.value = newRow;
if (newRow.length > 0) {
const result = newRow.reduce(
resultAssigned.value = newRow.reduce(
(sum: number, e: any) => sum + e.evaluationResults,
0
);
store.excusiveIndicator2PercentVal = resultAssigned.value;
const weight = newRow.reduce(
(sum: number, e: any) => sum + e.weight,
0
);
weightAssigned.value = weight;
store.indicatorWeight2Total = Number(weight);
totalResults3.value =
(result * store.dataEvaluation.specialPoint) / weight;
(resultAssigned.value * store.excusiveIndicator2Weight) / weight;
store.excusiveIndicator2ScoreVal = totalResults3.value;
}
})
.catch((err) => {
@ -162,11 +156,6 @@ function onInfo() {
modalCriteria.value = true;
}
const resultWork = computed(() => {
const total = totalResults1.value + totalResults2.value + totalResults3.value;
return total.toFixed(2);
});
function getCriteria() {
http
.get(config.API.KpiEvaluationInfo)
@ -182,6 +171,7 @@ function getCriteria() {
const isShowScore = computed(() => {
return (
store.tabOpen === 3 &&
store.tabMain === "3" &&
store.dataEvaluation.evaluationStatus === "EVALUATING"
);
});
@ -190,7 +180,7 @@ watch(
[weightPlanned, weightRole, weightAssigned],
([newA, newB, newC], [prevA, prevB, prevC]) => {
if (newA !== prevA || newB !== prevB || newC !== prevC) {
indicatorWeightTotal.value =
store.indicatorWeightTotal =
Number(weightPlanned.value) +
Number(weightAssigned.value) +
Number(weightRole.value);
@ -198,12 +188,20 @@ watch(
}
);
async function getAll() {
await getCriteria();
await fetchListPlanned();
await fetchListRole();
await fetchAssigned();
}
watch(
[resultPlanned, resultRole, resultAssigned],
([newA, newB, newC], [prevA, prevB, prevC]) => {
if (newA !== prevA || newB !== prevB || newC !== prevC) {
store.indicatorPercentVal =
Number(resultPlanned.value) +
Number(resultRole.value) +
Number(resultAssigned.value);
store.indicatorScoreVal =
store.indicatorPercentVal * (store.indicatorScore / 100);
}
}
);
onMounted(() => {
getCriteria();
@ -225,7 +223,6 @@ onMounted(() => {
<span class="txt-under text-blue-6">องคประกอบท 1 </span>
<span class="q-ml-sm"> ผลสมฤทธของงาน</span>
</div>
<div class="q-gutter-md q-mt-sm">
<!-- องคประกอบท 1 -->
<div v-if="store.dataProfile.posExecutiveName != null">
@ -245,11 +242,11 @@ onMounted(() => {
:rows="[
{
name: 'รวมผลการประเมิน (ร้อยละ)',
value: store.excusiveIndicator1PercentVal,
value: store.excusiveIndicator1PercentVal.toFixed(2),
},
{
name: 'ผลการประเมินมิติที่ 1 (คะแนน)',
value: store.excusiveIndicator1ScoreVal,
value: store.excusiveIndicator1ScoreVal.toFixed(2),
},
]"
:columns="[
@ -289,13 +286,13 @@ onMounted(() => {
dense
bordered
:rows="[
{
name: 'รวมผลการประเมิน (ร้อยละ)',
value: store.excusiveIndicator2PercentVal,
},
// {
// name: ' ()',
// value: store.excusiveIndicator2PercentVal.toFixed(2),
// },
{
name: 'ผลการประเมินมิติที่ 2 (คะแนน)',
value: store.excusiveIndicator2ScoreVal,
value: store.excusiveIndicator2ScoreVal.toFixed(2),
},
]"
:columns="[
@ -327,7 +324,12 @@ onMounted(() => {
คะแนน)</span
>
<div class="text-primary q-pl-md">
{{ store.indicatorScoreVal }}
{{
(
store.excusiveIndicator1ScoreVal +
store.excusiveIndicator2ScoreVal
).toFixed(2)
}}
</div>
</div>
</div>
@ -365,7 +367,7 @@ onMounted(() => {
:rows="[
{
name: 'รวมผลการประเมิน (ร้อยละ)',
value: store.indicatorPercentVal,
value: store.indicatorPercentVal.toFixed(2),
},
]"
:columns="[
@ -396,7 +398,7 @@ onMounted(() => {
คะแนน)</span
>
<div class="text-primary q-pl-md">
{{ store.indicatorScoreVal }}
{{ store.indicatorScoreVal.toFixed(2) }}
</div>
</div>
</div>
@ -435,7 +437,7 @@ onMounted(() => {
? store.competencyScore
: store.excusiveCompetencyScore
} คะแนน)`,
value: store.competencyScoreVal,
value: store.competencyScoreVal.toFixed(2),
},
]"
:columns="[
@ -469,7 +471,7 @@ onMounted(() => {
:rows="[
{
name: `ผลการประเมินการพัฒนาตนเอง (คะแนนเต็ม ${store.devScore} คะแนน)`,
value: store.devScoreVal,
value: store.devScoreVal.toFixed(2),
},
]"
:columns="[
@ -492,9 +494,11 @@ onMounted(() => {
class="q-mt-xs q-mb-md"
/>
</div>
</div>
<div v-if="isShowScore">
<div
v-if="isShowScore && !store.dataProfile.posExecutiveName"
v-if="store.dataProfile.posExecutiveName == null"
class="row text-body2 text-weight-bold"
>
<div class="col-12 text-center row justify-center">
@ -503,7 +507,7 @@ onMounted(() => {
(คะแนนเต {{ store.competencyDevScore }} คะแนน)</span
>
<div class="text-primary q-pl-md">
{{ store.competencyDevScoreVal }}
{{ (store.competencyScoreVal + store.devScoreVal).toFixed(2) }}
</div>
</div>
</div>
@ -514,7 +518,7 @@ onMounted(() => {
{{ store.competencyScore }} คะแนน)</span
>
<div class="text-primary q-pl-md">
{{ store.competencyScoreVal }}
{{ store.competencyScoreVal.toFixed(2) }}
</div>
</div>
</div>