ปรับ paging ประวัติการลงเวลา
This commit is contained in:
parent
21e1016cae
commit
5cca23b11d
2 changed files with 30 additions and 17 deletions
|
|
@ -18,15 +18,15 @@ const { fetchHistoryList } = stores
|
|||
const $q = useQuasar() //ใช้ noti quasar
|
||||
|
||||
onMounted(() => {
|
||||
// fetchlistHistory()
|
||||
fetchlistHistory()
|
||||
})
|
||||
|
||||
// paging
|
||||
const page = ref<number>(1)
|
||||
const year = ref<number>(2023)
|
||||
const pageSize = ref<number>(5)
|
||||
const pageSize = ref<number>(2)
|
||||
const total = ref<number>(0)
|
||||
const maxPage = ref<number>(5)
|
||||
const maxPage = ref<number>(1)
|
||||
const filter = ref<string>('') //search data table
|
||||
|
||||
/**
|
||||
|
|
@ -45,7 +45,10 @@ async function changePage(
|
|||
fetchlistHistory(loading)
|
||||
}
|
||||
|
||||
//นำข้อมูลมาแสดง
|
||||
/**
|
||||
* ฟังก์ชั่นดึงข้อมูลรายการประวัติการลงเวลาจาก api มาแสดง
|
||||
* @param loading แสดง loading ไหม true คือแสดง, false คือไม่แสดง
|
||||
*/
|
||||
const fetchlistHistory = async (loading = true) => {
|
||||
loading === true ?? showLoader()
|
||||
await http
|
||||
|
|
@ -55,9 +58,11 @@ const fetchlistHistory = async (loading = true) => {
|
|||
)
|
||||
.then(async (res) => {
|
||||
const data = res.data.result
|
||||
total.value = data.total
|
||||
// maxPage.value = await Math.ceil(data.total / pageSize.value)
|
||||
fetchHistoryList(data)
|
||||
total.value = data.total ? data.total : 5
|
||||
maxPage.value = await Math.ceil(total.value / pageSize.value)
|
||||
maxPage.value = maxPage.value < 1 ? 1 : maxPage.value
|
||||
fetchHistoryList(data) // ปิดกรณีมี total
|
||||
// fetchHistoryList(data.data) // เปิดกรณีมี total
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err)
|
||||
|
|
@ -65,7 +70,6 @@ const fetchlistHistory = async (loading = true) => {
|
|||
.finally(() => {
|
||||
hideLoader()
|
||||
})
|
||||
console.log(maxPage.value)
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
|
|
@ -98,7 +102,7 @@ const fetchlistHistory = async (loading = true) => {
|
|||
:total="total"
|
||||
:page="page"
|
||||
:paging="true"
|
||||
:changePage="changePage"
|
||||
@update:change-page="changePage"
|
||||
:max-page="maxPage"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue