diff --git a/src/modules/08_KPI/components/Tab/01_Assessment.vue b/src/modules/08_KPI/components/Tab/01_Assessment.vue index b0f26b0..01bc429 100644 --- a/src/modules/08_KPI/components/Tab/01_Assessment.vue +++ b/src/modules/08_KPI/components/Tab/01_Assessment.vue @@ -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([]); const modalCriteria = ref(false); @@ -58,6 +45,9 @@ const totalResults3 = ref(0); const weightPlanned = ref(0); const weightRole = ref(0); const weightAssigned = ref(0); +const resultPlanned = ref(0); +const resultRole = ref(0); +const resultAssigned = ref(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(() => { องค์ประกอบที่ 1 ผลสัมฤทธิ์ของงาน -
@@ -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(() => { คะแนน)
- {{ store.indicatorScoreVal }} + {{ + ( + store.excusiveIndicator1ScoreVal + + store.excusiveIndicator2ScoreVal + ).toFixed(2) + }}
@@ -365,7 +367,7 @@ onMounted(() => { :rows="[ { name: 'รวมผลการประเมิน (ร้อยละ)', - value: store.indicatorPercentVal, + value: store.indicatorPercentVal.toFixed(2), }, ]" :columns="[ @@ -396,7 +398,7 @@ onMounted(() => { คะแนน)
- {{ store.indicatorScoreVal }} + {{ store.indicatorScoreVal.toFixed(2) }}
@@ -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" /> + +
@@ -503,7 +507,7 @@ onMounted(() => { (คะแนนเต็ม {{ store.competencyDevScore }} คะแนน)
- {{ store.competencyDevScoreVal }} + {{ (store.competencyScoreVal + store.devScoreVal).toFixed(2) }}
@@ -514,7 +518,7 @@ onMounted(() => { {{ store.competencyScore }} คะแนน)
- {{ store.competencyScoreVal }} + {{ store.competencyScoreVal.toFixed(2) }}
diff --git a/src/modules/08_KPI/components/Tab/DialogEvaluate/01_Indicator.vue b/src/modules/08_KPI/components/Tab/DialogEvaluate/01_Indicator.vue index 429d1a7..15ac908 100644 --- a/src/modules/08_KPI/components/Tab/DialogEvaluate/01_Indicator.vue +++ b/src/modules/08_KPI/components/Tab/DialogEvaluate/01_Indicator.vue @@ -16,6 +16,10 @@ const store = useKpiDataStore(); const { showLoader, hideLoader, messageError, dialogConfirm, success } = useCounterMixin(); +const props = defineProps({ + fetchList: { type: Function, required: true }, +}); + const modal = defineModel("modal", { required: true }); const rows = defineModel("data", { required: true }); const numpage = defineModel("numpage", { required: true }); @@ -142,7 +146,9 @@ function onSubmit() { : numpage.value === 3 ? config.API.kpiAchievementPoint("special") : ""; - await http.post(url, formData); + await http.post(url, formData).then((res) => { + props.fetchList(); + }); success($q, "บันทึกข้อมูลสำเร็จ"); } catch (err) { messageError($q, err); diff --git a/src/modules/08_KPI/components/Tab/TabMain.vue b/src/modules/08_KPI/components/Tab/TabMain.vue index eda9ce7..52ab8ad 100644 --- a/src/modules/08_KPI/components/Tab/TabMain.vue +++ b/src/modules/08_KPI/components/Tab/TabMain.vue @@ -11,18 +11,6 @@ import File from "@/modules/08_KPI/components/Tab/05_File.vue"; const store = useKpiDataStore(); const route = useRoute(); -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 itemsTab = ref([ { @@ -37,14 +25,6 @@ const itemsTab = ref([ name: "3", label: "รายงานผลสำเร็จของงาน", }, - // { - // name: "3", - // label: "ผู้บังคับบัญชาเหนือขึ้นไป", - // }, - // { - // name: "4", - // label: "ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง", - // }, { name: "5", label: "ไฟล์เอกสาร", @@ -107,12 +87,7 @@ const splitterModel = ref(12); :name="tab.name" class="q-pa-none" > - + diff --git a/src/modules/08_KPI/components/Tab/Topic/01_Indicator.vue b/src/modules/08_KPI/components/Tab/Topic/01_Indicator.vue index 8a0b900..ed7bd0c 100644 --- a/src/modules/08_KPI/components/Tab/Topic/01_Indicator.vue +++ b/src/modules/08_KPI/components/Tab/Topic/01_Indicator.vue @@ -29,18 +29,16 @@ const { success, } = useCounterMixin(); -const isReadonly = (route.name === "KPIEditEvaluator" ? true : false); const title = defineModel("title", { required: true }); const rows = defineModel("data", { required: true }); const numpage = defineModel("page", { required: true }); -const evaluationTotal = defineModel("total", { required: true }); const props = defineProps({ fetchList: { type: Function, required: true }, }); const visibleColumns = ref( - store.tabOpen === 3 + store.tabOpen === 3 && store.tabMain === "3" ? [ "includingName", "target", @@ -143,7 +141,7 @@ function onClickView(id: string) { modalViewInfo.value = true; } -function onEvaluate() { +async function onEvaluate() { modalEvaluate.value = true; } @@ -198,6 +196,28 @@ watch( } ); +const isEditStep1 = computed(() => { + return ( + (store.dataEvaluation.evaluationStatus === "NEW" && + store.rolePerson === "USER" && + store.tabMain === "1") || + (store.dataEvaluation.evaluationStatus === "NEW_EVALUATOR" && + store.rolePerson === "EVALUATOR" && + store.tabMain === "1") + ); +}); + +const isEditStep3 = computed(() => { + return ( + (store.dataEvaluation.evaluationStatus === "EVALUATING" && + store.rolePerson === "USER" && + store.tabMain === "3") || + (store.dataEvaluation.evaluationStatus === "EVALUATING_EVALUATOR" && + store.rolePerson === "EVALUATOR" && + store.tabMain === "3") + ); +}); + // watch( // () => modalAssigned.value, // () => { @@ -216,6 +236,7 @@ watch( // } // ); +