filter จัดการคำขอ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-09-07 09:33:04 +07:00
parent 74f4f8991b
commit 682fbd165d
4 changed files with 42 additions and 51 deletions

View file

@ -607,7 +607,12 @@ const paginationLabel2 = (start: number, end: number, total: number) => {
:outlined="true"
:hide-dropdown-icon="false"
style="min-width: 150px"
@update:model-value="DataStore.searchFilterTable"
@update:model-value="
DataStore.searchDataTable(
DataStore.typeinsignia,
DataStore.employeeClass
)
"
/>
<div>
<q-select
@ -626,7 +631,10 @@ const paginationLabel2 = (start: number, end: number, total: number) => {
:borderless="false"
style="min-width: 150px"
@update:model-value="
DataStore.selectEmployeeClass(DataStore.employeeClass)
DataStore.searchDataTable(
DataStore.typeinsignia,
DataStore.employeeClass
)
"
/>
</div>

View file

@ -246,7 +246,12 @@ const closeReson = () => {
:outlined="true"
:hide-dropdown-icon="false"
style="min-width: 150px"
@update:model-value="DataStore.searchFilterTable"
@update:model-value="
DataStore.searchDataTable(
DataStore.typeinsignia,
DataStore.employeeClass
)
"
/>
<div>
<q-select
@ -265,7 +270,10 @@ const closeReson = () => {
:borderless="false"
style="min-width: 150px"
@update:model-value="
DataStore.selectEmployeeClass(DataStore.employeeClass)
DataStore.searchDataTable(
DataStore.typeinsignia,
DataStore.employeeClass
)
"
/>
</div>

View file

@ -243,7 +243,12 @@ const closeReson = () => {
:outlined="true"
:hide-dropdown-icon="false"
style="min-width: 150px"
@update:model-value="DataStore.searchFilterTable"
@update:model-value="
DataStore.searchDataTable(
DataStore.typeinsignia,
DataStore.employeeClass
)
"
/>
<div>
<q-select
@ -262,7 +267,10 @@ const closeReson = () => {
:borderless="false"
style="min-width: 150px"
@update:model-value="
DataStore.selectEmployeeClass(DataStore.employeeClass)
DataStore.searchDataTable(
DataStore.typeinsignia,
DataStore.employeeClass
)
"
/>
</div>

View file

@ -15,7 +15,7 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
const agency = ref<string>("");
let rows = ref<any>([]);
const listinsignia = ref<any>([]);
const typeinsignia = ref<number | string>("all");
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" }])
@ -48,6 +48,7 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
}));
rows.value = await datalist
listinsignia.value = await datalist;
searchDataTable(typeinsignia.value, employeeClass.value)
filtertypeInsignia();
} else rows.value = [];
};
@ -77,53 +78,20 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
id: type,
name: type,
};
// typeinsigniaOptions.value = [{ id: "all", name: "ทั้งหมด" }]
typeinsigniaOptions.value.push(listtype);
}
} else typeinsigniaOptions.value = [{ id: "all", name: "ทั้งหมด" }];
};
const searchDataTable = async (type: string, employeeClass: string) => {
if (type !== 'all' && employeeClass !== 'all') {
rows.value = listinsignia.value.filter((e: any) => e.insigniaType === type && e.employeeType === profileType(employeeClass))
} else if (type !== 'all' && employeeClass === 'all') {
rows.value = listinsignia.value.filter((e: any) => e.insigniaType === type)
} else if (type === 'all' && employeeClass !== 'all') {
rows.value = listinsignia.value.filter((e: any) => e.employeeType === profileType(employeeClass))
}
const searchFilterTable = async () => {
console.log(employeeClass.value);
if (employeeClass.value === "all") {
if (typeinsignia.value !== undefined && typeinsignia.value !== null) {
if (typeinsignia.value === "all") {
rows.value = listinsignia.value;
} else {
rows.value = listinsignia.value.filter(
(e: any) => e.insigniaSend === typeinsignia.value
);
}
}
} else {
if (typeinsignia.value !== undefined && typeinsignia.value !== null) {
if (typeinsignia.value === "all") {
rows.value = listinsignia.value.filter((e: any) => e.employeeType === profileType(employeeClass.value))
} else {
rows.value = listinsignia.value.filter(
(e: any) => e.insigniaSend === typeinsignia.value && e.employeeType === profileType(employeeClass.value)
);
}
}
}
};
const selectEmployeeClass = (employeeClass: string) => {
if (typeinsignia.value !== "all") {
if (employeeClass !== "all") {
let list = listinsignia.value.filter((e: any) => e.employeeType === profileType(employeeClass) && e.insigniaSend === typeinsignia.value)
rows.value = list
} else {
let list = listinsignia.value.filter((e: any) => e.insigniaSend === typeinsignia.value)
rows.value = list
}
} else if (typeinsignia.value == "all") {
if (employeeClass !== "all") {
let list = listinsignia.value.filter((e: any) => e.employeeType === profileType(employeeClass))
rows.value = list
} else {
rows.value = listinsignia.value
}
}
}
const convertOcid = (oc: string) => {
let ocdata = optionsTypeOc.value.find((e: any) => e.name === oc)
@ -149,12 +117,11 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
agency,
fetchData,
fetchOption,
searchFilterTable,
searchDataTable,
setTypeandTitle,
convertOcid,
typeReport,
titleReport,
selectEmployeeClass,
employeeClass,
employeeClassOps,
fetchDataInsignia,