แก้ไข max-page // page api ของประวัติการลา
*api ยังไม่ได้ส่ง total มาเลยคำนวน max-page ไม่ได้เลย setค่าไว้ 5 เพื่อรอ api
This commit is contained in:
parent
a95c320cf5
commit
9ed15251f9
2 changed files with 37 additions and 14 deletions
|
|
@ -9,6 +9,7 @@ import { useChekIn } from '@/stores/chekin'
|
||||||
import Popup from '@/components/PopUp.vue'
|
import Popup from '@/components/PopUp.vue'
|
||||||
|
|
||||||
const stores = useChekIn()
|
const stores = useChekIn()
|
||||||
|
const selected = ref<string[]>([])
|
||||||
|
|
||||||
/** props from page */
|
/** props from page */
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
|
@ -16,6 +17,10 @@ const props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
defualt: false,
|
defualt: false,
|
||||||
},
|
},
|
||||||
|
selected: {
|
||||||
|
type: Array,
|
||||||
|
defualt: [],
|
||||||
|
},
|
||||||
pageSize: {
|
pageSize: {
|
||||||
type: Number,
|
type: Number,
|
||||||
defualt: 10,
|
defualt: 10,
|
||||||
|
|
@ -84,7 +89,7 @@ const initialPagination = ref<any>({
|
||||||
sortBy: null,
|
sortBy: null,
|
||||||
descending: false,
|
descending: false,
|
||||||
page: 1,
|
page: 1,
|
||||||
rowsPerPage: props.pageSize,
|
rowsPerPage: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Pagination - update rowsPerPage
|
// Pagination - update rowsPerPage
|
||||||
|
|
@ -157,7 +162,7 @@ const columns = ref<QTableProps['columns']>([
|
||||||
field: 'checkOutStatus',
|
field: 'checkOutStatus',
|
||||||
headerStyle: 'font-size: 14px',
|
headerStyle: 'font-size: 14px',
|
||||||
style: 'font-size: 14px; width:15%;',
|
style: 'font-size: 14px; width:15%;',
|
||||||
}
|
},
|
||||||
])
|
])
|
||||||
// popup
|
// popup
|
||||||
const modalPopup = ref<boolean>(false)
|
const modalPopup = ref<boolean>(false)
|
||||||
|
|
@ -187,11 +192,6 @@ function classStatus(status: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const pagination = ref({
|
|
||||||
page: 1,
|
|
||||||
rowsPerPage: 2,
|
|
||||||
})
|
|
||||||
|
|
||||||
const checkRequestEdit = (checkInStatus: string, checkOutStatus: string) => {
|
const checkRequestEdit = (checkInStatus: string, checkOutStatus: string) => {
|
||||||
if (
|
if (
|
||||||
checkInStatus === 'ขาด' ||
|
checkInStatus === 'ขาด' ||
|
||||||
|
|
@ -212,10 +212,11 @@ const checkRequestEdit = (checkInStatus: string, checkOutStatus: string) => {
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:rows="stores.rows"
|
:rows="stores.rows"
|
||||||
virtual-scroll
|
virtual-scroll
|
||||||
|
v-model:selected="selected"
|
||||||
:virtual-scroll-sticky-size-start="48"
|
:virtual-scroll-sticky-size-start="48"
|
||||||
:style="$q.screen.gt.xs ? 'max-height: 64vh' : ''"
|
:style="$q.screen.gt.xs ? 'max-height: 64vh' : ''"
|
||||||
:grid="$q.screen.gt.xs ? false : true"
|
:grid="$q.screen.gt.xs ? false : true"
|
||||||
v-model:pagination="pagination"
|
:pagination="initialPagination"
|
||||||
@update:pagination="updatePagination"
|
@update:pagination="updatePagination"
|
||||||
>
|
>
|
||||||
<template v-slot:header="props">
|
<template v-slot:header="props">
|
||||||
|
|
@ -336,9 +337,9 @@ const checkRequestEdit = (checkInStatus: string, checkOutStatus: string) => {
|
||||||
</q-card>
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:pagination="scope">
|
<!-- <template v-slot:pagination="scope">
|
||||||
<q-pagination
|
<q-pagination
|
||||||
v-model="pagination.page"
|
v-model="currentPage"
|
||||||
active-color="primary"
|
active-color="primary"
|
||||||
color="dark"
|
color="dark"
|
||||||
:max="scope.pagesNumber"
|
:max="scope.pagesNumber"
|
||||||
|
|
@ -347,6 +348,19 @@ const checkRequestEdit = (checkInStatus: string, checkOutStatus: string) => {
|
||||||
boundary-links
|
boundary-links
|
||||||
direction-links
|
direction-links
|
||||||
></q-pagination>
|
></q-pagination>
|
||||||
|
</template> -->
|
||||||
|
<template v-slot:pagination="scope">
|
||||||
|
ทั้งหมด {{ props.total }} รายการ
|
||||||
|
<q-pagination
|
||||||
|
v-model="currentPage"
|
||||||
|
active-color="primary"
|
||||||
|
color="dark"
|
||||||
|
:max-pages="5"
|
||||||
|
size="sm"
|
||||||
|
boundary-links
|
||||||
|
direction-links
|
||||||
|
:max="Number(props.maxPage)"
|
||||||
|
></q-pagination>
|
||||||
</template>
|
</template>
|
||||||
</q-table>
|
</q-table>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,16 +18,23 @@ const { fetchHistoryList } = stores
|
||||||
const $q = useQuasar() //ใช้ noti quasar
|
const $q = useQuasar() //ใช้ noti quasar
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
fetchlistHistory()
|
// fetchlistHistory()
|
||||||
})
|
})
|
||||||
|
|
||||||
// paging
|
// paging
|
||||||
const page = ref<number>(1)
|
const page = ref<number>(1)
|
||||||
const year = ref<number>(2023)
|
const year = ref<number>(2023)
|
||||||
const pageSize = ref<number>(25)
|
const pageSize = ref<number>(5)
|
||||||
const total = ref<number>(0)
|
const total = ref<number>(0)
|
||||||
const maxPage = ref<number>(1)
|
const maxPage = ref<number>(5)
|
||||||
const filter = ref<string>('') //search data table
|
const filter = ref<string>('') //search data table
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชั่น api เปลี่ยนหน้า
|
||||||
|
* @param pageVal page
|
||||||
|
* @param pageSizeVal pagesize
|
||||||
|
* @param loading loading
|
||||||
|
*/
|
||||||
async function changePage(
|
async function changePage(
|
||||||
pageVal: number,
|
pageVal: number,
|
||||||
pageSizeVal: number,
|
pageSizeVal: number,
|
||||||
|
|
@ -49,7 +56,7 @@ const fetchlistHistory = async (loading = true) => {
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
const data = res.data.result
|
const data = res.data.result
|
||||||
total.value = data.total
|
total.value = data.total
|
||||||
maxPage.value = await Math.ceil(data.total / pageSize.value)
|
// maxPage.value = await Math.ceil(data.total / pageSize.value)
|
||||||
fetchHistoryList(data)
|
fetchHistoryList(data)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|
@ -58,6 +65,7 @@ const fetchlistHistory = async (loading = true) => {
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
hideLoader()
|
hideLoader()
|
||||||
})
|
})
|
||||||
|
console.log(maxPage.value)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -89,6 +97,7 @@ const fetchlistHistory = async (loading = true) => {
|
||||||
:page-size="pageSize"
|
:page-size="pageSize"
|
||||||
:total="total"
|
:total="total"
|
||||||
:page="page"
|
:page="page"
|
||||||
|
:paging="true"
|
||||||
:changePage="changePage"
|
:changePage="changePage"
|
||||||
:max-page="maxPage"
|
:max-page="maxPage"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue