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