fix CurrentPage ===> รอบการขึ้นเงินเดือน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-07-08 10:20:19 +07:00
parent 014bcdf180
commit c6abf8314d

View file

@ -3,6 +3,7 @@ import { ref, watch, onMounted } from "vue";
import { useQuasar } from "quasar";
import { checkPermission } from "@/utils/permissions";
import { updateCurrentPage } from "@/utils/function";
import { useCounterMixin } from "@/stores/mixin";
import { useSalaryDataStore } from "@/modules/13_salary/store/SalaryStore";
import config from "@/app.config";
@ -42,7 +43,6 @@ const yearData = ref<number | null>(0); //ปีงบประมาณ
/** Table*/
const year = ref<number>(0); //
const filterKeyword = ref<string>(""); //
const currentPage = ref<number>(1); //
const maxPage = ref<number>(1); //
const totalList = ref<number>(0); //
const page = ref<number>(1); //
@ -117,23 +117,19 @@ const pagination = ref({
rowsPerPage: rowsPerPage.value,
});
/**
* function เป Dialog เพมรอบการขนเงนเดอน
*/
/**ฟังก์ชัน เปิด Dialog เพิ่มรอบการขึ้นเงินเดือน */
function clickAdd() {
dialog.value = true;
editCheck.value = false;
}
/**
* fetch รายการรอบการขนเงนเดอน
*/
/** ฟังก์ชันดึงข้อมูลรายการรอบการขึ้นเงินเดือน */
async function getData() {
showLoader();
await http
.get(
config.API.salaryPeriod() +
`?page=${page.value}&pageSise=${rowsPerPage.value}&keyword=${filterKeyword.value}&year=${year.value}`
`?page=${page.value}&pageSize=${rowsPerPage.value}&keyword=${filterKeyword.value}&year=${year.value}`
)
.then(async (res) => {
const data = await res.data.result;
@ -149,31 +145,34 @@ async function getData() {
});
}
/**
* function เลอกปงบประมาณ
*/
/** ฟังก์ชันเลือกปีงบประมาณ */
function updateYear() {
page.value = 1;
getData();
}
/**
* set งหมด
*/
/** ฟังก์ชันกำหนด ปี ทั้งหมด */
function yearAll() {
year.value = 0;
getData();
}
/**
* function ลบรายการรอบการขนเงนเดอน
* งกลบรายการรอบการขนเงนเดอน
* @param id รอบการขนเงนเดอน
*/
function deleteData(id: string) {
dialogRemove($q, () => {
dialogRemove($q, async () => {
showLoader();
http
await http
.delete(config.API.salaryPeriod() + `/${id}`)
.then(async () => {
page.value = await updateCurrentPage(
page.value,
maxPage.value,
dataStore.rows.length
);
await getData();
await success($q, "ลบข้อมูลสำเร็จ");
})
@ -187,9 +186,9 @@ function deleteData(id: string) {
}
/**
* function เป Dialog อมลรอบการขนเงนเดอน
* งกเป Dialog อมลรอบการขนเงนเดอน
* @param data อมลรอบการขนเงนเดอน
* @param status ถานะการแกไข
* @param status ถานะการแกไข
*/
function editPopup(data: RowList, status: string) {
if (status == "read") {
@ -205,7 +204,7 @@ function editPopup(data: RowList, status: string) {
}
/**
* function ดรอการขนเงนเดอน
* งกดรอการขนเงนเดอน
* @param id รอบการขนเงนเดอน
*/
function dialogClose(id: string) {
@ -232,7 +231,7 @@ function dialogClose(id: string) {
}
/**
* function ปเดท แถวตอหน
* งกปเดท แถวตอหน
* @param newPagination
*/
function updatePageSize(newPagination: NewPagination) {
@ -240,9 +239,7 @@ function updatePageSize(newPagination: NewPagination) {
rowsPerPage.value = newPagination.rowsPerPage;
}
/**
* callbackFunction ทำเมอมการอปเดท แถวตอหน แล fetch รายการรอบการขนเงนเดอน
*/
/** ฟังก์ชันทำเมื่อมีการอัปเดท แถวต่อหน้า แล้ว fetch รายการรอบการขึ้นเงินเดือน */
watch(
() => rowsPerPage.value,
() => {
@ -250,12 +247,12 @@ watch(
}
);
/** Hooklifecycle*/
/** Hooklifecycle */
onMounted(async () => {
year.value = new Date().getFullYear();
getData();
dataStore.visibleColumns = visibleColumns.value;
dataStore.columns = columns.value;
getData();
});
</script>
@ -358,7 +355,7 @@ onMounted(async () => {
<template v-slot:pagination="scope">
งหมด {{ totalList?.toLocaleString() }} รายการ
<q-pagination
v-model="currentPage"
v-model="page"
active-color="primary"
color="dark"
:max="Number(maxPage)"
@ -481,7 +478,7 @@ onMounted(async () => {
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'no'">
{{
(currentPage - 1) * Number(pagination.rowsPerPage) +
(page - 1) * Number(pagination.rowsPerPage) +
props.rowIndex +
1
}}