Merge branch 'develop'
* develop: fix fix เพิ่ม check Status fixing landing redirect fix
This commit is contained in:
commit
48d7bd016a
3 changed files with 102 additions and 52 deletions
|
|
@ -5,6 +5,7 @@ const urlFile = `${env.API_URI}/salary`
|
|||
export default {
|
||||
checkin: () => `${leave}/check-in`,
|
||||
checkTime: () => `${leave}/check-time`,
|
||||
checkStatus: () => `${leave}/check-status`,
|
||||
|
||||
keycloakLogSSO: `${env.API_URI}/org/keycloak/log/sso`,
|
||||
keycloakPosition: () => `${env.API_URI}/org/profile/keycloak/position`,
|
||||
|
|
|
|||
|
|
@ -51,9 +51,7 @@ const formattedS = ref()
|
|||
const formattedM = ref()
|
||||
const formattedH = ref()
|
||||
|
||||
/**
|
||||
* function อัพเดทเวลา
|
||||
*/
|
||||
/** function อัพเดทเวลา*/
|
||||
function updateClock() {
|
||||
const date = Date.now()
|
||||
const hh = moment(date).format('HH')
|
||||
|
|
@ -103,9 +101,7 @@ const options = ref<string[]>([
|
|||
'อื่นๆ',
|
||||
])
|
||||
|
||||
/**
|
||||
* function เลือกสถานที่
|
||||
*/
|
||||
/** function เลือกสถานที่*/
|
||||
function selectLocation() {
|
||||
if (model.value === 'อื่นๆ') {
|
||||
useLocation.value = ''
|
||||
|
|
@ -121,51 +117,44 @@ const img = ref<any>(undefined)
|
|||
const photoWidth = ref<number>(350)
|
||||
const photoHeight = ref<number>(350)
|
||||
|
||||
/**
|
||||
* function เปิดกล้อง
|
||||
*/
|
||||
/** function เปิดกล้อง*/
|
||||
async function openCamera() {
|
||||
// change camera device
|
||||
if (cameraIsOn.value) {
|
||||
camera.value?.stop()
|
||||
await camera.value?.stop()
|
||||
} else {
|
||||
await camera.value?.start()
|
||||
changeCamera()
|
||||
await changeCamera() // ต้องรอให้ start() เสร็จก่อน
|
||||
}
|
||||
cameraIsOn.value = !cameraIsOn.value
|
||||
}
|
||||
|
||||
/**
|
||||
* change camera device
|
||||
*/
|
||||
/** change camera device*/
|
||||
async function changeCamera() {
|
||||
const devices: any = await camera.value?.devices(['videoinput'])
|
||||
const device = await devices[0]
|
||||
camera.value?.changeCamera(device.deviceId)
|
||||
}
|
||||
|
||||
/**
|
||||
* function ถ่ายรูป
|
||||
*/
|
||||
/** function ถ่ายรูป*/
|
||||
async function capturePhoto() {
|
||||
const imageBlob: any = await camera.value?.snapshot(
|
||||
{ width: photoWidth.value, height: photoHeight.value },
|
||||
'image/png',
|
||||
0.5
|
||||
)
|
||||
if (!imageBlob) return
|
||||
const fileName = 'photo.png'
|
||||
//ไฟล์รูป
|
||||
const file = new File([imageBlob], fileName, { type: 'image/png' })
|
||||
fileImg.value = file
|
||||
//แสดงรูป
|
||||
camera.value?.stop()
|
||||
await camera.value?.stop()
|
||||
const url = URL.createObjectURL(imageBlob)
|
||||
img.value = url
|
||||
}
|
||||
|
||||
/**
|
||||
* function เปลี่ยนรูปภาพ
|
||||
*/
|
||||
/** function เปลี่ยนรูปภาพ*/
|
||||
function refreshPhoto() {
|
||||
img.value = undefined
|
||||
camera.value?.start()
|
||||
|
|
@ -179,9 +168,7 @@ const objectRef: FormRef = {
|
|||
useLocation: useLocationRef,
|
||||
}
|
||||
|
||||
/**
|
||||
* function ตรวจสอบค่าว่างของ input
|
||||
*/
|
||||
/** function ตรวจสอบค่าว่างของ input*/
|
||||
function validateForm() {
|
||||
const hasError = []
|
||||
for (const key in objectRef) {
|
||||
|
|
@ -200,9 +187,7 @@ function validateForm() {
|
|||
|
||||
const timeChickin = ref<string>('') //เวลาเข้างาน,เวลาออกงาน
|
||||
|
||||
/**
|
||||
* function ยืนยันการลงเวลาเข้า - ออก
|
||||
*/
|
||||
/** function ยืนยันการลงเวลาเข้า - ออก*/
|
||||
async function confirm() {
|
||||
showLoader()
|
||||
const isLocation = workplace.value === 'in-place' //*true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง
|
||||
|
|
@ -230,36 +215,34 @@ async function confirm() {
|
|||
dateObject
|
||||
)
|
||||
timeChickin.value = timeString
|
||||
setTimeout(() => {
|
||||
modalTime.value = true
|
||||
hideLoader()
|
||||
}, 2000)
|
||||
modalTime.value = true
|
||||
remark.value = ''
|
||||
})
|
||||
.catch((err) => {
|
||||
hideLoader()
|
||||
messageError($q, err)
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* ปิด popup แสดงการลงเวลา
|
||||
*/
|
||||
/** ปิด popup แสดงการลงเวลา*/
|
||||
async function onClickConfirm() {
|
||||
showLoader()
|
||||
setTimeout(async () => {
|
||||
if (!stetusCheckin.value) {
|
||||
stetusCheckin.value = true
|
||||
}
|
||||
await fetchCheckTime()
|
||||
}, 2000)
|
||||
if (!stetusCheckin.value) {
|
||||
stetusCheckin.value = true
|
||||
}
|
||||
|
||||
// await fetchCheckTime()
|
||||
// fetchCheckStatus()
|
||||
startChecking()
|
||||
|
||||
cameraIsOn.value = false
|
||||
img.value = undefined
|
||||
modalTime.value = false
|
||||
}
|
||||
|
||||
/**
|
||||
* เลือกสถานที่ทำงาน
|
||||
*/
|
||||
/** เลือกสถานที่ทำงาน*/
|
||||
function updateWorkplace() {
|
||||
useLocation.value = ''
|
||||
model.value = ''
|
||||
|
|
@ -276,10 +259,55 @@ const getClass = (val: boolean) => {
|
|||
}
|
||||
}
|
||||
|
||||
const inQueue = ref<boolean>(false)
|
||||
|
||||
async function fetchCheckStatus() {
|
||||
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 = 'ระบบกำลังประมวลผล'
|
||||
hideLoader()
|
||||
} else {
|
||||
isDisabledCheckTime.value = false
|
||||
msgCheckTime.value = ''
|
||||
stopChecking() // หยุดการทำงาน
|
||||
console.log('Response เป็น false, หยุด interval')
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('เกิดข้อผิดพลาด', error)
|
||||
stopChecking() // หยุดการทำงาน
|
||||
}
|
||||
}
|
||||
const intervalId = ref<number | undefined>(undefined) // ต้องใช้ตัวแปรเก็บค่า interval
|
||||
|
||||
async function startChecking() {
|
||||
showLoader()
|
||||
fetchCheckStatus()
|
||||
if (intervalId.value === undefined) {
|
||||
// ป้องกันการสร้าง interval ซ้ำ
|
||||
intervalId.value = setInterval(async () => {
|
||||
await fetchCheckStatus() // รอให้ fetchCheckStatus ทำงานเสร็จก่อน
|
||||
}, 3000)
|
||||
}
|
||||
}
|
||||
|
||||
async function stopChecking() {
|
||||
if (intervalId.value !== undefined) {
|
||||
clearInterval(intervalId.value) // หยุด interval
|
||||
setTimeout(() => {
|
||||
fetchCheckTime()
|
||||
}, 1000)
|
||||
intervalId.value = undefined // รีเซ็ตค่า
|
||||
}
|
||||
}
|
||||
|
||||
/** Hook*/
|
||||
onMounted(async () => {
|
||||
await fetchCheckTime()
|
||||
// await fetchCheckTime()
|
||||
updateClock()
|
||||
startChecking()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
@ -290,10 +318,29 @@ onMounted(async () => {
|
|||
<!-- <q-header elevated class="bg-purple"> -->
|
||||
<q-toolbar :class="getClass(stetusCheckin)">
|
||||
<div class="row col-12 justify-center">
|
||||
<strong v-if="stetusCheckin" style="font-size: 1rem">
|
||||
<!-- <strong v-if="stetusCheckin" style="font-size: 1rem">
|
||||
ลงเวลาเข้างาน
|
||||
</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
|
||||
v-else-if="stetusCheckin && !inQueue"
|
||||
style="font-size: 1rem"
|
||||
>
|
||||
ลงเวลาเข้างาน
|
||||
</strong>
|
||||
<strong v-else style="font-size: 1rem">ลงเวลาออกงาน</strong>
|
||||
|
||||
<strong v-else style="font-size: 1rem"> ลงเวลาออกงาน </strong>
|
||||
</div>
|
||||
</q-toolbar>
|
||||
<div class="col-12 text-grey-9">
|
||||
|
|
@ -322,7 +369,9 @@ onMounted(async () => {
|
|||
</div>
|
||||
<div class="col-xs-12 col-md-11 q-pa-md q-col-gutter-md row">
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<MapCheck @update:location="updateLocation" class="col-12" />
|
||||
<div class="col-12">
|
||||
<MapCheck @update:location="updateLocation" />
|
||||
</div>
|
||||
<!-- <AscMaps /> -->
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-4">
|
||||
|
|
@ -343,6 +392,7 @@ onMounted(async () => {
|
|||
</div>
|
||||
<div class="col-12 row items-center">
|
||||
<!-- แสดงกล้องตอนกดถ่ายภาพ -->
|
||||
|
||||
<Camera
|
||||
:resolution="{ width: photoWidth, height: photoHeight }"
|
||||
ref="camera"
|
||||
|
|
@ -488,15 +538,14 @@ onMounted(async () => {
|
|||
*หมายเหตุ คลิกลงเวลาเข้างานแล้วระบบจะลงเวลาทันที
|
||||
</p>
|
||||
<q-btn
|
||||
:label="
|
||||
stetusCheckin == true ? 'ลงเวลาเข้างาน' : 'ลงเวลาออกงาน'
|
||||
"
|
||||
:label="stetusCheckin ? 'ลงเวลาเข้างาน' : 'ลงเวลาออกงาน'"
|
||||
:color="img == null ? 'grey-6' : 'primary'"
|
||||
push
|
||||
size="18px"
|
||||
:class="$q.screen.gt.xs ? 'q-px-md' : 'full-width q-pa-sm'"
|
||||
:disable="camera && img ? false : true"
|
||||
@click="validateForm"
|
||||
:loading="inQueue"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ function onLoad(index: number, done: Function) {
|
|||
// landing page redirect
|
||||
const landingPageUrl = ref<string>(getLandingUrl())
|
||||
function getLandingUrl() {
|
||||
return `${configParam.landingPageUrl}/landing`
|
||||
return configParam.landingPageUrl
|
||||
}
|
||||
|
||||
/** ฟังก์ชันเรียกข้อมูลผู้ใช่งาน*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue