From f33208bb71ae83c3c21cde0cc8167b931f7fdc0b Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 8 Jul 2025 10:49:27 +0700 Subject: [PATCH] =?UTF-8?q?fix=20Current=20=3D=3D=3D>=20=E0=B8=A3=E0=B8=B2?= =?UTF-8?q?=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B9=80=E0=B8=A5=E0=B8=B7?= =?UTF-8?q?=E0=B9=88=E0=B8=AD=E0=B8=99=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99?= =?UTF-8?q?=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99=E0=B8=82=E0=B9=89?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B8=B2=E0=B8=8A=E0=B8=81=E0=B8=B2=E0=B8=A3?= =?UTF-8?q?=E0=B8=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/04_salaryLists/TabMain.vue | 9 +--- .../04_salaryLists/TableTypeOther.vue | 29 ++++++++--- .../04_salaryLists/TableTypePending.vue | 51 +++++++++++-------- 3 files changed, 52 insertions(+), 37 deletions(-) diff --git a/src/modules/13_salary/components/04_salaryLists/TabMain.vue b/src/modules/13_salary/components/04_salaryLists/TabMain.vue index 107e41543..07b06f477 100644 --- a/src/modules/13_salary/components/04_salaryLists/TabMain.vue +++ b/src/modules/13_salary/components/04_salaryLists/TabMain.vue @@ -38,7 +38,7 @@ const props = defineProps({ revisionId: { type: String, require: true }, }); -const total = ref(); +const total = ref(0); const splitterModel = ref(13); const rows = ref([]); @@ -257,12 +257,7 @@ async function fetchDataPeriod(id: string) { showLoader(); let formData = { - page: - formFilter.page !== 1 && - formFilter.page === maxPage.value && - rows.value.length === 1 - ? (formFilter.page - 1).toString() - : formFilter.page.toString(), + page: formFilter.page.toString(), pageSize: formFilter.pageSize.toString(), keyword: formFilter.keyword.trim(), type: store.tabType, diff --git a/src/modules/13_salary/components/04_salaryLists/TableTypeOther.vue b/src/modules/13_salary/components/04_salaryLists/TableTypeOther.vue index c0258c8c7..39340cd5d 100644 --- a/src/modules/13_salary/components/04_salaryLists/TableTypeOther.vue +++ b/src/modules/13_salary/components/04_salaryLists/TableTypeOther.vue @@ -2,6 +2,7 @@ import { ref, watch, computed } from "vue"; import { useQuasar } from "quasar"; import { checkPermission } from "@/utils/permissions"; +import { updateCurrentPage } from "@/utils/function"; import config from "@/app.config"; import http from "@/plugins/http"; @@ -33,12 +34,14 @@ const snapShot = defineModel("snapShot"); const isClose = defineModel("isClose", { required: true }); const props = defineProps({ - rows: { type: Array }, + rows: { type: Array, required: true }, fetchDataTable: { type: Function, + required: true, }, total: { type: Number, + required: true, }, type: { type: String, @@ -191,7 +194,7 @@ const columns = computed(() => { const modalDialogAddPerson = ref(false); //popup เพิ่มคนเลื่อนเงินเดือน const modalDialogForm = ref(false); //popup แก้ไขเงินเดือน const modalDialogMoveGroup = ref(false); //popup ย้ายกลุ่ม -const modalDialogMoveLeve = ref(false); //popup เลื่อนขั้น +const modalDialogMoveLevel = ref(false); //popup เลื่อนขั้น const profileId = ref(""); //id คน const amount = ref(0); //เงินเดือน @@ -240,7 +243,7 @@ function onClickMoveLevel( remarkVal: string = "" ) { profileId.value = id; - modalDialogMoveLeve.value = !modalDialogMoveLeve.value; + modalDialogMoveLevel.value = !modalDialogMoveLevel.value; typeLevel.value = typeVal; isReserve.value = isReserveVal; remark.value = typeVal === "NONE" ? remarkVal : ""; @@ -256,7 +259,7 @@ function onClickDelete(id: string) { await http .delete(config.API.salaryListPeriodProfileById(id)) .then(async () => { - await props.fetchDataTable?.(); + await updateCurrentPageAndfetchData(); await success($q, "ลบข้อมูลสำเร็จ"); }) .catch((err) => { @@ -291,6 +294,16 @@ function searchData() { props.fetchDataTable?.(); } +/** ฟังก์ชันอัปเดตหน้าปัจจุบันและดึงข้อมูล */ +async function updateCurrentPageAndfetchData() { + formFilter.value.page = await updateCurrentPage( + formFilter.value.page, + Number(maxPage.value), + props.rows.length + ); + await props.fetchDataTable?.(); +} + /** * callblack function เรียกข้อมูลรายชื่อใหม่ เมื่อมีการเปลี่ยน PageSize */ @@ -369,7 +382,7 @@ watch( bordered :paging="true" dense - :rows-per-page-options="[10, 25, 50, 100]" + :rows-per-page-options="[1,10, 25, 50, 100]" :visible-columns="visibleColumns" @update:pagination="updatePageSizePagination" > @@ -547,13 +560,13 @@ watch( ("maxPage", { required: true }); const snapShot = defineModel("snapShot"); const isClose = defineModel("isClose", { required: true }); const props = defineProps({ - rows: { type: Array }, + rows: { type: Array, required: true }, fetchDataTable: { type: Function, + required: true, }, maxPage: { type: Number, + required: true, }, total: { type: Number, + required: true, }, isRetire: { type: Boolean, + required: true, }, }); @@ -219,8 +224,8 @@ const visibleColumns = ref([ const modalDialogAddPerson = ref(false); //popup เพิ่มคนเลื่อนเงินเดือน const modalDialogForm = ref(false); //popup แก้ไขเงินเดือน const modalDialogMoveGroup = ref(false); //popup ย้ายกลุ่ม -const modalDialogMoveLeve = ref(false); //popup เลื่อนขั้น -const modalDialogMoveLeveMulti = ref(false); //popup เลื่อนขั้น +const modalDialogMoveLevel = ref(false); //popup เลื่อนขั้น +const modalDialogMoveLevelMulti = ref(false); //popup เลื่อนขั้น const modalDialogProperties = ref(false); const modalDialogInfo = ref(false); // /popup ข้อมูลส่วนตัว @@ -244,7 +249,7 @@ function onClickDelete(id: string) { await http .delete(config.API.salaryListPeriodProfileById(id)) .then(async () => { - await props.fetchDataTable?.(); + await updateCurrentPageAndfetchData(); await success($q, "ลบข้อมูลสำเร็จ"); }) .catch((err) => { @@ -256,9 +261,7 @@ function onClickDelete(id: string) { }); } -/** - * function openPopup เพิ่มคนเลื่อนเงินเดือน - */ +/** function openPopup เพิ่มคนเลื่อนเงินเดือน*/ function onClickAddPerson() { modalDialogAddPerson.value = !modalDialogAddPerson.value; } @@ -292,29 +295,23 @@ function onClickMovieGroup(id: string) { */ function onClickMoveLevel(id: string, typeVal: string, isReserveVal: boolean) { profileId.value = id; - modalDialogMoveLeve.value = !modalDialogMoveLeve.value; + modalDialogMoveLevel.value = !modalDialogMoveLevel.value; typeLevel.value = typeVal; isReserve.value = isReserveVal; } -/** - * function updatePageTable - */ +/** function updatePageTable*/ function updatePagePagination() { props.fetchDataTable?.(); } -/** - * function updatePageSizeTable - */ +/** function updatePageSizeTable*/ function updatePageSizePagination(newPagination: NewPagination) { formFilter.value.page = 1; formFilter.value.pageSize = newPagination.rowsPerPage; } -/** - * function ค้นหาข้อมูล Table - */ +/** function ค้นหาข้อมูล Table */ function searchData() { formFilter.value.page = 1; props.fetchDataTable?.(); @@ -335,7 +332,17 @@ function onProperties(data: any) { /** function openPopup ย้ายกขั้น*/ function onClickMoveLevelMulti() { - modalDialogMoveLeveMulti.value = !modalDialogMoveLeve.value; + modalDialogMoveLevelMulti.value = !modalDialogMoveLevel.value; +} + +/** ฟังก์ชันอัปเดตหน้าปัจจุบันและดึงข้อมูล */ +async function updateCurrentPageAndfetchData() { + formFilter.value.page = await updateCurrentPage( + formFilter.value.page, + props.maxPage, + props.rows.length + ); + await props.fetchDataTable?.(); } /** callblack function เรียกข้อมูลรายชื่อใหม่ เมื่อมีการเปลี่ยน PageSize*/ @@ -590,15 +597,15 @@ function onClickViewInfo(type: string, id: string) {