From b28f759ac73fcff2ed70c06a91000f5a5121fdbb Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 26 Nov 2024 11:10:23 +0700 Subject: [PATCH] =?UTF-8?q?fix=20bug=20pagintion=20=3D=3D>=20=20=20?= =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=9A=E0=B8=9A=E0=B9=80=E0=B8=9B=E0=B8=A5?= =?UTF-8?q?=E0=B8=B5=E0=B9=88=E0=B8=A2=E0=B8=99=E0=B9=81=E0=B8=9B=E0=B8=A5?= =?UTF-8?q?=E0=B8=87=E0=B8=A3=E0=B8=AD=E0=B8=9A=E0=B8=81=E0=B8=B2=E0=B8=A3?= =?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=87=E0=B8=B2=E0=B8=99=E0=B8=82=E0=B8=AD=E0=B8=87=E0=B8=9C?= =?UTF-8?q?=E0=B8=B9=E0=B9=89=E0=B9=83=E0=B8=8A=E0=B9=89=E0=B8=87=E0=B8=B2?= =?UTF-8?q?=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/03_ChangeRound/DialogForm.vue | 32 +++++++++++++------ .../09_leave/stores/ChangeRoundStore.ts | 22 ++++++------- .../09_leave/views/03_ChangeRoundMain.vue | 18 ++++++----- 3 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/modules/09_leave/components/03_ChangeRound/DialogForm.vue b/src/modules/09_leave/components/03_ChangeRound/DialogForm.vue index 0a8290190..ef50d6ced 100644 --- a/src/modules/09_leave/components/03_ChangeRound/DialogForm.vue +++ b/src/modules/09_leave/components/03_ChangeRound/DialogForm.vue @@ -68,8 +68,8 @@ const pageSize = ref(10); const initialPagination = ref({ sortBy: null, descending: false, - page: 1, - rowsPerPage: pageSize, // set ตาม page หลักส่งมา + page: dataStore.page, + rowsPerPage: dataStore.pageSize, // set ตาม page หลักส่งมา }); // Pagination - page & change page & get new data @@ -77,7 +77,7 @@ const currentPage = ref(1); const roundOp = ref([]); async function updatePagination(newPagination: any) { initialPagination.value = newPagination; - currentPage.value = 1; // set current page เป็น 1 เสมอเมื่อเปลี่ยน per row + // currentPage.value = 1; // set current page เป็น 1 เสมอเมื่อเปลี่ยน per row } /** Function validateForm */ @@ -103,7 +103,7 @@ function onSubmit() { $q, () => { changeRound(); - props.closeDialog?.(); + // props.closeDialog?.(); }, "ยืนยันการบันทึกข้อมูล", "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" @@ -112,6 +112,7 @@ function onSubmit() { /** Function เปลี่ยนรอบเวลา*/ async function changeRound() { + showLoader(); await http .post(config.API.leaveRound(), { profileId: props.personId, @@ -121,12 +122,13 @@ async function changeRound() { }) .then(() => { success($q, "บันทึกข้อมูลเปลี่ยนรอบเวลา"); + props.closeDialog?.(); }) .catch((err) => { messageError($q, err); }) .finally(() => { - props.closeDialog?.(); + hideLoader(); }); } @@ -135,7 +137,7 @@ async function changeRound() { * */ async function fetchDataOption() { - showLoader(); + props.editCheck !== "history" && showLoader(); await http .get(config.API.leaveRound()) .then((res) => { @@ -156,7 +158,7 @@ async function fetchDataOption() { messageError($q, err); }) .finally(() => { - hideLoader(); + props.editCheck !== "history" && hideLoader(); }); } @@ -168,8 +170,9 @@ function close() { } watch( - [() => currentPage.value, () => initialPagination.value.rowsPerPage], + () => initialPagination.value.rowsPerPage, () => { + currentPage.value = 1; emit( "update:change-page", currentPage.value, @@ -179,6 +182,15 @@ watch( } ); +function nextPage() { + emit( + "update:change-page", + currentPage.value, + initialPagination.value.rowsPerPage, + true + ); +} + watch( () => props.modal, async () => { @@ -188,6 +200,7 @@ watch( formData.effectiveDate = null; } if (props.modal === true) { + currentPage.value = 1; await fetchDataOption(); } } @@ -355,7 +368,7 @@ watch( dense class="custom-header-table" :visible-columns="dataStore.visibleColumnsHistory" - :rows-per-page-options="[5, 10, 25, 50, 100]" + :rows-per-page-options="[1, 10, 25, 50, 100]" :pagination="initialPagination" @update:pagination="updatePagination" > @@ -370,6 +383,7 @@ watch( boundary-links direction-links :max="Number(dataStore.maxPage)" + @update:model-value="nextPage" >