ปรับ จัดการคำขอ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-08-23 10:13:32 +07:00
parent 085373593b
commit 393f94297e
5 changed files with 99 additions and 191 deletions

View file

@ -11,6 +11,7 @@ const {
export const useInsigniaDataStore = defineStore("insignia", () => {
let optionsTypeOc = ref<any>([]);
let typeOc = ref<string>("")
const agency = ref<string>('')
let rows = ref<any>([])
const listinsignia = ref<any>([])
const typeinsignia = ref<number | string>("all");
@ -36,6 +37,17 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
listinsignia.value = await rows.value
filtertypeInsignia()
} else rows.value = []
}
const fetchOption = (op: any) => {
console.log(agency.value);
console.log(op);
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 }
console.log(optionsTypeOc.value);
}
@ -45,16 +57,19 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
const double_name = [
...new Set(listinsignia.value.map((item: any) => item.insigniaType)),
];
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 = [{ id: "all", name: "ทั้งหมด" }]
typeinsigniaOptions.value.push(listtype)
}
} else typeinsigniaOptions.value = [{ id: "all", name: "ทั้งหมด" }]
};
const searchFilterTable = async () => {
if (typeinsignia.value !== undefined && typeinsignia.value !== null) {
if (typeinsignia.value === "all") {
@ -73,7 +88,9 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
rows,
typeinsigniaOptions,
typeinsignia,
agency,
fetchData,
fetchOption,
searchFilterTable,
};
});