From 1f80bda5ff1db37ac3d8e5e343915d4f906f8528 Mon Sep 17 00:00:00 2001 From: waruneeta Date: Wed, 27 Dec 2023 13:51:40 +0700 Subject: [PATCH] =?UTF-8?q?fix=20select=20filter=20=E0=B8=A3=E0=B8=B0?= =?UTF-8?q?=E0=B8=9A=E0=B8=9A=E0=B8=A5=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../09_leave/components/2_Leave/Tab1.vue | 39 +++++++++++------- .../09_leave/components/2_Leave/Tab2.vue | 41 +++++++++++-------- .../components/2_Leave/ToolBarLeave.vue | 12 +++--- 3 files changed, 55 insertions(+), 37 deletions(-) diff --git a/src/modules/09_leave/components/2_Leave/Tab1.vue b/src/modules/09_leave/components/2_Leave/Tab1.vue index 17fe59967..c675aff02 100644 --- a/src/modules/09_leave/components/2_Leave/Tab1.vue +++ b/src/modules/09_leave/components/2_Leave/Tab1.vue @@ -22,7 +22,6 @@ const mixin = useCounterMixin(); const leaveStore = useLeavelistDataStore(); const { date2Thai, dateToISO, showLoader, hideLoader, messageError } = mixin; -const { fetchListLeave } = leaveStore; const $q = useQuasar(); //ใช้ noti quasar @@ -39,20 +38,29 @@ const maxPage = ref(1); //** เรียกข้อมูลจาก API*/ async function fecthLeaveList() { - showLoader(); - await http - .post(config.API.leaveList(), querySting) - .then((res) => { - const data = res.data.result; - maxPage.value = Math.ceil(data.total / querySting.pageSize); - fetchListLeave(data.data); /** ส่งข้อมูลไป stores*/ - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); + querySting.status = await (querySting.status == null + ? "ALL" + : querySting.status); + querySting.type = await (querySting.type == null + ? "00000000-0000-0000-0000-000000000000" + : querySting.type); + + if (querySting.status != null && querySting.type != null) { + showLoader(); + await http + .post(config.API.leaveList(), querySting) + .then((res) => { + const data = res.data.result; + maxPage.value = Math.ceil(data.total / querySting.pageSize); + leaveStore.fetchListLeave(data.data); /** ส่งข้อมูลไป stores*/ + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); + } // const data = APIDATA.data; // maxPage.value = Math.ceil(data.length / querySting.pageSize); } @@ -74,6 +82,7 @@ async function updatePaging( querySting.page = newPage; querySting.pageSize = pageSize ? pageSize : querySting.pageSize; querySting.keyword = dateFilter ? dateFilter.keyword : querySting.keyword; + await fecthLeaveList(); } diff --git a/src/modules/09_leave/components/2_Leave/Tab2.vue b/src/modules/09_leave/components/2_Leave/Tab2.vue index 042dfa0d6..522bcfb6c 100644 --- a/src/modules/09_leave/components/2_Leave/Tab2.vue +++ b/src/modules/09_leave/components/2_Leave/Tab2.vue @@ -38,23 +38,32 @@ const maxPage = ref(1); //** เรียกข้อมูลจาก API*/ async function fecthLeaveList() { - showLoader(); - await http - .post(config.API.leaveListDelete(), querySting) - .then((res) => { - const data = res.data.result; - console.log(data); + querySting.status = await (querySting.status == null + ? "ALL" + : querySting.status); + querySting.type = await (querySting.type == null + ? "00000000-0000-0000-0000-000000000000" + : querySting.type); - maxPage.value = Math.ceil(data.total / querySting.pageSize); - console.log(maxPage.value); - fetchListLeaveReject(data.data); /** ส่งข้อมูลไป stores*/ - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); + if (querySting.status != null && querySting.type != null) { + showLoader(); + await http + .post(config.API.leaveListDelete(), querySting) + .then((res) => { + const data = res.data.result; + console.log(data); + + maxPage.value = Math.ceil(data.total / querySting.pageSize); + console.log(maxPage.value); + fetchListLeaveReject(data.data); /** ส่งข้อมูลไป stores*/ + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); + } // const data = APIDATA.data; } diff --git a/src/modules/09_leave/components/2_Leave/ToolBarLeave.vue b/src/modules/09_leave/components/2_Leave/ToolBarLeave.vue index 25d61bdbc..55e7f90a0 100644 --- a/src/modules/09_leave/components/2_Leave/ToolBarLeave.vue +++ b/src/modules/09_leave/components/2_Leave/ToolBarLeave.vue @@ -23,12 +23,12 @@ const props = defineProps({ const emit = defineEmits(["update:querySting"]); /** formFilter*/ -const filter = reactive({ - year: new Date().getFullYear(), //*ปีในการยื่นขอใบลา(ใช้เป็น คศ.) - type: "00000000-0000-0000-0000-000000000000", //*Id ประเภทการลา - status: "ALL", //*สถานะการของลา - keyword: "", //keyword ค้นหา -}); +// const filter = reactive({ +// year: new Date().getFullYear(), //*ปีในการยื่นขอใบลา(ใช้เป็น คศ.) +// type: "00000000-0000-0000-0000-000000000000", //*Id ประเภทการลา +// status: "ALL", //*สถานะการของลา +// keyword: "", //keyword ค้นหา +// }); /** * function update ข้อมูลการค้นหา (QuerySting)