api เครื่องราชฯ ส่วนจัดการ
This commit is contained in:
parent
8f16fadeea
commit
7bac2037be
6 changed files with 179 additions and 357 deletions
|
|
@ -1,9 +1,73 @@
|
|||
import { defineStore } from "pinia";
|
||||
import { ref, } from "vue";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
date2Thai
|
||||
} = mixin;
|
||||
|
||||
|
||||
export const useInsigniaDataStore = defineStore("insignia", () => {
|
||||
let optionsTypeOc = ref<any>([]);
|
||||
let typeOc = ref<string>("")
|
||||
let rows = ref<any>([])
|
||||
const listinsignia = ref<any>([])
|
||||
const typeinsigniaValues: Set<number> = new Set();
|
||||
const typeinsignia = ref<number | string>("all");
|
||||
let typeinsigniaOptions = ref<any>([{ id: "all", name: "ทั้งหมด" }]);
|
||||
|
||||
|
||||
const fetchData = async (data: any) => {
|
||||
if (data !== null) {
|
||||
rows.value = await data.map((e: any) =>
|
||||
({
|
||||
id: e.id,
|
||||
profileId: e.profileId,
|
||||
name: e.fullName,
|
||||
position: e.position,
|
||||
level: e.rank,
|
||||
salary2: e.salary,
|
||||
salary: Number(e.salary).toLocaleString(),
|
||||
insigniaType: e.lastInsignia,
|
||||
insigniaSend: e.requestInsignia,
|
||||
insigniaLevel: e.level,
|
||||
dateSend: date2Thai(e.requestDate),
|
||||
}))
|
||||
listinsignia.value = await rows.value
|
||||
filtertypeInsignia()
|
||||
} else rows.value = []
|
||||
|
||||
|
||||
}
|
||||
const filtertypeInsignia = async () => {
|
||||
typeinsignia.value = "all"
|
||||
for (const data of listinsignia.value) {
|
||||
const Type = data.insigniaType;
|
||||
if (Type !== null && !typeinsigniaValues.has(Type)) {
|
||||
typeinsigniaOptions.value.push({ id: Type, name: Type })
|
||||
typeinsigniaValues.add(Type);
|
||||
}
|
||||
}
|
||||
};
|
||||
const searchFilterTable = async () => {
|
||||
if (typeinsignia.value !== undefined && typeinsignia.value !== null) {
|
||||
if (typeinsignia.value === "all") {
|
||||
rows.value = listinsignia.value;
|
||||
} else {
|
||||
rows.value = listinsignia.value.filter(
|
||||
(e: any) => e.insigniaType === typeinsignia.value
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
return {
|
||||
optionsTypeOc
|
||||
optionsTypeOc,
|
||||
typeOc,
|
||||
rows,
|
||||
typeinsigniaOptions,
|
||||
typeinsignia,
|
||||
fetchData,
|
||||
searchFilterTable,
|
||||
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue