ประเมินบุคคล=> ปรับ paging
This commit is contained in:
parent
d04c6f30f5
commit
00d01ec986
3 changed files with 51 additions and 73 deletions
|
|
@ -42,35 +42,12 @@ const initialPagination = ref<any>({
|
|||
async function updatePagination(initialPagination: any) {
|
||||
currentPage.value = 1;
|
||||
pageSize.value = initialPagination.rowsPerPage;
|
||||
page.value = 1; // set current page เป็น 1 เสมอเมื่อเปลี่ยน per row
|
||||
}
|
||||
|
||||
/** function callback เมื่อมีการเปลี่ยนหน้า*/
|
||||
watch(
|
||||
[
|
||||
() => currentPage.value,
|
||||
() => (pageSize.value = initialPagination.value.rowsPerPage),
|
||||
],
|
||||
async () => {
|
||||
fetchEvaluteList();
|
||||
}
|
||||
);
|
||||
|
||||
/** function callback เมื่อมีการเปลี่ยนหน้า*/
|
||||
watch(
|
||||
[() => currentPage.value, () => initialPagination.value.rowsPerPage],
|
||||
async () => {
|
||||
page.value = currentPage.value;
|
||||
await fetchEvaluteList();
|
||||
}
|
||||
);
|
||||
|
||||
/** function callback เมื่อมีการเปลี่ยนจำนวนแถว*/
|
||||
watch(
|
||||
() => initialPagination.value.rowsPerPage,
|
||||
() => pageSize.value,
|
||||
() => {
|
||||
pageSize.value = initialPagination.value.rowsPerPage;
|
||||
currentPage.value = 1;
|
||||
fetchEvaluteList();
|
||||
}
|
||||
);
|
||||
|
|
@ -106,8 +83,7 @@ async function fetchEvaluteList() {
|
|||
.then(async (res) => {
|
||||
const data = res.data.result.data;
|
||||
total.value = res.data.result.total;
|
||||
maxPage.value = await Math.ceil(total.value / pageSize.value);
|
||||
maxPage.value = maxPage.value < 1 ? 1 : maxPage.value;
|
||||
maxPage.value = Math.ceil(total.value / pageSize.value);
|
||||
store.fetchData(data);
|
||||
})
|
||||
.catch((e) => {
|
||||
|
|
@ -268,7 +244,7 @@ onMounted(async () => {
|
|||
class="custom-header-table"
|
||||
:visible-columns="store.visibleColumns"
|
||||
v-model:pagination="initialPagination"
|
||||
:rows-per-page-options="[10, 25, 50, 100]"
|
||||
:rows-per-page-options="[1, 10, 25, 50, 100]"
|
||||
@update:pagination="updatePagination"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
|
|
@ -309,6 +285,8 @@ onMounted(async () => {
|
|||
size="sm"
|
||||
boundary-links
|
||||
direction-links
|
||||
:max-pages="5"
|
||||
@update:model-value="fetchEvaluteList"
|
||||
></q-pagination>
|
||||
</template>
|
||||
</d-table>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue