From 9b03f293535ef87ba0d84aa1b7480d8d11639a83 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 5 Aug 2025 17:46:43 +0700 Subject: [PATCH] fix Load --- src/components/SkeletonTable.vue | 120 +++++++++++++++++++++++++++++++ src/components/TableHistory.vue | 21 +++--- src/views/HistoryView.vue | 19 +++-- src/views/HomeView.vue | 43 ++++++++--- 4 files changed, 175 insertions(+), 28 deletions(-) create mode 100644 src/components/SkeletonTable.vue diff --git a/src/components/SkeletonTable.vue b/src/components/SkeletonTable.vue new file mode 100644 index 0000000..66c6b27 --- /dev/null +++ b/src/components/SkeletonTable.vue @@ -0,0 +1,120 @@ + + + + + diff --git a/src/components/TableHistory.vue b/src/components/TableHistory.vue index 8e42f01..5d13e66 100644 --- a/src/components/TableHistory.vue +++ b/src/components/TableHistory.vue @@ -4,17 +4,16 @@ import { ref, watch } from 'vue' import { useCounterMixin } from '@/stores/mixin' import { useChekIn } from '@/stores/chekin' -import type { QTableProps } from 'quasar' +import { is, type QTableProps } from 'quasar' import type { Pagination, DataCheckIn } from '@/interface/index/Main' import Popup from '@/components/PopUp.vue' // dialog เพิ่ม/ขอแก้ไขลงเวลากรณีพิเศษ -const { date2Thai } = useCounterMixin() +import SkeletonTable from '@/components/SkeletonTable.vue' // skeleton table +const { date2Thai } = useCounterMixin() const stores = useChekIn() -/** - * props ข้อมูลจาก Components Page HistoryView - */ +/** props ข้อมูลจาก Components Page HistoryView */ const props = defineProps({ paging: { type: Boolean, @@ -49,9 +48,12 @@ const props = defineProps({ type: Function, default: () => console.log('not function'), }, + isLoading: { + type: Boolean, + default: false, + }, }) const emit = defineEmits(['update:change-page']) - const keyword = ref('') const tab = ref(props.tab?.toString()) const selected = ref([]) @@ -270,9 +272,7 @@ function onClickOpenPopupRejrct(data: DataCheckIn) { } } -/** - * watch currentPage และ rowsPerPage - */ +/** watch currentPage และ rowsPerPage*/ watch( [() => currentPage.value, () => initialPagination.value.rowsPerPage], () => { @@ -322,7 +322,10 @@ watch( + + (10) // จำนวนแถวต่อหน้ const total = ref(0) // จำนวนทั้งหมด const maxPage = ref(1) // จำนวนวหน้าทั้งหมด const filter = ref('') //search data table +const isLoading = ref(false) // ตัวแปรสำหรับเช็คการโหลดข้อมูล /** * ฟังก์ชั่น api เปลี่ยนหน้า @@ -38,19 +39,15 @@ async function changePage(pageVal: number, pageSizeVal: number, key: string) { await functionFetch() } -/** - * ฟังก์ชันสำหรับดึงข้อมูลตามประเภทแท็บที่เลือก - */ +/** ฟังก์ชันสำหรับดึงข้อมูลตามประเภทแท็บที่เลือก*/ async function functionFetch() { stores.rows = [] stores.tab === 'history' ? await fetchlistHistory() : await fetchlistTime() } -/*** - * ฟังก์ชั่นดึงข้อมูลรายการประวัติการลงเวลา - */ +/** ฟังก์ชั่นดึงข้อมูลรายการประวัติการลงเวลา*/ async function fetchlistHistory() { - showLoader() + isLoading.value = true await http .get( config.API.history() + @@ -72,7 +69,7 @@ async function fetchlistHistory() { messageError($q, err) }) .finally(() => { - hideLoader() + isLoading.value = false }) } @@ -80,7 +77,7 @@ async function fetchlistHistory() { * ฟังก์ชั่นดึงรายการลงเวลากรณีพิเศษ */ async function fetchlistTime() { - showLoader() + isLoading.value = true await http .get( config.API.historyTime() + @@ -104,7 +101,7 @@ async function fetchlistTime() { messageError($q, err) }) .finally(() => { - hideLoader() + isLoading.value = false }) } @@ -193,6 +190,7 @@ onMounted(() => { @update:change-page="changePage" :max-page="maxPage" :tab="stores.tab" + :is-loading="isLoading" /> @@ -211,6 +209,7 @@ onMounted(() => { @update:change-page="changePage" :max-page="maxPage" :tab="stores.tab" + :is-loading="isLoading" /> diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 894d30c..e4f5e16 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -1,6 +1,6 @@