255 lines
8.6 KiB
TypeScript
255 lines
8.6 KiB
TypeScript
import { defineStore } from "pinia";
|
|
import { ref } from "vue";
|
|
|
|
/**import Type */
|
|
import type { OptionReport } from "@/modules/07_insignia/interface/index/Main";
|
|
|
|
/**import Stores */
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
/**use Stroe */
|
|
const mixin = useCounterMixin();
|
|
const { date2Thai } = mixin;
|
|
|
|
export const useInsigniaDataStore = defineStore("insignia", () => {
|
|
const roundId = ref<string>("");
|
|
const optionRound = ref<any>([]);
|
|
const isLock = ref<boolean>(false);
|
|
const roleUser = ref<string>("");
|
|
const requestId = ref<string>("");
|
|
const requestStatus = ref<string>("");
|
|
const optionsTypeOc = ref<any>([]);
|
|
const typeOc = ref<string>("");
|
|
const agency = ref<string>("");
|
|
const rows = ref<any[]>([]);
|
|
const listinsignia = ref<any>([]);
|
|
const typeinsignia = ref<string>("all");
|
|
const typeinsigniaOptions = ref<any>([{ id: "all", name: "ทั้งหมด" }]);
|
|
const employeeClass = ref<string>("all");
|
|
const employeeClassOps = ref<any>([
|
|
{ name: "ทั้งหมด", id: "all" },
|
|
{ name: "ข้าราชการ กทม.สามัญ", id: "officer" },
|
|
{ name: "ลูกจ้างประจำ", id: "perm" },
|
|
]);
|
|
|
|
/** option รายงาน */
|
|
const optionReport = ref<OptionReport[]>([
|
|
{
|
|
id: "45",
|
|
title: "บัญชีรายชื่อข้าราชการผู้ขอพระราชทานเครื่องราชอิสริยาภรณ์",
|
|
},
|
|
{ id: "43", title: "บัญชีระดับผลการประเมินผลการปฏิบัติราชการในรอบ 5 ปี" },
|
|
{ id: "44", title: "บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ" },
|
|
]);
|
|
const mainTab = ref<string | undefined>("pending");
|
|
const dataInsigniaType = ref<any>([]);
|
|
|
|
/**
|
|
* Funtioin เรียกข้อมูลรายชื่อข้าราชการสามัญ
|
|
* @param data ข้อมูลรายชื่อข้าราชการสามัญ
|
|
*/
|
|
async function fetchData(data: any) {
|
|
if (data !== null) {
|
|
let datalist = await data.map((e: any) => ({
|
|
id: e.id,
|
|
citizenId: e.citizenId,
|
|
profileId: e.profileId,
|
|
name: e.fullName,
|
|
position: e.position,
|
|
level: e.rank,
|
|
salary: e.salary,
|
|
salary2: Number(e.salary).toLocaleString(),
|
|
insigniaType: e.lastInsignia
|
|
? `${e.lastInsignia} (${
|
|
dataInsigniaType.value.find(
|
|
(item: any) => item.name === e.lastInsignia
|
|
)?.shortName || ""
|
|
})`
|
|
: "-",
|
|
insigniaCheck: e.requestInsignia,
|
|
insigniaSend: e.requestInsignia
|
|
? `${e.requestInsignia} (${
|
|
dataInsigniaType.value.find(
|
|
(item: any) => item.name === e.requestInsignia
|
|
)?.shortName || ""
|
|
})`
|
|
: "",
|
|
insigniaLevel: e.level,
|
|
dateSend: date2Thai(e.requestDate),
|
|
requestNote: e.requestNote,
|
|
employeeType: profileType(e.profileType),
|
|
reason: e.reason,
|
|
markDiscipline: e.markDiscipline,
|
|
markLeave: e.markLeave,
|
|
markRate: e.markRate,
|
|
isApprove: e.isApprove,
|
|
statusMark:
|
|
e.markDiscipline === true ||
|
|
e.markLeave === true ||
|
|
e.markRate === true
|
|
? true
|
|
: false,
|
|
}));
|
|
const item = datalist;
|
|
for (let j = 0; j < item.length; j++) {
|
|
const data = item[j];
|
|
const filteredData = dataInsigniaType.value.find(
|
|
(item: any) => item.name === data.insigniaType
|
|
);
|
|
if (filteredData) {
|
|
data.insigniaType = `${data.insigniaType} (${filteredData.shortName})`;
|
|
} else {
|
|
data.insigniaType = data.insigniaType;
|
|
}
|
|
}
|
|
|
|
rows.value = await datalist;
|
|
listinsignia.value = await item;
|
|
searchDataTable(typeinsignia.value, employeeClass.value);
|
|
filtertypeInsignia();
|
|
} else rows.value = [];
|
|
}
|
|
|
|
/**
|
|
* function เรียกข้อมูลรอบการเสนอขอ
|
|
* @param data ข้อมูลราบการเสนอขอ
|
|
*/
|
|
async function fetchDataInsignia(data: any) {
|
|
isLock.value = data.isLock; // สถานะล็อกข้อมูล
|
|
requestId.value = data.requestId;
|
|
requestStatus.value = data.requestStatus; // สถานะของรอบการเสนอขอ
|
|
}
|
|
|
|
/**
|
|
* funntoin หา option หน่วยงสานทั้งหมด
|
|
* @param op
|
|
*/
|
|
function fetchOption(op: any) {
|
|
const aId = agency.value ?? "00000000-0000-0000-0000-000000000000";
|
|
const hasID = op.find((e: any) => e.id === agency.value);
|
|
|
|
if (aId !== "00000000-0000-0000-0000-000000000000" && hasID) {
|
|
typeOc.value = agency.value;
|
|
optionsTypeOc.value = op;
|
|
} else {
|
|
(optionsTypeOc.value = op), (typeOc.value = op[0].id);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* funcion หาประเภทเครื่องราชทั้งหมดที่อยู่ในรายชื่อข้าราชการสามัญฯ
|
|
*/
|
|
async function filtertypeInsignia() {
|
|
typeinsignia.value = "all";
|
|
if (listinsignia.value.length !== 0) {
|
|
// หาประเภทเครื่องราชที่ขอที่ชื่อซ้ำกัน
|
|
const double_name = [
|
|
...new Set(listinsignia.value.map((item: any) => item.insigniaCheck)),
|
|
];
|
|
typeinsigniaOptions.value = [{ id: "all", name: "ทั้งหมด" }];
|
|
for (let i = 1; i <= double_name.length; i++) {
|
|
const type = double_name[i - 1];
|
|
const filterShortName = dataInsigniaType.value.find(
|
|
(item: any) => item.name === type
|
|
);
|
|
const listtype = {
|
|
id: type,
|
|
name: `${type} (${filterShortName.shortName})`,
|
|
};
|
|
typeinsigniaOptions.value.push(listtype);
|
|
}
|
|
} else typeinsigniaOptions.value = [{ id: "all", name: "ทั้งหมด" }];
|
|
}
|
|
|
|
/**
|
|
* function ค้นหาข้อมมูลรายชื่อ ตาม ประเภทและสถานภาพ
|
|
* @param type ประเภท
|
|
* @param employeeClasstype สถานภาพ
|
|
*/
|
|
async function searchDataTable(type: string, employeeClasstype: string) {
|
|
typeinsignia.value = type;
|
|
employeeClass.value = employeeClasstype;
|
|
if (type !== "all" && employeeClasstype !== "all") {
|
|
rows.value = listinsignia.value.filter(
|
|
(e: any) =>
|
|
e.insigniaCheck === type &&
|
|
e.employeeType === profileType(employeeClasstype)
|
|
);
|
|
} else if (type !== "all" && employeeClasstype === "all") {
|
|
rows.value = listinsignia.value.filter(
|
|
(e: any) => e.insigniaCheck === type
|
|
);
|
|
} else if (type === "all" && employeeClasstype !== "all") {
|
|
rows.value = listinsignia.value.filter(
|
|
(e: any) => e.employeeType === profileType(employeeClasstype)
|
|
);
|
|
} else if (type === "all" && employeeClasstype === "all") {
|
|
rows.value = listinsignia.value;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* function เรียกประเภทเครื่องราช
|
|
* @param data ประเภทเครื่องราชทั้งหมด
|
|
*/
|
|
function fetchInsigniaType(data: any) {
|
|
dataInsigniaType.value = data;
|
|
}
|
|
|
|
/**
|
|
* Function convert ประเภทลูกจ้าง
|
|
* @param val ประเภทลูกจ้าง
|
|
*/
|
|
function profileType(val: string) {
|
|
switch (val) {
|
|
case "officer":
|
|
return "ข้าราชการ กทม.สามัญ";
|
|
case "employee":
|
|
return "ลูกจ้างประจำ";
|
|
case "perm":
|
|
return "ลูกจ้างประจำ";
|
|
case "temp":
|
|
return "ลูกจ้างประจำ";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* function convert สถานะ
|
|
* @param val สถานะ
|
|
*/
|
|
function convertStatus(val: string) {
|
|
switch (val) {
|
|
case "WAITTING":
|
|
return "สร้างรอบ";
|
|
case "PENDING":
|
|
return "กำลังดำเนินการ";
|
|
case "DONE":
|
|
return "เสร็จสิ้น";
|
|
}
|
|
}
|
|
|
|
return {
|
|
roundId,
|
|
optionRound,
|
|
optionsTypeOc,
|
|
mainTab,
|
|
typeOc,
|
|
rows,
|
|
typeinsigniaOptions,
|
|
typeinsignia,
|
|
agency,
|
|
fetchData,
|
|
fetchOption,
|
|
searchDataTable,
|
|
employeeClass,
|
|
employeeClassOps,
|
|
fetchDataInsignia,
|
|
fetchInsigniaType,
|
|
isLock,
|
|
requestId,
|
|
roleUser,
|
|
requestStatus,
|
|
optionReport,
|
|
convertStatus,
|
|
dataInsigniaType,
|
|
};
|
|
});
|