410 lines
15 KiB
TypeScript
410 lines
15 KiB
TypeScript
import { defineStore } from "pinia";
|
|
import { ref, reactive } from "vue";
|
|
import type { DataOption } from "@/modules/14_KPI/interface/index/Main";
|
|
import type { FormQuery } from "@/modules/14_KPI/interface/request/index";
|
|
|
|
export const useKpiDataStore = defineStore("KPIDataAdmin", () => {
|
|
const tabMainevaluator = ref<string>("1");
|
|
const yearRound = ref<number>(new Date().getFullYear());
|
|
const formQuery = reactive<FormQuery>({
|
|
page: 1,
|
|
pageSize: 10,
|
|
round: "",
|
|
keyword: "",
|
|
});
|
|
const selected = ref([]);
|
|
const isUpdate = ref<boolean>(false);
|
|
const tabMain = ref<string>("1");
|
|
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,
|
|
});
|
|
|
|
const dataEvaluation = ref<any>({
|
|
evaluationReqEdit: null,
|
|
evaluationStatus: null,
|
|
profileId: null,
|
|
evaluatorId: null,
|
|
commanderId: null,
|
|
commanderHighId: null,
|
|
plannedPoint: 0,
|
|
rolePoint: 0,
|
|
specialPoint: 0,
|
|
});
|
|
|
|
const competencyType = ref<any[]>([
|
|
{
|
|
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: DataOption) => x.id == val
|
|
);
|
|
return competency?.name;
|
|
}
|
|
|
|
const statusOptions = ref<DataOption[]>([
|
|
{
|
|
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: "เสร็จสิ้น",
|
|
},
|
|
]);
|
|
|
|
function convertStatus(val: string) {
|
|
return statusOptions.value.find((x: DataOption) => x.id == val)?.name;
|
|
}
|
|
|
|
function convertResults(val: string) {
|
|
switch (val) {
|
|
case "PENDING":
|
|
return "รอดำเนินการ";
|
|
case "PASSED":
|
|
return "ผ่านการประเมิน";
|
|
case "NOTPASSED":
|
|
return "ไม่ผ่านการประเมิน";
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
function checkCompetency() {
|
|
const position = dataEvaluation.value.position;
|
|
const posTypeName = dataEvaluation.value.posTypeName;
|
|
const posLevelName = dataEvaluation.value.posLevelName;
|
|
const executiveName = dataEvaluation.value.posExecutiveName;
|
|
|
|
if (
|
|
position == "ผู้ตรวจราชการกรุงเทพมหานคร" ||
|
|
position == "ผู้ตรวจราชการ"
|
|
) {
|
|
competencyType.value = competencyType.value.filter(
|
|
(x: DataOption) => x.id == "HEAD" || x.id == "INSPECTOR"
|
|
);
|
|
} else if (position == "ผู้อำนวยการเขต") {
|
|
competencyType.value = competencyType.value.filter(
|
|
(x: DataOption) => x.id == "HEAD" || x.id == "DIRECTOR"
|
|
);
|
|
} else {
|
|
if (executiveName == null) {
|
|
competencyType.value = competencyType.value.filter(
|
|
(x: DataOption) => x.id == "HEAD" || x.id == "GROUP"
|
|
);
|
|
} else {
|
|
competencyType.value = competencyType.value.filter(
|
|
(x: DataOption) => x.id == "HEAD" || x.id == "EXECUTIVE"
|
|
);
|
|
}
|
|
// switch (posTypeName + " " + posLevelName) {
|
|
// // case "ทั่วไป ปฏิบัติงาน":
|
|
// // case "ทั่วไป ชำนาญงาน":
|
|
// // case "ทั่วไป อาวุโส":
|
|
// // case "วิชาการ ปฏิบัติการ":
|
|
// // case "วิชาการ ชำนาญการ":
|
|
// // case "วิชาการ ชำนาญการพิเศษ":
|
|
// // case "วิชาการ เชี่ยวชาญ":
|
|
// // case "วิชาการ ทรงคุณวุฒิ":
|
|
// // competencyType.value = competencyType.value.filter(
|
|
// // (x: DataOption) => x.id == "HEAD" || x.id == "GROUP"
|
|
// // );
|
|
// // break;
|
|
// case "อำนวยการ ต้น":
|
|
// case "อำนวยการ สูง":
|
|
// case "บริหาร ต้น":
|
|
// case "บริหาร สูง":
|
|
// competencyType.value = competencyType.value.filter(
|
|
// (x: DataOption) => x.id == "HEAD" || x.id == "EXECUTIVE"
|
|
// );
|
|
// break;
|
|
// default:
|
|
// competencyType.value = competencyType.value.filter(
|
|
// (x: DataOption) => x.id == "HEAD" || x.id == "GROUP"
|
|
// );
|
|
// break;
|
|
// }
|
|
}
|
|
}
|
|
|
|
const defaultCompetencyCoreLevel = ref<number>();
|
|
const defaultCompetencyGroupLevel = ref<number | null>(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<string[]>([
|
|
"light-blue-3",
|
|
"light-blue-6",
|
|
"blue",
|
|
"blue-9",
|
|
"blue-10",
|
|
]);
|
|
|
|
// ROLE & TAB
|
|
const rolePerson = ref<string>("USER"); //"USER" | "EVALUATOR" | "COMMANDER", "COMMANDERHIGH"
|
|
const tabOpen = ref<number>(1);
|
|
function checkStep() {
|
|
// const role =
|
|
// dataEvaluation.value.profileId == 'USER'
|
|
rolePerson.value = "USER";
|
|
|
|
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 = "4";
|
|
break;
|
|
default:
|
|
tabOpen.value = 1;
|
|
tabMain.value = "1";
|
|
break;
|
|
}
|
|
}
|
|
|
|
// SUMMARY GENERAL CASE
|
|
const indicatorWeightTotal = ref<number>(0); // น้ำหนักรวมกรณีทั่วไป
|
|
const indicatorWeight1Total = ref<number>(0); // น้ำหนักรวมมิติที่ 1 ต้องไม่เกิน 100%
|
|
const indicatorWeight2Total = ref<number>(0); // น้ำหนักรวมมิติที่ 2 ต้องไม่เกิน 20
|
|
|
|
const indicatorPercentVal = ref<number>(0); // รวมผลการประเมิน (ร้อยละ) ที่ได้จริง
|
|
const indicatorScore = ref<number>(70); // สรุปผลการประเมินผลสัมฤทธิ์ของงาน ( คะแนนเต็ม indicatorScore คะแนน)
|
|
const competencyScore = ref<number>(20); // ผลการประเมินสมรรถนะ (competencyScore คะแนน)
|
|
const devScoreVal = ref<number>(0); // ผลการประเมินการพัฒนาตนเองที่ได้กี่คะแนน
|
|
const competencyDevScore = ref<number>(30); // สรุปผลการประเมินพฤติกรรมการปฏิบัติราชการ (สมรรถนะ+การพัฒนาตนเอง) (คะแนนเต็ม competencyDevScore คะแนน)
|
|
const devScore = ref<number>(10); // ผลการประเมินการพัฒนาตนเอง (devScore คะแนน)
|
|
|
|
// SUMMARY EXCLUSIVE CASE
|
|
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 excusiveCompetencyScore = ref<number>(20); // ผลการประเมินสมรรถนะ (competencyScore คะแนน)
|
|
|
|
const indicatorScoreVal = ref<number>(0); // สรุปผลการประเมินผลสัมฤทธิ์ของงานที่ได้
|
|
const competencyScoreVal = ref<number>(0); // ผลการประเมินสมรรถนะที่ได้กี่คะแนน
|
|
|
|
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,
|
|
|
|
//รายการการประเมินผลการปฏิบัติราชการระดับบุคคล
|
|
tabMainevaluator,
|
|
formQuery,
|
|
yearRound,
|
|
selected,
|
|
statusOptions,
|
|
isUpdate,
|
|
};
|
|
});
|