fix bug pagintion ==> ระบบเปลี่ยนแปลงรอบการปฏิบัติงานของผู้ใช้งาน
This commit is contained in:
parent
0c91be9173
commit
b28f759ac7
3 changed files with 43 additions and 29 deletions
|
|
@ -68,8 +68,8 @@ const pageSize = ref<number>(10);
|
|||
const initialPagination = ref<any>({
|
||||
sortBy: null,
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: pageSize, // set ตาม page หลักส่งมา
|
||||
page: dataStore.page,
|
||||
rowsPerPage: dataStore.pageSize, // set ตาม page หลักส่งมา
|
||||
});
|
||||
|
||||
// Pagination - page & change page & get new data
|
||||
|
|
@ -77,7 +77,7 @@ const currentPage = ref<number>(1);
|
|||
const roundOp = ref<any>([]);
|
||||
async function updatePagination(newPagination: any) {
|
||||
initialPagination.value = newPagination;
|
||||
currentPage.value = 1; // set current page เป็น 1 เสมอเมื่อเปลี่ยน per row
|
||||
// currentPage.value = 1; // set current page เป็น 1 เสมอเมื่อเปลี่ยน per row
|
||||
}
|
||||
|
||||
/** Function validateForm */
|
||||
|
|
@ -103,7 +103,7 @@ function onSubmit() {
|
|||
$q,
|
||||
() => {
|
||||
changeRound();
|
||||
props.closeDialog?.();
|
||||
// props.closeDialog?.();
|
||||
},
|
||||
"ยืนยันการบันทึกข้อมูล",
|
||||
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
|
||||
|
|
@ -112,6 +112,7 @@ function onSubmit() {
|
|||
|
||||
/** Function เปลี่ยนรอบเวลา*/
|
||||
async function changeRound() {
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.leaveRound(), {
|
||||
profileId: props.personId,
|
||||
|
|
@ -121,12 +122,13 @@ async function changeRound() {
|
|||
})
|
||||
.then(() => {
|
||||
success($q, "บันทึกข้อมูลเปลี่ยนรอบเวลา");
|
||||
props.closeDialog?.();
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
props.closeDialog?.();
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -135,7 +137,7 @@ async function changeRound() {
|
|||
*
|
||||
*/
|
||||
async function fetchDataOption() {
|
||||
showLoader();
|
||||
props.editCheck !== "history" && showLoader();
|
||||
await http
|
||||
.get(config.API.leaveRound())
|
||||
.then((res) => {
|
||||
|
|
@ -156,7 +158,7 @@ async function fetchDataOption() {
|
|||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
props.editCheck !== "history" && hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -168,8 +170,9 @@ function close() {
|
|||
}
|
||||
|
||||
watch(
|
||||
[() => currentPage.value, () => initialPagination.value.rowsPerPage],
|
||||
() => initialPagination.value.rowsPerPage,
|
||||
() => {
|
||||
currentPage.value = 1;
|
||||
emit(
|
||||
"update:change-page",
|
||||
currentPage.value,
|
||||
|
|
@ -179,6 +182,15 @@ watch(
|
|||
}
|
||||
);
|
||||
|
||||
function nextPage() {
|
||||
emit(
|
||||
"update:change-page",
|
||||
currentPage.value,
|
||||
initialPagination.value.rowsPerPage,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modal,
|
||||
async () => {
|
||||
|
|
@ -188,6 +200,7 @@ watch(
|
|||
formData.effectiveDate = null;
|
||||
}
|
||||
if (props.modal === true) {
|
||||
currentPage.value = 1;
|
||||
await fetchDataOption();
|
||||
}
|
||||
}
|
||||
|
|
@ -355,7 +368,7 @@ watch(
|
|||
dense
|
||||
class="custom-header-table"
|
||||
:visible-columns="dataStore.visibleColumnsHistory"
|
||||
:rows-per-page-options="[5, 10, 25, 50, 100]"
|
||||
:rows-per-page-options="[1, 10, 25, 50, 100]"
|
||||
:pagination="initialPagination"
|
||||
@update:pagination="updatePagination"
|
||||
>
|
||||
|
|
@ -370,6 +383,7 @@ watch(
|
|||
boundary-links
|
||||
direction-links
|
||||
:max="Number(dataStore.maxPage)"
|
||||
@update:model-value="nextPage"
|
||||
></q-pagination>
|
||||
</template>
|
||||
<template v-slot:header="props">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue