fix CurrentPage ===> อัตราค่าจ้าง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-07-08 09:52:57 +07:00
parent 1513eecd15
commit c9f699bbcf

View file

@ -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<ItemsMenu[]>([
const isActive = ref<boolean>(false); //
const groupSalary = ref<string>(""); //
/**
* 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();
}
});
</script>
<template>
<div class="row items-center">
<div class="toptitle text-dark row items-center q-py-xs">
@ -345,7 +361,7 @@ onMounted(async () => {
<DialogEmployeeRate
v-model:modal="modalDialogEmployeeRate"
:is-status-edit="isStatusEdit"
:fetch-data="fetchSalalyEmployeeRate"
:fetch-data="fetchSalaryEmployeeRate"
:data="dataRow as EmployeeRateSalary"
/>
</template>