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 { useRouter, useRoute } from "vue-router";
import { checkPermission } from "@/utils/permissions"; import { checkPermission } from "@/utils/permissions";
import { updateCurrentPage } from "@/utils/function";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http"; import http from "@/plugins/http";
import config from "@/app.config"; import config from "@/app.config";
@ -110,9 +111,7 @@ const itemMenu = ref<ItemsMenu[]>([
const isActive = ref<boolean>(false); // const isActive = ref<boolean>(false); //
const groupSalary = ref<string>(""); // const groupSalary = ref<string>(""); //
/** /** ฟังก์ชันดึงข้อมูลรายละเอียดอัตราค่าจ้าง */
* fetch อมลอตราคาจาง
*/
async function fetchDataDetail() { async function fetchDataDetail() {
await http await http
.get(config.API.salaryEmployeeChartByid(salaryEmployeeId.value)) .get(config.API.salaryEmployeeChartByid(salaryEmployeeId.value))
@ -125,11 +124,8 @@ async function fetchDataDetail() {
}); });
} }
/** /** ฟังก์ชันดึงข้อมูลรายการอัตราค่าจ้าง */
* fetch ตราคาจาง async function fetchSalaryEmployeeRate() {
*/
async function fetchSalalyEmployeeRate() {
showLoader();
await http await http
.get( .get(
config.API.salaryEmployeeRateListByid(salaryEmployeeId.value) + config.API.salaryEmployeeRateListByid(salaryEmployeeId.value) +
@ -143,9 +139,6 @@ async function fetchSalalyEmployeeRate() {
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
})
.finally(() => {
hideLoader();
}); });
} }
@ -169,7 +162,12 @@ function onDelete(id: string) {
http http
.delete(config.API.salaryEmployeeRateListByid(id)) .delete(config.API.salaryEmployeeRateListByid(id))
.then(async () => { .then(async () => {
await fetchSalalyEmployeeRate(); formFilter.page = await updateCurrentPage(
formFilter.page,
maxPage.value,
rows.value.length
);
await fetchSalaryEmployeeRate();
await success($q, "ลบข้อมูลสำเร็จ"); await success($q, "ลบข้อมูลสำเร็จ");
}) })
.catch((err) => { .catch((err) => {
@ -181,9 +179,7 @@ function onDelete(id: string) {
}); });
} }
/** /** ฟังก์ชันเปิด Popup เพิ่มข้อมูลรายการอัตราค่าจ้าง */
* เพมขอมลรายการอตราคาจาง
*/
function onClickAdd() { function onClickAdd() {
modalDialogEmployeeRate.value = true; modalDialogEmployeeRate.value = true;
isStatusEdit.value = false; isStatusEdit.value = false;
@ -193,9 +189,16 @@ function onClickAdd() {
* งกนเปลยนหนาขอม * งกนเปลยนหนาขอม
* @param val หนาทองการไป * @param val หนาทองการไป
*/ */
function updatePage(val: number) { async function updatePage(val: number) {
formFilter.page = val; try {
fetchSalalyEmployeeRate(); 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; formFilter.pageSize = newPagination.rowsPerPage;
} }
/** /** ฟังก์ชันดาวน์โหลดรายงาน */
* click download
*/
function clickDownload() { function clickDownload() {
showLoader(); showLoader();
http http
@ -228,15 +229,30 @@ function clickDownload() {
watch( watch(
() => formFilter.pageSize, () => formFilter.pageSize,
() => { async () => {
fetchSalalyEmployeeRate(); try {
showLoader();
await fetchSalaryEmployeeRate();
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
} }
); );
onMounted(async () => { onMounted(async () => {
await Promise.all([fetchDataDetail(), fetchSalalyEmployeeRate()]); try {
showLoader();
await Promise.all([fetchDataDetail(), fetchSalaryEmployeeRate()]);
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
}); });
</script> </script>
<template> <template>
<div class="row items-center"> <div class="row items-center">
<div class="toptitle text-dark row items-center q-py-xs"> <div class="toptitle text-dark row items-center q-py-xs">
@ -345,7 +361,7 @@ onMounted(async () => {
<DialogEmployeeRate <DialogEmployeeRate
v-model:modal="modalDialogEmployeeRate" v-model:modal="modalDialogEmployeeRate"
:is-status-edit="isStatusEdit" :is-status-edit="isStatusEdit"
:fetch-data="fetchSalalyEmployeeRate" :fetch-data="fetchSalaryEmployeeRate"
:data="dataRow as EmployeeRateSalary" :data="dataRow as EmployeeRateSalary"
/> />
</template> </template>