From 36c71e3fda2e7ef55cc0e24672c194c14fc5f303 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 7 Jul 2025 18:07:54 +0700 Subject: [PATCH 1/9] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20Function=20updateCurrentPage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/function.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/utils/function.ts diff --git a/src/utils/function.ts b/src/utils/function.ts new file mode 100644 index 000000000..82896079a --- /dev/null +++ b/src/utils/function.ts @@ -0,0 +1,19 @@ +/** + * คำนวณหน้าที่ควรแสดงหลังจากลบข้อมูล + * + * @param page หน้าปัจจุบัน + * @param maxPage หน้าสุดท้าย + * @param currentPageItems จำนวนข้อมูลในหน้าปัจจุบัน + * @returns หน้าที่ควรแสดง + */ +export function updateCurrentPage( + page: number, + maxPage: number, + total: number +) { + // ถ้าหน้าปัจจุบันไม่ใช่หน้าแรก และเป็นหน้าสุดท้าย และมีข้อมูลเหลือ 1 รายการ ให้กลับไปหน้าก่อนหน้า + if (page > 1 && page === maxPage && total === 1) { + return page - 1; + } + return page; +} From a82d383b834e85e1758a489ce8caff7a1a712531 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 7 Jul 2025 18:08:02 +0700 Subject: [PATCH 2/9] no message --- src/utils/function.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/function.ts b/src/utils/function.ts index 82896079a..057de9702 100644 --- a/src/utils/function.ts +++ b/src/utils/function.ts @@ -1,5 +1,5 @@ /** - * คำนวณหน้าที่ควรแสดงหลังจากลบข้อมูล + * คำนวณหน้าที่จะแสดงหลังจากลบข้อมูล * * @param page หน้าปัจจุบัน * @param maxPage หน้าสุดท้าย From 8ef2241797e6895b0d1417e9971058c852b8b063 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 7 Jul 2025 18:08:57 +0700 Subject: [PATCH 3/9] async --- src/utils/function.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/utils/function.ts diff --git a/src/utils/function.ts b/src/utils/function.ts new file mode 100644 index 000000000..cab7df1ed --- /dev/null +++ b/src/utils/function.ts @@ -0,0 +1,19 @@ +/** + * คำนวณหน้าที่จะแสดงหลังจากลบข้อมูล + * + * @param page หน้าปัจจุบัน + * @param maxPage หน้าสุดท้าย + * @param currentPageItems จำนวนข้อมูลในหน้าปัจจุบัน + * @returns หน้าที่ควรแสดง + */ +export async function updateCurrentPage( + page: number, + maxPage: number, + total: number +) { + // ถ้าหน้าปัจจุบันไม่ใช่หน้าแรก และเป็นหน้าสุดท้าย และมีข้อมูลเหลือ 1 รายการ ให้กลับไปหน้าก่อนหน้า + if (page > 1 && page === maxPage && total === 1) { + return page - 1; + } + return page; +} From fb7b4060c94245d8d6bf253161e63fc704528257 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 7 Jul 2025 18:13:29 +0700 Subject: [PATCH 4/9] =?UTF-8?q?fix=20updateCurrentPage=20=3D=3D>=20?= =?UTF-8?q?=E0=B8=9C=E0=B8=B1=E0=B8=87=E0=B8=9A=E0=B8=B1=E0=B8=8D=E0=B8=8A?= =?UTF-8?q?=E0=B8=B5=E0=B8=84=E0=B9=88=E0=B8=B2=E0=B8=88=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=87=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=87=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=88=E0=B8=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/02_salaryEmployee/TabStructure.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/13_salary/components/02_salaryEmployee/TabStructure.vue b/src/modules/13_salary/components/02_salaryEmployee/TabStructure.vue index d6ef43154..a3b10b375 100644 --- a/src/modules/13_salary/components/02_salaryEmployee/TabStructure.vue +++ b/src/modules/13_salary/components/02_salaryEmployee/TabStructure.vue @@ -5,6 +5,7 @@ import { useQuasar } from "quasar"; import { useRouter } from "vue-router"; import http from "@/plugins/http"; import config from "@/app.config"; +import { updateCurrentPage } from "@/utils/function"; /** importType*/ import type { QTableProps } from "quasar"; @@ -179,6 +180,11 @@ function onClickDelete(id: string) { http .delete(config.API.salaryEmployeeChartByid(id)) .then(async () => { + formFilter.page = await updateCurrentPage( + formFilter.page, + maxPage.value, + rows.value.length + ); await fetchListChart(); await success($q, "ลบข้อมูลสำเร็จ"); }) @@ -282,7 +288,7 @@ onMounted(() => { :rows="rows" :columns="columns" row-key="name" - :rows-per-page-options="[10, 20, 50, 100]" + :rows-per-page-options="[1, 10, 20, 50, 100]" :visible-columns="visibleColumns" @update:pagination="updatePageSize" > From 1513eecd1569efd5033727cc7d114dd7214b4003 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 8 Jul 2025 09:52:27 +0700 Subject: [PATCH 5/9] =?UTF-8?q?fix=20CurrentPage=20=3D=3D=3D>=20=E0=B8=9C?= =?UTF-8?q?=E0=B8=B1=E0=B8=87=E0=B8=9A=E0=B8=B1=E0=B8=8D=E0=B8=8A=E0=B8=B5?= =?UTF-8?q?=E0=B8=84=E0=B9=88=E0=B8=B2=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87?= =?UTF-8?q?=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87?= =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=88=E0=B8=B3(=E0=B8=AB?= =?UTF-8?q?=E0=B8=A5=E0=B8=B1=E0=B8=81=E0=B9=80=E0=B8=81=E0=B8=93=E0=B8=91?= =?UTF-8?q?=E0=B9=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../02_salaryEmployee/TabCriteria.vue | 102 ++++++++++-------- 1 file changed, 59 insertions(+), 43 deletions(-) diff --git a/src/modules/13_salary/components/02_salaryEmployee/TabCriteria.vue b/src/modules/13_salary/components/02_salaryEmployee/TabCriteria.vue index a611f252a..5176dcf92 100644 --- a/src/modules/13_salary/components/02_salaryEmployee/TabCriteria.vue +++ b/src/modules/13_salary/components/02_salaryEmployee/TabCriteria.vue @@ -1,6 +1,7 @@ From c9f699bbcf40ea46a208db7706ed8a196116a447 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 8 Jul 2025 09:52:57 +0700 Subject: [PATCH 6/9] =?UTF-8?q?fix=20CurrentPage=20=3D=3D=3D>=20=E0=B8=AD?= =?UTF-8?q?=E0=B8=B1=E0=B8=95=E0=B8=A3=E0=B8=B2=E0=B8=84=E0=B9=88=E0=B8=B2?= =?UTF-8?q?=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/page02_salaryEmployeeRate.vue | 66 ++++++++++++------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/src/modules/13_salary/views/page02_salaryEmployeeRate.vue b/src/modules/13_salary/views/page02_salaryEmployeeRate.vue index 776b28914..078ff46a8 100644 --- a/src/modules/13_salary/views/page02_salaryEmployeeRate.vue +++ b/src/modules/13_salary/views/page02_salaryEmployeeRate.vue @@ -4,6 +4,7 @@ import { useQuasar } from "quasar"; import { useRouter, useRoute } from "vue-router"; import { checkPermission } from "@/utils/permissions"; +import { updateCurrentPage } from "@/utils/function"; import { useCounterMixin } from "@/stores/mixin"; import http from "@/plugins/http"; import config from "@/app.config"; @@ -110,9 +111,7 @@ const itemMenu = ref([ const isActive = ref(false); //สถานะการใช้งาน const groupSalary = ref(""); //ชื่ออัตราค่าจ้าง -/** - * fetch ข้อมูลอัตราค่าจ้าง - */ +/** ฟังก์ชันดึงข้อมูลรายละเอียดอัตราค่าจ้าง */ async function fetchDataDetail() { await http .get(config.API.salaryEmployeeChartByid(salaryEmployeeId.value)) @@ -125,11 +124,8 @@ async function fetchDataDetail() { }); } -/** - * fetch อัตราค่าจ้าง - */ -async function fetchSalalyEmployeeRate() { - showLoader(); +/** ฟังก์ชันดึงข้อมูลรายการอัตราค่าจ้าง */ +async function fetchSalaryEmployeeRate() { await http .get( config.API.salaryEmployeeRateListByid(salaryEmployeeId.value) + @@ -143,9 +139,6 @@ async function fetchSalalyEmployeeRate() { }) .catch((err) => { messageError($q, err); - }) - .finally(() => { - hideLoader(); }); } @@ -169,7 +162,12 @@ function onDelete(id: string) { http .delete(config.API.salaryEmployeeRateListByid(id)) .then(async () => { - await fetchSalalyEmployeeRate(); + formFilter.page = await updateCurrentPage( + formFilter.page, + maxPage.value, + rows.value.length + ); + await fetchSalaryEmployeeRate(); await success($q, "ลบข้อมูลสำเร็จ"); }) .catch((err) => { @@ -181,9 +179,7 @@ function onDelete(id: string) { }); } -/** - * เพิ่มข้อมูลรายการอัตราค่าจ้าง - */ +/** ฟังก์ชันเปิด Popup เพิ่มข้อมูลรายการอัตราค่าจ้าง */ function onClickAdd() { modalDialogEmployeeRate.value = true; isStatusEdit.value = false; @@ -193,9 +189,16 @@ function onClickAdd() { * ฟังก์ชันเปลี่ยนหน้าข้อมูล * @param val หน้าที่จ้องการไป */ -function updatePage(val: number) { - formFilter.page = val; - fetchSalalyEmployeeRate(); +async function updatePage(val: number) { + try { + showLoader(); + formFilter.page = val; + await fetchSalaryEmployeeRate(); + } catch (error) { + messageError($q, error); + } finally { + hideLoader(); + } } /** @@ -207,9 +210,7 @@ function updatePageSize(newPagination: NewPagination) { formFilter.pageSize = newPagination.rowsPerPage; } -/** - * click download - */ +/** ฟังก์ชันดาวน์โหลดรายงาน */ function clickDownload() { showLoader(); http @@ -228,15 +229,30 @@ function clickDownload() { watch( () => formFilter.pageSize, - () => { - fetchSalalyEmployeeRate(); + async () => { + try { + showLoader(); + await fetchSalaryEmployeeRate(); + } catch (error) { + messageError($q, error); + } finally { + hideLoader(); + } } ); onMounted(async () => { - await Promise.all([fetchDataDetail(), fetchSalalyEmployeeRate()]); + try { + showLoader(); + await Promise.all([fetchDataDetail(), fetchSalaryEmployeeRate()]); + } catch (error) { + messageError($q, error); + } finally { + hideLoader(); + } }); + From 1faa8e798a11e1f3f507923f0ceec05ad2ae58bd Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 8 Jul 2025 10:07:07 +0700 Subject: [PATCH 7/9] =?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=B8=9C=E0=B8=B1?= =?UTF-8?q?=E0=B8=87=E0=B8=9A=E0=B8=B1=E0=B8=8D=E0=B8=8A=E0=B8=B5=E0=B9=80?= =?UTF-8?q?=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD?= =?UTF-8?q?=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/13_salary/views/01_salaryMain.vue | 53 ++++++++----------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/src/modules/13_salary/views/01_salaryMain.vue b/src/modules/13_salary/views/01_salaryMain.vue index 114a110ad..9a03034d5 100644 --- a/src/modules/13_salary/views/01_salaryMain.vue +++ b/src/modules/13_salary/views/01_salaryMain.vue @@ -4,25 +4,22 @@ import { useQuasar } from "quasar"; import { useRouter } from "vue-router"; import { checkPermission } from "@/utils/permissions"; +import { updateCurrentPage } from "@/utils/function"; import { useCounterMixin } from "@/stores/mixin"; import http from "@/plugins/http"; import config from "@/app.config"; -/** - * importType - */ +/** importType */ import type { QTableProps } from "quasar"; import type { NewPagination } from "@/modules/13_salary/interface/index/Main"; import type { Salary } from "@/modules/13_salary/interface/response/Main"; import type { FormQuerySalary } from "@/modules/13_salary/interface/request/Main"; -/** - * importComponents - */ +/** importComponents */ import DialogFormMain from "@/modules/13_salary/components/01_Salary/DialogFormMain.vue"; // ผังบัญชีเงินเดือน import DialogFormUpload from "@/modules/13_salary/components/01_Salary/DialogUpload.vue"; // อัปโหลดเอกสารอ้างอิง -/** use*/ +/** use composables */ const $q = useQuasar(); const router = useRouter(); const { @@ -34,7 +31,7 @@ const { success, } = useCounterMixin(); -/** modalDialog*/ +/** modalDialog */ const modalDialogFormMain = ref(false); //popup เพิ่ม,แก้ไข ผังบัญชีเงินเดือน const modalUpload = ref(false); //popup อัปโหลดเอกสารอ้างอิง const rowId = ref(""); // id รายการผังบัญชีเงินเดือน @@ -86,7 +83,7 @@ const visibleColumns = ref([ "isActive", ]); -/** queryString*/ +/** queryString */ const formQuery = reactive({ page: 1, //*หน้า pageSize: 10, //*จำนวนแถวต่อหน้า @@ -98,9 +95,7 @@ const isActive = ref(false); //สถานะการใช้งา const typeAction = ref(""); //ประเภทการกระทำ const dataSalary = ref(); //ข้อมูลรายการผังบัญชีเงินเดือนที่ต้องการแก้ไข -/** - * fetch ข้อมูลรายการผังบัญชีเงินเดือน - */ +/** ฟังก์ชันดึงข้อมูลรายการผังบัญชีเงินเดือน */ async function fetchListSalaly() { showLoader(); const page = formQuery.page.toString(); @@ -126,8 +121,8 @@ async function fetchListSalaly() { } /** - * function openDialog เพิ่ม,แก้ไข ผังบัญชีเงินเดือน - * @param type ประเภท แก่ไข,เพิ่ม + * ฟังก์ชัน openDialog เพิ่ม,แก้ไข ผังบัญชีเงินเดือน + * @param type ประเภท แก้ไข,เพิ่ม * @param data ข้อมูลผังบัญชีเงินเดือน */ function onClickSalary(type: string, data: Salary | null) { @@ -139,7 +134,7 @@ function onClickSalary(type: string, data: Salary | null) { } /** - * function redirect to page อัตราเงินเดือน + * ฟังก์ชัน redirect to page อัตราเงินเดือน * @param id บัญชีเงินเดือน */ function onClickSalaryRate(id: string) { @@ -147,7 +142,7 @@ function onClickSalaryRate(id: string) { } /** - * function คัดลอกข้อมูลรายการผังบัญชีเงินเดือน + * ฟังก์ชันคัดลอกข้อมูลรายการผังบัญชีเงินเดือน * @param id บัญชีเงินเดือน */ function onClickCoppy(id: string) { @@ -167,21 +162,21 @@ function onClickCoppy(id: string) { } /** - * function ลบข้อมูลรายการผังบัญชีเงินเดือน + * ฟังก์ชันลบข้อมูลรายการผังบัญชีเงินเดือน * @param id บัญชีเงินเดือน */ function onClickDelete(id: string) { dialogRemove($q, async () => { showLoader(); - formQuery.page = - formQuery.page !== 1 && - formQuery.page === maxPage.value && - rows.value.length === 1 - ? formQuery.page - 1 - : formQuery.page; await http .delete(config.API.salaryChartByid(id)) .then(async () => { + formQuery.page = await updateCurrentPage( + formQuery.page, + maxPage.value, + rows.value.length + ); + await fetchListSalaly(); success($q, "ลบข้อมูลสำเร็จ"); }) @@ -195,7 +190,7 @@ function onClickDelete(id: string) { } /** - * function openDialog อัปโหลดเอกสารอ้างอิง + * ฟังก์ชัน openDialog อัปโหลดเอกสารอ้างอิง * @param type * @param id ผังบัญชีเงินเดือน * @param active สถานะการใช้งาน @@ -208,7 +203,7 @@ function onClickUpload(type: string, id: string, active: boolean) { } /** - * function updatePagination + * ฟังก์ชัน updatePagination * @param newPagination ข้อมูล Pagination ใหม่ */ function updatePagination(newPagination: NewPagination) { @@ -216,16 +211,12 @@ function updatePagination(newPagination: NewPagination) { formQuery.pageSize = newPagination.rowsPerPage; } -/** - * function ค้นหาข้อมูลตาม keyword - */ +/** ฟังก์ชัน ค้นหาข้อมูลตาม keyword */ function filterFn(page: number) { page !== 1 ? (formQuery.page = 1) : fetchListSalaly(); } -/** - * callbackFunction ทำงานเมื่อมีการ เปลี่ยนแถว - */ +/** callbackFunction ทำงานเมื่อมีการ เปลี่ยนแถว */ watch( () => formQuery.pageSize, () => { From 014bcdf180d0788f56251f2c7d22eff6677d6dbd Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 8 Jul 2025 10:07:38 +0700 Subject: [PATCH 8/9] =?UTF-8?q?fix=20CurrentPage=20=3D=3D>=20=E0=B8=AD?= =?UTF-8?q?=E0=B8=B1=E0=B8=95=E0=B8=A3=E0=B8=B2=E0=B9=80=E0=B8=87=E0=B8=B4?= =?UTF-8?q?=E0=B8=99=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../13_salary/views/page01_salaryRate.vue | 64 ++++++++----------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/src/modules/13_salary/views/page01_salaryRate.vue b/src/modules/13_salary/views/page01_salaryRate.vue index 2f0caf1bc..65cdaa47b 100644 --- a/src/modules/13_salary/views/page01_salaryRate.vue +++ b/src/modules/13_salary/views/page01_salaryRate.vue @@ -1,15 +1,15 @@ @@ -358,7 +355,7 @@ onMounted(async () => {