hrms-user/src/modules/08_KPI/store.ts

331 lines
14 KiB
TypeScript
Raw Normal View History

2024-04-04 14:14:25 +07:00
import { defineStore } from "pinia";
2024-04-09 15:22:23 +07:00
import { ref } from "vue";
2024-04-22 18:14:48 +07:00
import type { DataOptions } from "./interface/index/Main";
2024-04-04 14:14:25 +07:00
export const useKpiDataStore = defineStore("KPIDate", () => {
2024-04-09 15:22:23 +07:00
const tabMain = ref<string>("1");
2024-05-08 18:12:52 +07:00
const dataProfile = ref<any>({
profileId: null,
prefix: "",
rank: "",
firstName: "",
lastName: "",
citizenId: "",
position: "",
posMaster: null,
posLevelName: null,
posLevelRank: null,
posLevelId: null,
posTypeName: null,
posTypeRank: null,
posTypeId: null,
posExecutiveName: "",
posExecutivePriority: null,
posExecutiveId: null,
rootId: null,
root: "",
child1Id: null,
child1: null,
child2Id: null,
child2: null,
child3Id: null,
child3: null,
child4Id: null,
child4: null,
node: null,
nodeId: null,
});
2024-04-30 09:22:46 +07:00
const dataEvaluation = ref<any>({
2024-05-09 12:12:58 +07:00
evaluationReqEdit: "NEW",
evaluationStatus: "NEW",
profileId: null,
evaluatorId: null,
commanderId: null,
commanderHighId: null,
2024-04-30 09:22:46 +07:00
plannedPoint: 0,
rolePoint: 0,
specialPoint: 0,
});
2024-04-22 18:14:48 +07:00
const competencyType = ref<DataOptions[]>([
{
id: "HEAD",
name: "สมรรถนะหลัก",
},
{
id: "GROUP",
name: "สมรรถนะประจำกลุ่มงาน",
},
{
id: "EXECUTIVE",
name: "สมรรถนะประจำผู้บริหารกรุงเทพมหานคร",
},
{
id: "DIRECTOR",
name: "สมรรถนะเฉพาะสำหรับตำแหน่ง ผอ.เขต ผช.ผอ.เขต และหัวหน้าฝ่ายในสังกัด สนง.เขต",
},
{
id: "INSPECTOR",
name: "สมรรถนะเฉพาะสำหรับตำแหน่งผู้ตรวจราชการ กทม. และผู้ตรวจราชการ",
},
]);
2024-04-22 18:14:48 +07:00
function convertCompetencyType(val: string) {
const competency = competencyType.value.find(
2024-04-23 11:41:33 +07:00
(x: DataOptions) => x.id == val
2024-04-22 18:14:48 +07:00
);
return competency?.name;
}
function convertStatus(val: string) {
switch (val) {
2024-05-08 18:12:52 +07:00
case "NEW":
return "จัดทำข้อตกลง";
case "NEW_EVALUATOR":
return "รอผู้ประเมินตรวจสอบข้อตกลง";
case "NEW_COMMANDER":
return "รอผู้บังคับบัญชาเหนือขึ้นไปตรวจสอบข้อตกลง";
case "NEW_COMMANDER_HIGH":
return "รอผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่งตรวจสอบข้อตกลง";
case "APPROVE":
return "รายงานความก้าวหน้า";
case "EVALUATING":
return "รายงานผลสำเร็จของงาน";
case "EVALUATING_EVALUATOR":
return "รอผู้ประเมินตรวจสอบผล";
case "EVALUATING_COMMANDER":
return "รอผู้บังคับบัญชาเหนือขึ้นไปตรวจสอบผล";
case "EVALUATING_COMMANDER_HIGH":
return "รอผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่งตรวจสอบผล";
case "COMPLETE":
return "เสร็จสิ้น";
default:
break;
}
}
function convertResults(val: string) {
switch (val) {
case "PENDING":
return "รอดำเนินการ";
case "PASSED":
return "ผ่านการประเมิน";
case "NOTPASSED":
return "ไม่ผ่านการประเมิน";
default:
break;
}
}
function checkCompetency() {
const position = dataProfile.value.position;
const posTypeName = dataProfile.value.posTypeName;
const posLevelName = dataProfile.value.posLevelName;
if (
position == "ผู้ตรวจราชการกรุงเทพมหานคร" ||
position == "ผู้ตรวจราชการ"
) {
competencyType.value = competencyType.value.filter(
(x: DataOptions) => x.id == "HEAD" || x.id == "INSPECTOR"
);
} else if (position == "ผู้อำนวยการเขต") {
competencyType.value = competencyType.value.filter(
(x: DataOptions) => x.id == "HEAD" || x.id == "DIRECTOR"
);
} else {
switch (posTypeName + " " + posLevelName) {
// case "ทั่วไป ปฏิบัติงาน":
// case "ทั่วไป ชำนาญงาน":
// case "ทั่วไป อาวุโส":
// case "วิชาการ ปฏิบัติการ":
// case "วิชาการ ชำนาญการ":
// case "วิชาการ ชำนาญการพิเศษ":
// case "วิชาการ เชี่ยวชาญ":
// case "วิชาการ ทรงคุณวุฒิ":
// competencyType.value = competencyType.value.filter(
// (x: DataOptions) => x.id == "HEAD" || x.id == "GROUP"
// );
// break;
case "อำนวยการ ต้น":
case "อำนวยการ สูง":
case "บริหาร ต้น":
case "บริหาร สูง":
competencyType.value = competencyType.value.filter(
(x: DataOptions) => x.id == "HEAD" || x.id == "EXECUTIVE"
);
break;
default:
competencyType.value = competencyType.value.filter(
(x: DataOptions) => x.id == "HEAD" || x.id == "GROUP"
);
break;
}
}
}
const defaultCompetencyCoreLevel = ref<number>();
const defaultCompetencyGroupLevel = ref<number | null>(null);
function checkCompetencyDefaultCompetencyLevel() {
const posTypeName = dataProfile.value.posTypeName;
const posLevelName = dataProfile.value.posLevelName;
switch (posTypeName + " " + posLevelName) {
case "บริหาร สูง":
defaultCompetencyCoreLevel.value = 5;
break;
case "บริหาร ต้น":
defaultCompetencyCoreLevel.value = 4;
break;
case "อำนวยการ สูง":
defaultCompetencyCoreLevel.value = 4;
break;
case "อำนวยการ ต้น":
defaultCompetencyCoreLevel.value = 3;
break;
case "วิชาการ ทรงคุณวุฒิ":
defaultCompetencyCoreLevel.value = 5;
defaultCompetencyGroupLevel.value = 5;
break;
case "วิชาการ เชี่ยวชาญ":
defaultCompetencyCoreLevel.value = 4;
defaultCompetencyGroupLevel.value = 4;
break;
case "วิชาการ ชำนาญการพิเศษ":
defaultCompetencyCoreLevel.value = 3;
defaultCompetencyGroupLevel.value = 4;
break;
case "วิชาการ ชำนาญการ":
defaultCompetencyCoreLevel.value = 2;
defaultCompetencyGroupLevel.value = 3;
break;
case "วิชาการ ปฏิบัติการ":
defaultCompetencyCoreLevel.value = 1;
defaultCompetencyGroupLevel.value = 2;
break;
case "ทั่วไป ทักษะพิเศษ":
defaultCompetencyCoreLevel.value = 4;
defaultCompetencyGroupLevel.value = 4;
break;
case "ทั่วไป อาวุโส":
defaultCompetencyCoreLevel.value = 3;
defaultCompetencyGroupLevel.value = 3;
break;
case "ทั่วไป ชำนาญงาน":
defaultCompetencyCoreLevel.value = 2;
defaultCompetencyGroupLevel.value = 2;
break;
case "ทั่วไป ปฏิบัติงาน":
defaultCompetencyCoreLevel.value = 1;
defaultCompetencyGroupLevel.value = 1;
break;
default:
break;
}
}
const ratingColors = ref<string[]>([
"light-blue-3",
"light-blue-6",
"blue",
"blue-9",
"blue-10",
]);
2024-05-09 12:12:58 +07:00
// ROLE & TAB
const rolePerson = ref<string>("USER"); //"USER" | "EVALUATOR" | "COMMANDER", "COMMANDERHIGH"
const tabOpen = ref<number>(1);
function checkStep() {
const role =
dataEvaluation.value.profileId == dataProfile.value.profileId
? "USER"
: dataEvaluation.value.evaluatorId == dataProfile.value.profileId
? "EVALUATOR"
: dataEvaluation.value.commanderId == dataProfile.value.profileId
? "COMMANDER"
: dataEvaluation.value.commanderHighId == dataProfile.value.profileId
? "COMMANDERHIGH"
: "";
rolePerson.value = role;
2024-05-08 18:12:52 +07:00
2024-05-09 12:12:58 +07:00
switch (dataEvaluation.value.evaluationStatus) {
case "NEW" || "NEW_EVALUATOR" || "NEW_COMMANDER" || "NEW_COMMANDER_HIGH":
tabOpen.value = 1;
break;
case "APPROVE":
tabOpen.value = 2;
break;
default:
tabOpen.value = 3;
break;
2024-05-08 18:12:52 +07:00
}
}
2024-05-09 12:12:58 +07:00
// SUMMARY GENERAL CASE
const indicatorPercent = ref<number>(100); // รวมผลการประเมิน (ร้อยละ)
const indicatorPercentVal = ref<number>(0); // รวมผลการประเมิน (ร้อยละ) ที่ได้จริง
const indicatorScore = ref<number>(80); // สรุปผลการประเมินผลสัมฤทธิ์ของงาน ( คะแนนเต็ม indicatorScore คะแนน)
const indicatorScoreVal = ref<number>(0); // สรุปผลการประเมินผลสัมฤทธิ์ของงานที่ได้
const competencyScore = ref<number>(20); // ผลการประเมินสมรรถนะ (competencyScore คะแนน)
const competencyScoreVal = ref<number>(0); // ผลการประเมินสมรรถนะที่ได้กี่คะแนน
const devScore = ref<number>(10); // ผลการประเมินการพัฒนาตนเอง (devScore คะแนน)
const devScoreVal = ref<number>(0); // ผลการประเมินการพัฒนาตนเองที่ได้กี่คะแนน
const competencyDevScore = ref<number>(30); // สรุปผลการประเมินพฤติกรรมการปฏิบัติราชการ (สมรรถนะ+การพัฒนาตนเอง) (คะแนนเต็ม competencyDevScore คะแนน)
const competencyDevScoreVal = ref<number>(0); // สรุปผลการประเมินพฤติกรรมการปฏิบัติราชการ (สมรรถนะ+การพัฒนาตนเอง)ที่ได้กี่คะแนน
// SUMMARY EXCLUSIVE CASE
const excusiveIndicatorPercent = ref<number>(100); // รวมผลการประเมิน (ร้อยละ) แต่ละมิติต้องไม่เกิน 100%
const excusiveIndicator1PercentVal = ref<number>(0); // รวมผลการประเมิน (ร้อยละ) มิติที่ 1 ที่ได้จริง
const excusiveIndicator1Weight = ref<number>(60); // น้ำหนักของมิติที่ 1
const excusiveIndicator1ScoreVal = ref<number>(0); // คะแนนมิติที่ 1 ที่ได้จริง
const excusiveIndicator2Weight = ref<number>(20); // น้ำหนักของมิติที่ 2
const excusiveIndicator2PercentVal = ref<number>(0); // รวมผลการประเมิน (ร้อยละ) มิติที่ 2 ที่ได้จริง
const excusiveIndicator2ScoreVal = ref<number>(0); // คะแนนมิติที่ 2 ที่ได้จริง
const excusiveIndicatorScore = ref<number>(80); // สรุปผลการประเมินผลสัมฤทธิ์ของงาน (มิติที่ 1 + มิติที่ 2) ( คะแนนเต็ม excusiveIndicatorScore คะแนน)
const excusiveIndicatorScoreVal = ref<number>(0); // สรุปผลการประเมินผลสัมฤทธิ์ของงาน (มิติที่ 1 + มิติที่ 2) คะแนนที่ได้จริง
const excusiveCompetencyScore = ref<number>(20); // ผลการประเมินสมรรถนะ (competencyScore คะแนน)
const excusiveCompetencyScoreVal = ref<number>(0); // ผลการประเมินสมรรถนะที่ได้กี่คะแนน
2024-04-22 18:14:48 +07:00
return {
tabMain,
dataProfile,
dataEvaluation,
competencyType,
convertCompetencyType,
convertStatus,
convertResults,
checkCompetency,
checkCompetencyDefaultCompetencyLevel,
defaultCompetencyCoreLevel,
defaultCompetencyGroupLevel,
ratingColors,
2024-05-09 12:12:58 +07:00
checkStep,
2024-05-08 18:12:52 +07:00
tabOpen,
2024-05-09 12:12:58 +07:00
rolePerson,
// score
indicatorPercent,
indicatorPercentVal,
indicatorScore,
indicatorScoreVal,
competencyScore,
competencyScoreVal,
devScore,
devScoreVal,
competencyDevScore,
competencyDevScoreVal,
excusiveCompetencyScore,
excusiveCompetencyScoreVal,
excusiveIndicatorPercent,
excusiveIndicator1PercentVal,
excusiveIndicator1Weight,
excusiveIndicator1ScoreVal,
excusiveIndicator2Weight,
excusiveIndicator2PercentVal,
excusiveIndicator2ScoreVal,
excusiveIndicatorScore,
excusiveIndicatorScoreVal,
2024-04-22 18:14:48 +07:00
};
2024-04-04 14:14:25 +07:00
});