fix: pageing

This commit is contained in:
setthawutttty 2025-09-24 11:37:49 +07:00
parent 33e7877e6e
commit c8d061e43a
3 changed files with 13 additions and 6 deletions

View file

@ -15,6 +15,7 @@ const props = defineProps({
fetchData: Function, fetchData: Function,
count: Number, count: Number,
totalList: Number, totalList: Number,
total: Number,
pass: Number, pass: Number,
notpass: Number, notpass: Number,
missed_exam: Number, missed_exam: Number,
@ -75,8 +76,8 @@ function updatePagination(newPagination: any) {
} }
} }
function getList(enter?: any) { function getList(enter?: string) {
if (enter) { if (enter == "enter") {
pagination.value.page = 1; pagination.value.page = 1;
props.fetchData?.(); props.fetchData?.();
} else { } else {
@ -193,7 +194,7 @@ watch(
placeholder="ค้นหา" placeholder="ค้นหา"
style="max-width: 200px" style="max-width: 200px"
@keydown.enter.prevent=" @keydown.enter.prevent="
nornmalData ? props.onSearch?.() : getList(true) nornmalData ? props.onSearch?.() : getList('enter')
" "
> >
<template v-slot:append> <template v-slot:append>
@ -245,7 +246,7 @@ watch(
<slot v-bind="props" name="columns"></slot> <slot v-bind="props" name="columns"></slot>
</template> </template>
<template v-if="!nornmalData" v-slot:pagination="scope"> <template v-if="!nornmalData" v-slot:pagination="scope">
งหมด {{ props.count && props.count.toLocaleString() }} รายการ งหมด {{ props.total?.toLocaleString() }} รายการ
<q-pagination <q-pagination
v-model="pagination.page" v-model="pagination.page"
active-color="primary" active-color="primary"

View file

@ -30,6 +30,7 @@ const year = ref<string>("");
const round = ref<string>(""); const round = ref<string>("");
const name = ref<string>(""); const name = ref<string>("");
const count = ref<number>(0); const count = ref<number>(0);
const total = ref<number>(0);
const totalList = ref<number>(0); const totalList = ref<number>(0);
const pass = ref<number>(0); const pass = ref<number>(0);
const notpass = ref<number>(0); const notpass = ref<number>(0);
@ -368,8 +369,9 @@ async function fetchData() {
notpass.value = header.notpass; notpass.value = header.notpass;
missed_exam.value = header.missed_exam; missed_exam.value = header.missed_exam;
other.value = header.other; other.value = header.other;
total.value = res.data.result.total;
totalList.value = Math.ceil( totalList.value = Math.ceil(
header.count / initialPagination.value.rowsPerPage res.data.result.total / initialPagination.value.rowsPerPage
); );
if (period != null) { if (period != null) {
name.value = period.name; name.value = period.name;
@ -505,6 +507,7 @@ onMounted(async () => {
v-model:inputfilter="filter" v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns" v-model:inputvisible="visibleColumns"
v-model:totalList="totalList" v-model:totalList="totalList"
v-model:total="total"
v-model:pagination="initialPagination" v-model:pagination="initialPagination"
:nornmalData="false" :nornmalData="false"
:conclude="true" :conclude="true"

View file

@ -36,6 +36,7 @@ const pass = ref<number>(0);
const notpass = ref<number>(0); const notpass = ref<number>(0);
const missed_exam = ref<number>(0); const missed_exam = ref<number>(0);
const other = ref<number>(0); const other = ref<number>(0);
const total = ref<number>(0);
const totalList = ref<number>(0); const totalList = ref<number>(0);
const importId = ref<string>(route.params.id as string); // Period Import Id const importId = ref<string>(route.params.id as string); // Period Import Id
@ -310,8 +311,9 @@ async function fetchData() {
notpass.value = header.notpass; notpass.value = header.notpass;
missed_exam.value = header.missed_exam; missed_exam.value = header.missed_exam;
other.value = header.other; other.value = header.other;
total.value = res.data.result.total;
totalList.value = Math.ceil( totalList.value = Math.ceil(
header.count / initialPagination.value.rowsPerPage res.data.result.total / initialPagination.value.rowsPerPage
); );
const data = res.data.result.data; const data = res.data.result.data;
let result: RecruitDetailResponse[] = []; let result: RecruitDetailResponse[] = [];
@ -444,6 +446,7 @@ onMounted(async () => {
:pagination="initialPagination" :pagination="initialPagination"
:visible-columns="visibleColumns" :visible-columns="visibleColumns"
v-model:inputfilter="filter" v-model:inputfilter="filter"
v-model:total="total"
v-model:inputvisible="visibleColumns" v-model:inputvisible="visibleColumns"
:nornmalData="false" :nornmalData="false"
:conclude="true" :conclude="true"