fix
This commit is contained in:
parent
3f79bde543
commit
3cb02c2896
1 changed files with 16 additions and 13 deletions
|
|
@ -206,7 +206,6 @@ async function confirm() {
|
|||
.then(async (res) => {
|
||||
const data = await res.data.result
|
||||
const dateObject = new Date(data.date)
|
||||
localStorage.setItem('taskid', data.taskId)
|
||||
const options: Intl.DateTimeFormatOptions = {
|
||||
hour12: false,
|
||||
hour: '2-digit',
|
||||
|
|
@ -234,7 +233,8 @@ async function onClickConfirm() {
|
|||
stetusCheckin.value = true
|
||||
}
|
||||
|
||||
await fetchCheckTime()
|
||||
// await fetchCheckTime()
|
||||
// fetchCheckStatus()
|
||||
startChecking()
|
||||
|
||||
cameraIsOn.value = false
|
||||
|
|
@ -262,20 +262,17 @@ const getClass = (val: boolean) => {
|
|||
const inQueue = ref<boolean>(false)
|
||||
|
||||
async function fetchCheckStatus() {
|
||||
// let taskId = localStorage.getItem('taskid')
|
||||
// console.log(taskId)
|
||||
// if (!taskId) return
|
||||
try {
|
||||
const res = await http.get(config.API.checkStatus())
|
||||
inQueue.value = res.data.result.inQueue
|
||||
if (res.data.result.inQueue) {
|
||||
isDisabledCheckTime.value = true
|
||||
msgCheckTime.value = 'กำลังดำเนินงาน'
|
||||
msgCheckTime.value = 'ระบบกำลังประมวลผล'
|
||||
hideLoader()
|
||||
} else {
|
||||
isDisabledCheckTime.value = false
|
||||
msgCheckTime.value = ''
|
||||
stopChecking() // หยุดการทำงาน
|
||||
fetchCheckTime()
|
||||
console.log('Response เป็น false, หยุด interval')
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -285,17 +282,23 @@ async function fetchCheckStatus() {
|
|||
}
|
||||
const intervalId = ref<number | undefined>(undefined) // ต้องใช้ตัวแปรเก็บค่า interval
|
||||
|
||||
function startChecking() {
|
||||
async function startChecking() {
|
||||
showLoader()
|
||||
fetchCheckStatus()
|
||||
if (intervalId.value === undefined) {
|
||||
// ป้องกันการสร้าง interval ซ้ำ
|
||||
intervalId.value = setInterval(fetchCheckStatus, 3000)
|
||||
intervalId.value = setInterval(async () => {
|
||||
await fetchCheckStatus() // รอให้ fetchCheckStatus ทำงานเสร็จก่อน
|
||||
}, 3000)
|
||||
}
|
||||
}
|
||||
|
||||
function stopChecking() {
|
||||
async function stopChecking() {
|
||||
if (intervalId.value !== undefined) {
|
||||
clearInterval(intervalId.value) // หยุด interval
|
||||
fetchCheckTime()
|
||||
setTimeout(() => {
|
||||
fetchCheckTime()
|
||||
}, 1000)
|
||||
intervalId.value = undefined // รีเซ็ตค่า
|
||||
}
|
||||
}
|
||||
|
|
@ -320,14 +323,14 @@ onMounted(async () => {
|
|||
</strong> -->
|
||||
<!-- <strong v-else style="font-size: 1rem">ลงเวลาออกงาน</strong> -->
|
||||
<strong v-if="!stetusCheckin && inQueue" style="font-size: 1rem">
|
||||
ลงเวลาออกงาน (รอประมวลผล)
|
||||
ลงเวลาออกงาน (ระบบกำลังประมวลผล)
|
||||
</strong>
|
||||
|
||||
<strong
|
||||
v-else-if="stetusCheckin && inQueue"
|
||||
style="font-size: 1rem"
|
||||
>
|
||||
ลงเวลาเข้างาน (รอประมวลผล)
|
||||
ลงเวลาเข้างาน (ระบบกำลังประมวลผล)
|
||||
</strong>
|
||||
|
||||
<strong
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue