From c86a0938ad2b360432d4925bd31ca6cdcf790a8c Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Tue, 29 Oct 2024 12:16:48 +0700 Subject: [PATCH 1/3] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20=E0=B8=9F?= =?UTF-8?q?=E0=B8=B4=E0=B8=A5=E0=B9=80=E0=B8=95=E0=B8=AD=E0=B8=A3=E0=B9=8C?= =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=9C?= =?UTF-8?q?=E0=B8=B9=E0=B9=89=E0=B8=97=E0=B8=94=E0=B8=A5=E0=B8=AD=E0=B8=87?= =?UTF-8?q?=E0=B8=9B=E0=B8=8F=E0=B8=B4=E0=B8=9A=E0=B8=B1=E0=B8=95=E0=B8=B4?= =?UTF-8?q?=E0=B8=AB=E0=B8=99=E0=B9=89=E0=B8=B2=E0=B8=97=E0=B8=B5=E0=B9=88?= =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=8A=E0=B8=81=E0=B8=B2=E0=B8=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/probation/MainProbation.vue | 60 +++++++++++++------ .../components/1_Complaint/MainPage.vue | 1 + 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/src/modules/05_placement/components/probation/MainProbation.vue b/src/modules/05_placement/components/probation/MainProbation.vue index 45638a2ee..b0861850f 100644 --- a/src/modules/05_placement/components/probation/MainProbation.vue +++ b/src/modules/05_placement/components/probation/MainProbation.vue @@ -34,14 +34,17 @@ const paging = ref(true); const filterRef2 = ref(null); const attrs = ref(useAttrs()); const paging2 = ref(true); +const fillterStatus = ref([]); const fillter = ref(""); const filterKeyword = ref(""); const filterKeyword2 = ref(""); const rows = ref([]); const rows2 = ref([]); +const dataUpdate = ref([]); const Opfillter = ref([]); const Opfillter2 = ref([]); const formProbation = reactive({ keyword: "", pageSize: 10, page: 1 }); +const formMain = reactive({ keyword: "", pageSize: 10, page: 1 }); const maxPage = ref(1); const modalAdd = ref(false); @@ -237,22 +240,22 @@ const columns2 = ref([ /** get ข้อมูล */ async function getpersonalList() { - rows.value = []; showLoader(); await http .get( config.API.probationPersonalList() + `?status=${fillter.value}&page=${pagination.value.page}&pageSize=${pagination.value.rowsPerPage}&keyword=${filterKeyword.value}` ) - .then((res) => { - rows.value = res.data.data.data; + .then(async (res) => { + const data = await res.data.data.data; + const resTotal = await res.data.data.total; + rows.value = data; + fillterStatus.value = data; + dataUpdate.value = rows.value; Opfillter.value = storeFn.optionStatusProbation; Opfillter2.value = storeFn.optionStatusProbation; - - totalList.value = Math.ceil( - res.data.data.total / pagination.value.rowsPerPage - ); - total.value = res.data.data.total; + totalList.value = Math.ceil(resTotal / pagination.value.rowsPerPage); + total.value = resTotal; hideLoader(); }) .catch((e) => { @@ -288,6 +291,15 @@ function updatePagination(newPagination: any) { formProbation.pageSize = newPagination.rowsPerPage; } +/** + * function updatePagination + * @param newPagination ข้อมูล Pagination ใหม่ + */ +function updatePaginationMain(newPagination: any) { + pagination.value.page = 1; + pagination.value.rowsPerPage = newPagination.rowsPerPage; +} + async function filterKeyword2Fn(page: number) { page !== 1 ? (formProbation.page = 1) : await onclickAddProbation(); } @@ -366,6 +378,7 @@ async function clickClose() { function resetFilter() { filterKeyword.value = ""; filterRef.value.focus(); + getSearchMain() } /** reset ฟิลเตอร์ ใน dialog */ @@ -374,6 +387,11 @@ function resetFilter2() { filterRef2.value.focus(); } +function paginationLabel(start: string, end: string, total: string) { + if (paging.value == true) return " " + start + "-" + end + " ใน " + total; + else return start + "-" + end + " ใน " + total; +} + function paginationLabel2(start: string, end: string, total: string) { if (paging2.value == true) return " " + start + "-" + end + " ใน " + total; else return start + "-" + end + " ใน " + total; @@ -441,14 +459,19 @@ function closeAdd() { topic.value = "แต่งตั้งคณะกรรมการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ"; } -function getSearch() { - pagination.value.page = 1; - getpersonalList(); +function getSearchMain(){ + pagination.value.page = 1 + getpersonalList() } + +watch([() => formProbation.page, () => formProbation.pageSize], () => { + onclickAddProbation(); +}); + watch( () => pagination.value.rowsPerPage, - () => { - getSearch(); + async () => { + getSearchMain() } ); @@ -478,7 +501,7 @@ onMounted(async () => { :borderless="false" :outlined="true" :hide-dropdown-icon="false" - @update:model-value="getpersonalList()" + @update:model-value="getSearchMain()" @filter="filterFn" use-input behavior="menu" @@ -530,7 +553,7 @@ onMounted(async () => { outlined debounce="300" placeholder="ค้นหา" - @keydown.enter.prevent="getSearch" + @keydown.enter.prevent="getSearchMain()" >