diff --git a/src/modules/12_evaluatePersonal/views/MainPage.vue b/src/modules/12_evaluatePersonal/views/MainPage.vue index f1cb849e3..58629cc7e 100644 --- a/src/modules/12_evaluatePersonal/views/MainPage.vue +++ b/src/modules/12_evaluatePersonal/views/MainPage.vue @@ -25,9 +25,9 @@ function Detailpage(id: string) { } const currentPage = ref(1); -const pageSize = ref(10); const maxPage = ref(1); const page = ref(1); +const total = ref(0); const filter = ref(""); const rowsPerPage = ref(10); /** @@ -39,6 +39,13 @@ const pagination = ref({ rowsPerPage: rowsPerPage.value, }); +// Pagination - update rowsPerPage +async function updatePagination(initialPagination: any) { + currentPage.value = 1; + rowsPerPage.value = initialPagination.rowsPerPage; + page.value = 1; // set current page เป็น 1 เสมอเมื่อเปลี่ยน per row +} + watch( () => currentPage.value, () => { @@ -69,8 +76,14 @@ function getList() { filter.value ) ) - .then((res) => { - maxPage.value = Math.ceil(res.data.result.total / rowsPerPage.value); + .then(async (res) => { + total.value = res.data.result.total; + maxPage.value = await Math.ceil(total.value / rowsPerPage.value); + maxPage.value = maxPage.value < 1 ? 1 : maxPage.value; + console.log(res.data.result.total); + console.log(rowsPerPage.value); + console.log(maxPage.value); + const data = res.data.result.data; store.fetchData(data); }) @@ -142,19 +155,27 @@ onMounted(async () => { :paging="true" dense class="custom-header-table" - v-bind="attrs" :visible-columns="store.visibleColumns" v-model:pagination="pagination" + :rows-per-page-options="[10, 25, 50, 100]" + @update:pagination="updatePagination" > +