This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-01-29 18:11:14 +07:00
parent 3f79bde543
commit 3cb02c2896

View file

@ -206,7 +206,6 @@ async function confirm() {
.then(async (res) => { .then(async (res) => {
const data = await res.data.result const data = await res.data.result
const dateObject = new Date(data.date) const dateObject = new Date(data.date)
localStorage.setItem('taskid', data.taskId)
const options: Intl.DateTimeFormatOptions = { const options: Intl.DateTimeFormatOptions = {
hour12: false, hour12: false,
hour: '2-digit', hour: '2-digit',
@ -234,7 +233,8 @@ async function onClickConfirm() {
stetusCheckin.value = true stetusCheckin.value = true
} }
await fetchCheckTime() // await fetchCheckTime()
// fetchCheckStatus()
startChecking() startChecking()
cameraIsOn.value = false cameraIsOn.value = false
@ -262,20 +262,17 @@ const getClass = (val: boolean) => {
const inQueue = ref<boolean>(false) const inQueue = ref<boolean>(false)
async function fetchCheckStatus() { async function fetchCheckStatus() {
// let taskId = localStorage.getItem('taskid')
// console.log(taskId)
// if (!taskId) return
try { try {
const res = await http.get(config.API.checkStatus()) const res = await http.get(config.API.checkStatus())
inQueue.value = res.data.result.inQueue inQueue.value = res.data.result.inQueue
if (res.data.result.inQueue) { if (res.data.result.inQueue) {
isDisabledCheckTime.value = true isDisabledCheckTime.value = true
msgCheckTime.value = 'กำลังดำเนินงาน' msgCheckTime.value = 'ระบบกำลังประมวลผล'
hideLoader()
} else { } else {
isDisabledCheckTime.value = false isDisabledCheckTime.value = false
msgCheckTime.value = '' msgCheckTime.value = ''
stopChecking() // stopChecking() //
fetchCheckTime()
console.log('Response เป็น false, หยุด interval') console.log('Response เป็น false, หยุด interval')
} }
} catch (error) { } catch (error) {
@ -285,17 +282,23 @@ async function fetchCheckStatus() {
} }
const intervalId = ref<number | undefined>(undefined) // interval const intervalId = ref<number | undefined>(undefined) // interval
function startChecking() { async function startChecking() {
showLoader()
fetchCheckStatus()
if (intervalId.value === undefined) { if (intervalId.value === undefined) {
// interval // interval
intervalId.value = setInterval(fetchCheckStatus, 3000) intervalId.value = setInterval(async () => {
await fetchCheckStatus() // fetchCheckStatus
}, 3000)
} }
} }
function stopChecking() { async function stopChecking() {
if (intervalId.value !== undefined) { if (intervalId.value !== undefined) {
clearInterval(intervalId.value) // interval clearInterval(intervalId.value) // interval
fetchCheckTime() setTimeout(() => {
fetchCheckTime()
}, 1000)
intervalId.value = undefined // intervalId.value = undefined //
} }
} }
@ -320,14 +323,14 @@ onMounted(async () => {
</strong> --> </strong> -->
<!-- <strong v-else style="font-size: 1rem">ลงเวลาออกงาน</strong> --> <!-- <strong v-else style="font-size: 1rem">ลงเวลาออกงาน</strong> -->
<strong v-if="!stetusCheckin && inQueue" style="font-size: 1rem"> <strong v-if="!stetusCheckin && inQueue" style="font-size: 1rem">
ลงเวลาออกงาน (ประมวลผล) ลงเวลาออกงาน (ะบบกำลประมวลผล)
</strong> </strong>
<strong <strong
v-else-if="stetusCheckin && inQueue" v-else-if="stetusCheckin && inQueue"
style="font-size: 1rem" style="font-size: 1rem"
> >
ลงเวลาเขางาน (ประมวลผล) ลงเวลาเขางาน (ะบบกำลประมวลผล)
</strong> </strong>
<strong <strong