fix Load
This commit is contained in:
parent
41c453cd23
commit
9b03f29353
4 changed files with 175 additions and 28 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { is, useQuasar } from 'quasar'
|
||||
import moment from 'moment'
|
||||
import Camera from 'simple-vue-camera'
|
||||
|
||||
|
|
@ -26,11 +26,13 @@ const isDisabledCheckTime = ref<boolean>(false) // ข้อความแจ
|
|||
const isErr = ref<boolean | null>(null) // ข้อความแจ้งเตือน
|
||||
const endTimeAfternoon = ref<string>('12:00:00') //เวลาเช็คเอาท์ตามรอบ
|
||||
|
||||
const isLoadingCheckTime = ref<boolean>(false) // ตัวแปรสำหรับการโหลด
|
||||
|
||||
/**
|
||||
* fetch เช็คเวลาต้องลงเวลาเข้าหรือออกงาน
|
||||
*/
|
||||
async function fetchCheckTime(load: any = true) {
|
||||
load && showLoader()
|
||||
if (load) isLoadingCheckTime.value = true
|
||||
await http
|
||||
.get(config.API.checkTime())
|
||||
.then(async (res) => {
|
||||
|
|
@ -48,7 +50,7 @@ async function fetchCheckTime(load: any = true) {
|
|||
} else messageError($q, err)
|
||||
})
|
||||
.finally(() => {
|
||||
load && hideLoader()
|
||||
if (load) isLoadingCheckTime.value = false
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -140,12 +142,12 @@ const intervalId = ref<number | undefined>(undefined) // ต้องใช้
|
|||
*/
|
||||
async function startChecking() {
|
||||
try {
|
||||
showLoader()
|
||||
// showLoader()
|
||||
await fetchCheckStatus()
|
||||
await fetchCheckTime()
|
||||
} catch (error) {
|
||||
console.error('Error in startChecking:', error)
|
||||
hideLoader()
|
||||
// hideLoader()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +159,6 @@ async function fetchCheckStatus() {
|
|||
try {
|
||||
const res = await http.get(config.API.checkStatus())
|
||||
inQueue.value = res.data.result.inQueue
|
||||
|
||||
if (res.data.result.inQueue) {
|
||||
/** inQueue เป็น true */
|
||||
isDisabledCheckTime.value = true
|
||||
|
|
@ -453,7 +454,7 @@ const inQueue = ref<boolean>(false)
|
|||
|
||||
/** Hook*/
|
||||
onMounted(async () => {
|
||||
// await fetchCheckTime()
|
||||
isLoadingCheckTime.value = true
|
||||
updateClock()
|
||||
startChecking() //เช็ค status จาก คิว #1
|
||||
mapRef.value?.requestLocationPermission()
|
||||
|
|
@ -471,7 +472,13 @@ onMounted(async () => {
|
|||
"
|
||||
>
|
||||
<!-- <q-header elevated class="bg-purple"> -->
|
||||
<div :class="getClass(statusCheckin)" class="gt-xs">
|
||||
<div
|
||||
class="col-12 q-pa-md items-center gt-xs"
|
||||
v-if="isLoadingCheckTime"
|
||||
>
|
||||
<q-skeleton type="QCard" width="100%" height="50px" />
|
||||
</div>
|
||||
<div v-else :class="getClass(statusCheckin)" class="gt-xs">
|
||||
<div class="col">
|
||||
<div class="row col-12 justify-center q-py-sm text-subtitle1">
|
||||
<strong v-if="!statusCheckin && inQueue">
|
||||
|
|
@ -490,6 +497,7 @@ onMounted(async () => {
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 text-grey-9">
|
||||
<div class="col-12 row justify-center">
|
||||
<div class="col-12 row q-pt-md justify-center gt-xs">
|
||||
|
|
@ -849,7 +857,24 @@ onMounted(async () => {
|
|||
|
||||
<!-- top page sticky หน้ามือถือ-->
|
||||
<q-page-sticky expand position="top" v-if="$q.screen.xs">
|
||||
<div :class="getClassXS(statusCheckin)">
|
||||
<div
|
||||
class="row q-col-gutter-sm col bg-white col-12 q-pa-md"
|
||||
style="height: 100px"
|
||||
v-if="isLoadingCheckTime"
|
||||
>
|
||||
<div class="col-7">
|
||||
<div class="row col-12">
|
||||
<q-skeleton type="text" width="90%" />
|
||||
<q-skeleton type="text" width="50%" class="text-subtitle1" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-5">
|
||||
<div class="row col-12">
|
||||
<q-skeleton type="QBtn" width="100%" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else :class="getClassXS(statusCheckin)">
|
||||
<div class="col">
|
||||
<div class="row col-12 justify-right items-center text-subtitle1">
|
||||
<strong v-if="!statusCheckin && inQueue">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue