163 lines
5.9 KiB
TypeScript
163 lines
5.9 KiB
TypeScript
import { defineStore } from "pinia";
|
|
import { ref } from "vue";
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
|
|
const mixin = useCounterMixin();
|
|
const { date2Thai } = mixin;
|
|
|
|
export const useInsigniaDataStore = defineStore("insignia", () => {
|
|
interface OptionReport {
|
|
id: string;
|
|
title: string;
|
|
}
|
|
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>("");
|
|
let optionsTypeOc = ref<any>([]);
|
|
let typeOc = ref<string>("");
|
|
const agency = ref<string>("");
|
|
let rows = ref<any>([]);
|
|
const listinsignia = ref<any>([]);
|
|
const typeinsignia = ref<string>("all");
|
|
let typeinsigniaOptions = ref<any>([{ id: "all", name: "ทั้งหมด" }]);
|
|
const employeeClass = ref<string>("all");
|
|
const employeeClassOps = ref<any>([
|
|
{ name: "ทั้งหมด", id: "all" },
|
|
{ name: "ข้าราชการ กทม.สามัญ", id: "officer" },
|
|
{ name: "ลูกจ้างประจำ", id: "perm" },
|
|
]);
|
|
|
|
//รางาน
|
|
const optionReport = ref<OptionReport[]>([
|
|
{ id: '45', title: "บัญชีรายชื่อข้าราชการผู้ขอพระราชทานเครื่องราชอิสริยาภรณ์" },
|
|
{ id: '43', title: 'บัญชีระดับผลการประเมินผลการปฏิบัติราชการในรอบ 5 ปี' },
|
|
{ id: '44', title: 'บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ' }
|
|
])
|
|
|
|
|
|
|
|
const mainTab = ref<string | undefined>("pending");
|
|
|
|
|
|
// เรียกราชชื่อการเสนอขอ
|
|
const fetchData = async (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,
|
|
insigniaSend: e.requestInsignia,
|
|
insigniaLevel: e.level,
|
|
dateSend: date2Thai(e.requestDate),
|
|
requestNote: e.requestNote,
|
|
employeeType: profileType(e.profileType),
|
|
}));
|
|
rows.value = await datalist;
|
|
listinsignia.value = await datalist;
|
|
searchDataTable(typeinsignia.value, employeeClass.value);
|
|
filtertypeInsignia();
|
|
} else rows.value = [];
|
|
};
|
|
// เรียกข้อมูลรอบการเสนอขอ
|
|
const fetchDataInsignia = async (data: any) => {
|
|
isLock.value = data.isLock; // สถานะล็อกข้อมูล
|
|
requestId.value = data.requestId;
|
|
requestStatus.value = data.requestStatus; // สถานะของรอบการเสนอขอ
|
|
};
|
|
// เรียก Option หน่วยงานทั้งหมด
|
|
const fetchOption = (op: any) => {
|
|
if (agency.value !== null) {
|
|
typeOc.value = agency.value;
|
|
optionsTypeOc.value = op.filter((e: any) => e.id == agency.value);
|
|
} else {
|
|
(optionsTypeOc.value = op), (typeOc.value = op[2].id);
|
|
}
|
|
};
|
|
// หาประเภทเครื่องราชทั้งหมดที่อยู่ในรายชื่อข้าราชการสามัญฯ
|
|
const filtertypeInsignia = async () => {
|
|
typeinsignia.value = "all";
|
|
if (listinsignia.value.length !== 0) {
|
|
// หาประเภทเครื่องราชที่ขอที่ชื่อซ้ำกัน
|
|
const double_name = [
|
|
...new Set(listinsignia.value.map((item: any) => item.insigniaSend)),
|
|
];
|
|
typeinsigniaOptions.value = [{ id: "all", name: "ทั้งหมด" }];
|
|
for (let i = 1; i <= double_name.length; i++) {
|
|
const type = double_name[i - 1];
|
|
const listtype = {
|
|
id: type,
|
|
name: type,
|
|
};
|
|
typeinsigniaOptions.value.push(listtype);
|
|
}
|
|
} else typeinsigniaOptions.value = [{ id: "all", name: "ทั้งหมด" }];
|
|
};
|
|
// ค้นหาข้อมมูลราชชื่อ ตาม ประเท๓และสถานภาพ
|
|
const searchDataTable = async (type: string, employeeClasstype: string) => {
|
|
typeinsignia.value = type;
|
|
employeeClass.value = employeeClasstype;
|
|
if (type !== "all" && employeeClasstype !== "all") {
|
|
rows.value = listinsignia.value.filter(
|
|
(e: any) =>
|
|
e.insigniaSend === type &&
|
|
e.employeeType === profileType(employeeClasstype)
|
|
);
|
|
} else if (type !== "all" && employeeClasstype === "all") {
|
|
rows.value = listinsignia.value.filter(
|
|
(e: any) => e.insigniaSend === 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;
|
|
}
|
|
};
|
|
|
|
// ประเภทลูกจ้าง
|
|
const profileType = (val: string) => {
|
|
switch (val) {
|
|
case "officer":
|
|
return "ข้าราชการ กทม.สามัญ";
|
|
case "employee":
|
|
return "ลูกจ้างประจำ";
|
|
case "perm":
|
|
return "ลูกจ้างประจำ";
|
|
case "temp":
|
|
return "ลูกจ้างประจำ";
|
|
}
|
|
};
|
|
|
|
return {
|
|
roundId,
|
|
optionRound,
|
|
optionsTypeOc,
|
|
mainTab,
|
|
typeOc,
|
|
rows,
|
|
typeinsigniaOptions,
|
|
typeinsignia,
|
|
agency,
|
|
fetchData,
|
|
fetchOption,
|
|
searchDataTable,
|
|
employeeClass,
|
|
employeeClassOps,
|
|
fetchDataInsignia,
|
|
isLock,
|
|
requestId,
|
|
roleUser,
|
|
requestStatus,
|
|
optionReport,
|
|
};
|
|
});
|