Merge branch 'develop'

* develop:
  fix
  fix เพิ่ม check Status
  fixing landing redirect
  fix
This commit is contained in:
Warunee Tamkoo 2025-02-11 13:51:03 +07:00
commit 48d7bd016a
3 changed files with 102 additions and 52 deletions

View file

@ -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`,

View file

@ -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>

View file

@ -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
}
/** ฟังก์ชันเรียกข้อมูลผู้ใช่งาน*/