From d9f5661ac3f78812f8b8baaf74afbeb57eeb3ceb Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 8 Jul 2025 11:19:40 +0700 Subject: [PATCH] =?UTF-8?q?fix=20CurrentPage=20=3D=3D=3D>=20=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B9=80=E0=B8=A5?= =?UTF-8?q?=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=99=E0=B8=84=E0=B9=88=E0=B8=B2?= =?UTF-8?q?=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87=E0=B8=A5=E0=B8=B9=E0=B8=81?= =?UTF-8?q?=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87=E0=B8=9B=E0=B8=A3=E0=B8=B0?= =?UTF-8?q?=E0=B8=88=E0=B8=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../04_salaryLists/TableTypeOther.vue | 2 +- .../05_salaryListsEmployee/TabMain.vue | 7 +--- .../05_salaryListsEmployee/TableTypeOther.vue | 31 +++++++++++----- .../TableTypePending.vue | 35 +++++++++++++------ 4 files changed, 49 insertions(+), 26 deletions(-) diff --git a/src/modules/13_salary/components/04_salaryLists/TableTypeOther.vue b/src/modules/13_salary/components/04_salaryLists/TableTypeOther.vue index 39340cd5d..2827baa1c 100644 --- a/src/modules/13_salary/components/04_salaryLists/TableTypeOther.vue +++ b/src/modules/13_salary/components/04_salaryLists/TableTypeOther.vue @@ -382,7 +382,7 @@ watch( bordered :paging="true" dense - :rows-per-page-options="[1,10, 25, 50, 100]" + :rows-per-page-options="[10, 25, 50, 100]" :visible-columns="visibleColumns" @update:pagination="updatePageSizePagination" > diff --git a/src/modules/13_salary/components/05_salaryListsEmployee/TabMain.vue b/src/modules/13_salary/components/05_salaryListsEmployee/TabMain.vue index 2ad3dcaa1..e94d7b1fa 100644 --- a/src/modules/13_salary/components/05_salaryListsEmployee/TabMain.vue +++ b/src/modules/13_salary/components/05_salaryListsEmployee/TabMain.vue @@ -249,12 +249,7 @@ function fetchDataQuota(id: string) { 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, type: store.tabType, diff --git a/src/modules/13_salary/components/05_salaryListsEmployee/TableTypeOther.vue b/src/modules/13_salary/components/05_salaryListsEmployee/TableTypeOther.vue index 6026f3d12..ea79252dc 100644 --- a/src/modules/13_salary/components/05_salaryListsEmployee/TableTypeOther.vue +++ b/src/modules/13_salary/components/05_salaryListsEmployee/TableTypeOther.vue @@ -3,6 +3,7 @@ import { ref, watch, computed } from "vue"; import { useQuasar } from "quasar"; import { checkPermission } from "@/utils/permissions"; +import { updateCurrentPage } from "@/utils/function"; import { useCounterMixin } from "@/stores/mixin"; import { useSalaryEmployeeListSDataStore } from "@/modules/13_salary/store/SalaryEmployeeListsStore"; import config from "@/app.config"; @@ -31,16 +32,18 @@ const maxPage = defineModel("maxPage", { required: true }); const isClose = defineModel("isClose", { required: true }); const snapShot = defineModel("snapShot"); const props = defineProps({ - rows: { type: Array }, + rows: { type: Array, required: true }, fetchDataTable: { type: Function, + required: true, }, total: { type: Number, + required: true, }, type: { type: String, - requird: true, + required: true, }, }); @@ -197,7 +200,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); //เงินเดือน @@ -246,7 +249,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 : ""; @@ -262,7 +265,7 @@ function onClickDelete(id: string) { await http .delete(config.API.salaryListPeriodProfileByIdEmp(id)) .then(async () => { - await props.fetchDataTable?.(); + await updateCurrentPageAndfetchData(); await success($q, "ลบข้อมูลสำเร็จ"); }) .catch((err) => { @@ -297,6 +300,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 */ @@ -376,7 +389,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" > @@ -556,13 +569,13 @@ watch( ("isClose", { required: true }); const snapShot = defineModel("snapShot"); 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, }, }); @@ -232,10 +237,10 @@ const visibleColumns = ref([ 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 modalDialogProperties = ref(false); //popup คุณสมบัติ const modalDialogInfo = ref(false); //popup ข้อมูลส่วนตัว -const modalDialogMoveLeveMulti = ref(false); //popup เลื่อนขั้น +const modalDialogMoveLevelMulti = ref(false); //popup เลื่อนขั้น /** ตัวแปร*/ const profileId = ref(""); //id คน @@ -257,7 +262,7 @@ function onClickDelete(id: string) { await http .delete(config.API.salaryListPeriodProfileByIdEmp(id)) .then(async () => { - await props.fetchDataTable?.(); + await updateCurrentPageAndfetchData(); await success($q, "ลบข้อมูลสำเร็จ"); }) .catch((err) => { @@ -303,7 +308,7 @@ 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; } @@ -354,7 +359,17 @@ function onClickViewInfo(type: string, id: string) { /** 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?.(); } /** @@ -604,15 +619,15 @@ watch(