import { defineStore } from "pinia"; import { ref, reactive } from "vue"; import type { DataOptions } from "./interface/index/Main"; import type { FormQuery } from "@/modules/08_KPI/interface/request/index"; import type { DataProfile } from "@/interface/Main"; export const useKpiDataStore = defineStore("KPIDate", () => { const mainRowData = ref(); const isUpdate = ref(false); const tabMainevaluator = ref("1"); const yearRound = ref(new Date().getFullYear()); const formQuery = reactive({ page: 1, pageSize: 10, round: "", keyword: "", }); const selected = ref([]); const work = ref(false); const tabMain = ref(""); const dataProfile = ref({ 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, }); const dataEvaluation = ref({ evaluationReqEdit: null, evaluationResults: null, evaluationStatus: null, isOpen: null, profileId: null, evaluatorId: null, commanderId: null, commanderHighId: null, plannedPoint: 0, rolePoint: 0, specialPoint: 0, prefix: "", firstName: "", lastName: "", posExecutiveName: "", posLevelName: "", posTypeName: "", position: "", summaryPoint: 0, totalPoint1: 0, totalPoint2_1: 0, totalPoint2_2: 0, }); const competencyType = ref([ { id: "HEAD", name: "สมรรถนะหลัก", }, { id: "GROUP", name: "สมรรถนะประจำกลุ่มงาน", }, { id: "EXECUTIVE", name: "สมรรถนะประจำผู้บริหารกรุงเทพมหานคร", }, { id: "DIRECTOR", name: "สมรรถนะเฉพาะสำหรับตำแหน่ง ผอ.เขต ผช.ผอ.เขต และหัวหน้าฝ่ายในสังกัด สนง.เขต", }, { id: "INSPECTOR", name: "สมรรถนะเฉพาะสำหรับตำแหน่งผู้ตรวจราชการ กทม. และผู้ตรวจราชการ", }, ]); function convertCompetencyType(val: string) { const competency = competencyType.value.find( (x: DataOptions) => x.id == val ); return competency?.name; } const statusOptions = ref([ { id: "", name: "ทั้งหมด", }, { id: "NEW", name: "จัดทำข้อตกลง", }, { id: "NEW_EVALUATOR", name: "รอผู้ประเมินตรวจสอบข้อตกลง", }, { id: "NEW_COMMANDER", name: "รอผู้บังคับบัญชาเหนือขึ้นไปตรวจสอบข้อตกลง", }, { id: "NEW_COMMANDER_HIGH", name: "รอผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่งตรวจสอบข้อตกลง", }, { id: "APPROVE", name: "รายงานความก้าวหน้า", }, { id: "EVALUATING", name: "รายงานผลสำเร็จของงาน", }, { id: "EVALUATING_EVALUATOR", name: "รอผู้ประเมินตรวจสอบผล", }, { id: "EVALUATING_COMMANDER", name: "รอผู้บังคับบัญชาเหนือขึ้นไปตรวจสอบผล", }, { id: "EVALUATING_COMMANDER_HIGH", name: "รอผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่งตรวจสอบผล", }, { id: "COMPLETE", name: "รอประกาศผลการประเมิน", }, { id: "KP7", name: "ประกาศและลงทะเบียนประวัติแล้ว", }, ]); function convertStatus(val: string) { switch (val) { 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 "SUMMARY": return "สรุปผลการประเมิน"; case "SUMMARY_COMMANDER": return "รอผู้บังคับบัญชาเหนือขึ้นไปตรวจสอบผล"; case "SUMMARY_COMMANDER_HIGH": return "รอผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่งตรวจสอบผล"; case "COMPLETE": return "รอประกาศผลการประเมิน"; case "KP7": return "ประกาศและลงทะเบียนประวัติแล้ว"; default: break; } } const resultsOptions = ref([ { id: "", name: "ทั้งหมด", }, { id: "PENDING", name: "รอดำเนินการ", }, { id: "PASSED", name: "ผ่านการประเมิน", }, { id: "NOTPASSED", name: "ไม่ผ่านการประเมิน", }, { id: "EXCELLENT", name: "ดีเด่น", }, { id: "VERY_GOOD", name: "ดีมาก", }, { id: "GOOD", name: "ดี", }, { id: "FAIR", name: "พอใช้", }, { id: "IMPROVEMENT", name: "ต้องปรับปรุง", }, ]); function convertResults(val: string) { switch (val) { case "EXCELLENT": return "ดีเด่น"; case "VERY_GOOD": return "ดีมาก"; case "GOOD": return "ดี"; case "FAIR": return "พอใช้"; case "IMPROVEMENT": return "ต้องปรับปรุง"; default: return "รอดำเนินการ"; } } const defaultCompetencyCoreLevel = ref(null); const defaultCompetencyGroupLevel = ref(null); function checkCompetencyDefaultCompetencyLevel() { const posTypeName = dataEvaluation.value.posTypeName; const posLevelName = dataEvaluation.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: defaultCompetencyCoreLevel.value = 1; defaultCompetencyGroupLevel.value = 1; break; } } const ratingColors = ref([ "light-blue-3", "light-blue-6", "blue", "blue-9", "blue-10", ]); // ROLE & TAB const rolePerson = ref("USER"); //"USER" | "EVALUATOR" | "COMMANDER", "COMMANDERHIGH" const tabOpen = ref(1); async function checkStep() { const role = await (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; switch (dataEvaluation.value.evaluationStatus) { case "NEW": tabOpen.value = 1; tabMain.value = "1"; break; case "NEW_EVALUATOR": tabOpen.value = 1; tabMain.value = "1"; break; case "NEW_COMMANDER": tabOpen.value = 1; tabMain.value = "1"; break; case "NEW_COMMANDER_HIGH": tabOpen.value = 1; tabMain.value = "1"; break; case "APPROVE": tabOpen.value = 2; tabMain.value = "2"; break; case "EVALUATING": tabOpen.value = 3; tabMain.value = "3"; break; case "EVALUATING_EVALUATOR": tabOpen.value = 3; tabMain.value = "3"; break; case "SUMMARY": tabOpen.value = 4; tabMain.value = "3"; break; case "SUMMARY_COMMANDER": tabOpen.value = 4; tabMain.value = "3"; break; case "SUMMARY_COMMANDER_HIGH": tabOpen.value = 4; tabMain.value = "3"; break; case "COMPLETE": tabOpen.value = 4; tabMain.value = "3"; break; case "KP7": tabOpen.value = 4; tabMain.value = "3"; break; default: tabOpen.value = 1; tabMain.value = "1"; break; } } function roleText(val: string) { switch (val) { case "EVALUATOR": return "ผู้ประเมิน"; case "COMMANDER": return "ผู้บังคับบัญชาเหนือขึ้นไป"; case "COMMANDERHIGH": return "ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง"; } } // SUMMARY GENERAL CASE const indicatorWeightTotal = ref(0); // น้ำหนักรวมกรณีทั่วไป const indicatorWeight1Total = ref(0); // น้ำหนักรวมมิติที่ 1 ต้องไม่เกิน 100% const indicatorWeight2Total = ref(0); // น้ำหนักรวมมิติที่ 2 ต้องไม่เกิน 20 const indicatorPercentVal = ref(0); // รวมผลการประเมิน (ร้อยละ) ที่ได้จริง const indicatorScore = ref(70); // สรุปผลการประเมินผลสัมฤทธิ์ของงาน ( คะแนนเต็ม indicatorScore คะแนน) const competencyScore = ref(20); // ผลการประเมินสมรรถนะ (competencyScore คะแนน) const devScoreVal = ref(0); // ผลการประเมินการพัฒนาตนเองที่ได้กี่คะแนน const competencyDevScore = ref(30); // สรุปผลการประเมินพฤติกรรมการปฏิบัติราชการ (สมรรถนะ+การพัฒนาตนเอง) (คะแนนเต็ม competencyDevScore คะแนน) const devScore = ref(10); // ผลการประเมินการพัฒนาตนเอง (devScore คะแนน) // SUMMARY EXCLUSIVE CASE const excusiveIndicator1PercentVal = ref(0); // รวมผลการประเมิน (ร้อยละ) มิติที่ 1 ที่ได้จริง const excusiveIndicator1Weight = ref(60); // น้ำหนักของมิติที่ 1 const excusiveIndicator1ScoreVal = ref(0); // คะแนนมิติที่ 1 ที่ได้จริง const excusiveIndicator2Weight = ref(20); // น้ำหนักของมิติที่ 2 const excusiveIndicator2PercentVal = ref(0); // รวมผลการประเมิน (ร้อยละ) มิติที่ 2 ที่ได้จริง const excusiveIndicator2ScoreVal = ref(0); // คะแนนมิติที่ 2 ที่ได้จริง const excusiveIndicatorScore = ref(80); // สรุปผลการประเมินผลสัมฤทธิ์ของงาน (มิติที่ 1 + มิติที่ 2) ( คะแนนเต็ม excusiveIndicatorScore คะแนน) const excusiveCompetencyScore = ref(20); // ผลการประเมินสมรรถนะ (competencyScore คะแนน) const indicatorScoreVal = ref(0); // สรุปผลการประเมินผลสัมฤทธิ์ของงานที่ได้ const competencyScoreVal = ref(0); // ผลการประเมินสมรรถนะที่ได้กี่คะแนน const indicatorProbationScore = ref(50); // สรุปผลการประเมินผลสัมฤทธิ์ของงาน ( คะแนนเต็ม indicatorScore คะแนน) const competencyProbationScore = ref(40); // ผลการประเมินสมรรถนะ (competencyScore คะแนน) const devProbationScore = ref(10); // สรุปผลการประเมินพฤติกรรมการปฏิบัติราชการ (สมรรถนะ+การพัฒนาตนเอง) (คะแนนเต็ม competencyDevScore คะแนน) const competencyDevProbationScore = ref(50); // สรุปผลการประเมินพฤติกรรมการปฏิบัติราชการ (สมรรถนะ+การพัฒนาตนเอง) (คะแนนเต็ม competencyDevScore คะแนน) return { tabMain, dataProfile, dataEvaluation, competencyType, convertCompetencyType, convertStatus, convertResults, // checkCompetency, checkCompetencyDefaultCompetencyLevel, defaultCompetencyCoreLevel, defaultCompetencyGroupLevel, ratingColors, checkStep, tabOpen, rolePerson, // score indicatorWeightTotal, indicatorWeight1Total, indicatorWeight2Total, indicatorPercentVal, indicatorScore, indicatorScoreVal, competencyScore, competencyScoreVal, devScore, devScoreVal, competencyDevScore, excusiveCompetencyScore, excusiveIndicator1PercentVal, excusiveIndicator1Weight, excusiveIndicator1ScoreVal, excusiveIndicator2Weight, excusiveIndicator2PercentVal, excusiveIndicator2ScoreVal, excusiveIndicatorScore, // isProbation indicatorProbationScore, competencyProbationScore, devProbationScore, competencyDevProbationScore, //รายการการประเมินผลการปฏิบัติราชการระดับบุคคล tabMainevaluator, formQuery, yearRound, selected, work, isUpdate, mainRowData, resultsOptions, statusOptions, roleText, }; });