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) => {
|
.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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue