filter เครื่องราชตามสถานภาพ

This commit is contained in:
Kittapath 2023-09-25 20:59:57 +07:00
parent 44f43d2f6f
commit 1b81f529ba

View file

@ -6,12 +6,12 @@ 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 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>("");
@ -20,11 +20,15 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
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 employeeClassOps = ref<any>([
{ name: "ทั้งหมด", id: "all" },
{ name: "ข้าราชการ กทม.สามัญ", id: "officer" },
{ name: "ลูกจ้างประจำ", id: "perm" },
]);
const typeReport = ref<string>("");
const titleReport = ref<string>("");
const mainTab = ref<string | undefined>('pending');
const mainTab = ref<string | undefined>("pending");
const setTypeandTitle = (type: string, title: string) => {
typeReport.value = type;
@ -49,9 +53,9 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
requestNote: e.requestNote,
employeeType: profileType(e.profileType),
}));
rows.value = await datalist
rows.value = await datalist;
listinsignia.value = await datalist;
searchDataTable(typeinsignia.value, employeeClass.value)
searchDataTable(typeinsignia.value, employeeClass.value);
filtertypeInsignia();
} else rows.value = [];
};
@ -60,7 +64,7 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
isLock.value = data.isLock; // สถานะล็อกข้อมูล
requestId.value = data.requestId;
requestStatus.value = data.requestStatus; // สถานะของรอบการเสนอขอ
}
};
// เรียก Option หน่วยงานทั้งหมด
const fetchOption = (op: any) => {
if (agency.value !== null) {
@ -91,18 +95,26 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
};
// ค้นหาข้อมมูลราชชื่อ ตาม ประเท๓และสถานภาพ
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
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) => {
@ -111,8 +123,12 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
return "ข้าราชการ กทม.สามัญ";
case "employee":
return "ลูกจ้างประจำ";
case "perm":
return "ลูกจ้างประจำ";
case "temp":
return "ลูกจ้างประจำ";
}
}
};
return {
roundId,