filter เครื่องราช

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-09-15 17:22:58 +07:00
parent e8abe74e45
commit 7c2ce06998
2 changed files with 33 additions and 11 deletions

View file

@ -8,6 +8,8 @@ const {
} = mixin;
export const useAllocateDataStore = defineStore("insigniaallocate", () => {
const roundId = ref<string>('')
const roundYear = ref<number>()
const insigniaName = ref<string>('')
const insignia = ref<string>('')
const insigniaOp = ref<any[]>([{ name: "ทั้งหมด", id: "", type: "" }])
@ -17,7 +19,7 @@ export const useAllocateDataStore = defineStore("insigniaallocate", () => {
const mainTab = ref<string>("")
const fetchDatainsignia = async (data: any) => {
insignia.value = ''
// insignia.value = ''
insigniaOp.value = [{ name: "ทั้งหมด", id: "", type: "" }]
data.forEach((e: any) => {
insigniaOp.value.push({ name: e.name, id: e.id, type: e.insigniaType.id })
@ -41,9 +43,10 @@ export const useAllocateDataStore = defineStore("insigniaallocate", () => {
}))
rows.value = list
listInsignia.value = list
selectInsignia(insignia.value)
}
const selectInsignia = () => {
console.log(insignia.value);
const selectInsignia = (type: string) => {
insignia.value = type
if (insignia.value !== "") {
rows.value = listInsignia.value.filter((e: any) => e.insigniaId === insignia.value)
} else rows.value = listInsignia.value
@ -58,6 +61,8 @@ export const useAllocateDataStore = defineStore("insigniaallocate", () => {
}
}
return {
roundId,
roundYear,
rows,
insignia,
insigniaOp,