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] =?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(); + } }); +