diff --git a/src/modules/07_insignia/components/5_Borrow/Main.vue b/src/modules/07_insignia/components/5_Borrow/Main.vue index 036f729b7..9543979e6 100644 --- a/src/modules/07_insignia/components/5_Borrow/Main.vue +++ b/src/modules/07_insignia/components/5_Borrow/Main.vue @@ -288,34 +288,11 @@ watch(tab, async () => { fecthlistInsignia(); }); -const selectorInsignia = async () => { - const dataCopy = await DataStore.listInsignia; - rows.value = - DataStore.insignia != "" - ? dataCopy.filter((x: any) => x.requestInsigniaId == DataStore.insignia) - : dataCopy; -}; -const selectEmployeeClass = async (employeeClass: string) => { - if (employeeClass == "officer") { - let list = DataStore.listInsignia.filter( - (e: any) => e.employeeType === "ข้าราชการ กทม.สามัญ" - ); - rows.value = list; - } else if (employeeClass === "perm") { - let list = DataStore.listInsignia.filter( - (e: any) => e.employeeType === "ลูกจ้างประจำ" - ); - rows.value = list; - } else rows.value = DataStore.listInsignia; -}; - const yearRound = ref(); const selectorRound = async (round: number) => { roundYear.value = round; await fecthlistInsignia(); }; - -const rows = ref([]); const fecthlistInsignia = async () => { showLoader(); await http @@ -324,7 +301,6 @@ const fecthlistInsignia = async () => { ) .then(async (res) => { await DataStore.fetchlistinsignia(res.data.result); - rows.value = DataStore.rows; }) .catch((err) => { messageError($q, err); @@ -441,7 +417,12 @@ const paginationLabel = (start: number, end: number, total: number) => { :readonly="false" :borderless="false" style="min-width: 150px" - @update:model-value="selectorInsignia" + @update:model-value=" + DataStore.searchDatatable( + DataStore.insignia, + DataStore.employeeClass + ) + " />
@@ -461,7 +442,10 @@ const paginationLabel = (start: number, end: number, total: number) => { :borderless="false" style="min-width: 150px" @update:model-value=" - selectEmployeeClass(DataStore.employeeClass) + DataStore.searchDatatable( + DataStore.insignia, + DataStore.employeeClass + ) " />
@@ -521,7 +505,7 @@ const paginationLabel = (start: number, end: number, total: number) => { { })); rows.value = list listInsignia.value = list - // selectInvoice(invoiceType.value) + searchDatatable(insignia.value, employeeClass.value) + } + const searchDatatable = (type: string, employeeClass: string) => { + if (type !== '' && employeeClass !== "all") { + rows.value = listInsignia.value.filter((e: any) => e.requestInsigniaId == type && e.profileType == employeeClass + ) + } else if (type !== '' && employeeClass == "all") { + rows.value = listInsignia.value.filter((e: any) => e.requestInsigniaId == type + ) + } else if (type == '' && employeeClass !== "all") { + rows.value = listInsignia.value.filter((e: any) => e.profileType == employeeClass + ) + } } const status = (val: string) => { @@ -89,5 +101,6 @@ export const useBrrowDataStore = defineStore("insigniaBrrow", () => { fetchDataInsignia, profileType, fetchlistinsignia, + searchDatatable, }; });