fix CurrentPage ===> รายการเลื่อนค่าจ้างลูกจ้างประจำ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-07-08 11:19:40 +07:00
parent 2ce94f1ebb
commit d9f5661ac3
4 changed files with 49 additions and 26 deletions

View file

@ -382,7 +382,7 @@ watch(
bordered bordered
:paging="true" :paging="true"
dense dense
:rows-per-page-options="[1,10, 25, 50, 100]" :rows-per-page-options="[10, 25, 50, 100]"
:visible-columns="visibleColumns" :visible-columns="visibleColumns"
@update:pagination="updatePageSizePagination" @update:pagination="updatePageSizePagination"
> >

View file

@ -249,12 +249,7 @@ function fetchDataQuota(id: string) {
async function fetchDataPeriod(id: string) { async function fetchDataPeriod(id: string) {
showLoader(); showLoader();
let formData = { let formData = {
page: page: formFilter.page.toString(),
formFilter.page !== 1 &&
formFilter.page === maxPage.value &&
rows.value.length === 1
? (formFilter.page - 1).toString()
: formFilter.page.toString(),
pageSize: formFilter.pageSize.toString(), pageSize: formFilter.pageSize.toString(),
keyword: formFilter.keyword, keyword: formFilter.keyword,
type: store.tabType, type: store.tabType,

View file

@ -3,6 +3,7 @@ import { ref, watch, computed } 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 { useSalaryEmployeeListSDataStore } from "@/modules/13_salary/store/SalaryEmployeeListsStore"; import { useSalaryEmployeeListSDataStore } from "@/modules/13_salary/store/SalaryEmployeeListsStore";
import config from "@/app.config"; import config from "@/app.config";
@ -31,16 +32,18 @@ const maxPage = defineModel<Number>("maxPage", { required: true });
const isClose = defineModel<boolean>("isClose", { required: true }); const isClose = defineModel<boolean>("isClose", { required: true });
const snapShot = defineModel<string>("snapShot"); const snapShot = defineModel<string>("snapShot");
const props = defineProps({ const props = defineProps({
rows: { type: Array }, rows: { type: Array, required: true },
fetchDataTable: { fetchDataTable: {
type: Function, type: Function,
required: true,
}, },
total: { total: {
type: Number, type: Number,
required: true,
}, },
type: { type: {
type: String, type: String,
requird: true, required: true,
}, },
}); });
@ -197,7 +200,7 @@ const columns = computed(() => {
const modalDialogAddPerson = ref<boolean>(false); //popup const modalDialogAddPerson = ref<boolean>(false); //popup
const modalDialogForm = ref<boolean>(false); //popup const modalDialogForm = ref<boolean>(false); //popup
const modalDialogMoveGroup = ref<boolean>(false); //popup const modalDialogMoveGroup = ref<boolean>(false); //popup
const modalDialogMoveLeve = ref<boolean>(false); //popup const modalDialogMoveLevel = ref<boolean>(false); //popup
const profileId = ref<string>(""); //id const profileId = ref<string>(""); //id
const amount = ref<number>(0); // const amount = ref<number>(0); //
@ -246,7 +249,7 @@ function onClickMoveLevel(
remarkVal: string = "" remarkVal: string = ""
) { ) {
profileId.value = id; profileId.value = id;
modalDialogMoveLeve.value = !modalDialogMoveLeve.value; modalDialogMoveLevel.value = !modalDialogMoveLevel.value;
typeLevel.value = typeVal; typeLevel.value = typeVal;
isReserve.value = isReserveVal; isReserve.value = isReserveVal;
remark.value = typeVal === "NONE" ? remarkVal : ""; remark.value = typeVal === "NONE" ? remarkVal : "";
@ -262,7 +265,7 @@ function onClickDelete(id: string) {
await http await http
.delete(config.API.salaryListPeriodProfileByIdEmp(id)) .delete(config.API.salaryListPeriodProfileByIdEmp(id))
.then(async () => { .then(async () => {
await props.fetchDataTable?.(); await updateCurrentPageAndfetchData();
await success($q, "ลบข้อมูลสำเร็จ"); await success($q, "ลบข้อมูลสำเร็จ");
}) })
.catch((err) => { .catch((err) => {
@ -297,6 +300,16 @@ function searchData() {
props.fetchDataTable?.(); props.fetchDataTable?.();
} }
/** ฟังก์ชันอัปเดตหน้าปัจจุบันและดึงข้อมูล */
async function updateCurrentPageAndfetchData() {
formFilter.value.page = await updateCurrentPage(
formFilter.value.page,
Number(maxPage.value),
props.rows.length
);
await props.fetchDataTable?.();
}
/** /**
* callblack function เรยกขอมลรายชอใหม เมอมการเปลยน PageSize * callblack function เรยกขอมลรายชอใหม เมอมการเปลยน PageSize
*/ */
@ -376,7 +389,7 @@ watch(
bordered bordered
:paging="true" :paging="true"
dense dense
:rows-per-page-options="[10, 25, 50, 100]" :rows-per-page-options="[1,10, 25, 50, 100]"
:visible-columns="visibleColumns" :visible-columns="visibleColumns"
@update:pagination="updatePageSizePagination" @update:pagination="updatePageSizePagination"
> >
@ -556,13 +569,13 @@ watch(
<DialogMoveGroup <DialogMoveGroup
v-model:modal="modalDialogMoveGroup" v-model:modal="modalDialogMoveGroup"
v-model:profile-id="profileId" v-model:profile-id="profileId"
:fetch-data="props.fetchDataTable" :fetch-data="updateCurrentPageAndfetchData"
:group="store.tabGroup === 'group1' ? 'กลุ่ม1' : 'กลุ่ม2'" :group="store.tabGroup === 'group1' ? 'กลุ่ม1' : 'กลุ่ม2'"
/> />
<DialogMoveLevel <DialogMoveLevel
v-model:modal="modalDialogMoveLeve" v-model:modal="modalDialogMoveLevel"
v-model:profile-id="profileId" v-model:profile-id="profileId"
:fetch-data="props.fetchDataTable" :fetch-data="updateCurrentPageAndfetchData"
:type-level="typeLevel" :type-level="typeLevel"
:is-reserve="isReserve" :is-reserve="isReserve"
:type="store.tabType" :type="store.tabType"

View file

@ -3,6 +3,7 @@ import { ref, watch } 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 { useSalaryEmployeeListSDataStore } from "@/modules/13_salary/store/SalaryEmployeeListsStore"; import { useSalaryEmployeeListSDataStore } from "@/modules/13_salary/store/SalaryEmployeeListsStore";
import http from "@/plugins/http"; import http from "@/plugins/http";
@ -42,18 +43,22 @@ const isClose = defineModel<boolean>("isClose", { required: true });
const snapShot = defineModel<string>("snapShot"); const snapShot = defineModel<string>("snapShot");
const props = defineProps({ const props = defineProps({
rows: { type: Array }, rows: { type: Array, required: true },
fetchDataTable: { fetchDataTable: {
type: Function, type: Function,
required: true,
}, },
maxPage: { maxPage: {
type: Number, type: Number,
required: true,
}, },
total: { total: {
type: Number, type: Number,
required: true,
}, },
isRetire: { isRetire: {
type: Boolean, type: Boolean,
required: true,
}, },
}); });
@ -232,10 +237,10 @@ const visibleColumns = ref<string[]>([
const modalDialogAddPerson = ref<boolean>(false); //popup const modalDialogAddPerson = ref<boolean>(false); //popup
const modalDialogForm = ref<boolean>(false); //popup const modalDialogForm = ref<boolean>(false); //popup
const modalDialogMoveGroup = ref<boolean>(false); //popup const modalDialogMoveGroup = ref<boolean>(false); //popup
const modalDialogMoveLeve = ref<boolean>(false); //popup const modalDialogMoveLevel = ref<boolean>(false); //popup
const modalDialogProperties = ref<boolean>(false); //popup const modalDialogProperties = ref<boolean>(false); //popup
const modalDialogInfo = ref<boolean>(false); //popup const modalDialogInfo = ref<boolean>(false); //popup
const modalDialogMoveLeveMulti = ref<boolean>(false); //popup const modalDialogMoveLevelMulti = ref<boolean>(false); //popup
/** ตัวแปร*/ /** ตัวแปร*/
const profileId = ref<string>(""); //id const profileId = ref<string>(""); //id
@ -257,7 +262,7 @@ function onClickDelete(id: string) {
await http await http
.delete(config.API.salaryListPeriodProfileByIdEmp(id)) .delete(config.API.salaryListPeriodProfileByIdEmp(id))
.then(async () => { .then(async () => {
await props.fetchDataTable?.(); await updateCurrentPageAndfetchData();
await success($q, "ลบข้อมูลสำเร็จ"); await success($q, "ลบข้อมูลสำเร็จ");
}) })
.catch((err) => { .catch((err) => {
@ -303,7 +308,7 @@ function onClickMovieGroup(id: string) {
*/ */
function onClickMoveLevel(id: string, typeVal: string, isReserveVal: boolean) { function onClickMoveLevel(id: string, typeVal: string, isReserveVal: boolean) {
profileId.value = id; profileId.value = id;
modalDialogMoveLeve.value = !modalDialogMoveLeve.value; modalDialogMoveLevel.value = !modalDialogMoveLevel.value;
typeLevel.value = typeVal; typeLevel.value = typeVal;
isReserve.value = isReserveVal; isReserve.value = isReserveVal;
} }
@ -354,7 +359,17 @@ function onClickViewInfo(type: string, id: string) {
/** function openPopup ย้ายกขั้น*/ /** function openPopup ย้ายกขั้น*/
function onClickMoveLevelMulti() { function onClickMoveLevelMulti() {
modalDialogMoveLeveMulti.value = !modalDialogMoveLeve.value; modalDialogMoveLevelMulti.value = !modalDialogMoveLevel.value;
}
/** ฟังก์ชันอัปเดตหน้าปัจจุบันและดึงข้อมูล */
async function updateCurrentPageAndfetchData() {
formFilter.value.page = await updateCurrentPage(
formFilter.value.page,
props.maxPage,
props.rows.length
);
await props.fetchDataTable?.();
} }
/** /**
@ -604,15 +619,15 @@ watch(
<DialogMoveGroup <DialogMoveGroup
v-model:modal="modalDialogMoveGroup" v-model:modal="modalDialogMoveGroup"
v-model:profile-id="profileId" v-model:profile-id="profileId"
:fetch-data="props.fetchDataTable" :fetch-data="updateCurrentPageAndfetchData"
:group="store.tabGroup === 'group1' ? 'กลุ่ม1' : 'กลุ่ม2'" :group="store.tabGroup === 'group1' ? 'กลุ่ม1' : 'กลุ่ม2'"
/> />
<DialogMoveLevel <DialogMoveLevel
v-model:modal="modalDialogMoveLeve" v-model:modal="modalDialogMoveLevel"
v-model:profile-id="profileId" v-model:profile-id="profileId"
:type-level="typeLevel" :type-level="typeLevel"
:is-reserve="isReserve" :is-reserve="isReserve"
:fetch-data="props.fetchDataTable" :fetch-data="updateCurrentPageAndfetchData"
:remark="''" :remark="''"
/> />
<DialogProperties <DialogProperties
@ -634,7 +649,7 @@ watch(
<!-- เลอนขนเลอกหลายคน --> <!-- เลอนขนเลอกหลายคน -->
<DialogMoveLevelMulti <DialogMoveLevelMulti
v-model:modal="modalDialogMoveLeveMulti" v-model:modal="modalDialogMoveLevelMulti"
:fetch-data="props.fetchDataTable" :fetch-data="props.fetchDataTable"
:columns=" :columns="
columns.filter( columns.filter(