This commit is contained in:
Warunee Tamkoo 2025-03-20 16:22:01 +07:00
parent 06c7083eff
commit 640bfefe13
2 changed files with 27 additions and 10 deletions

View file

@ -106,7 +106,9 @@ export const useCounterMixin = defineStore('mixin', () => {
ok?: OkCallback, ok?: OkCallback,
title?: string, // ถ้ามี cancel action ใส่เป็น null title?: string, // ถ้ามี cancel action ใส่เป็น null
desc?: string, // ถ้ามี cancel action ใส่เป็น null desc?: string, // ถ้ามี cancel action ใส่เป็น null
cancel?: CancelCallback cancel?: CancelCallback,
color?: string,
okText?: string
) { ) {
q.dialog({ q.dialog({
component: CustomComponent, component: CustomComponent,
@ -117,8 +119,8 @@ export const useCounterMixin = defineStore('mixin', () => {
? desc ? desc
: 'ต้องการยืนยันการบันทึกข้อมูลนี้ใช่หรือไม่?', : 'ต้องการยืนยันการบันทึกข้อมูลนี้ใช่หรือไม่?',
icon: 'info', icon: 'info',
color: 'public', color: color ? color : 'public',
textOk: 'ตกลง', textOk: okText ? okText : 'ตกลง',
onlycancel: false, onlycancel: false,
}, },
}) })

View file

@ -22,6 +22,7 @@ const statusCheckin = ref<boolean>(true) // สถานะเวลา เข
const msgCheckTime = ref<string>('') // const msgCheckTime = ref<string>('') //
const isDisabledCheckTime = ref<boolean>(false) // const isDisabledCheckTime = ref<boolean>(false) //
const endTimeAfternoon = ref<string>('12:00:00') //
/** /**
* fetch เชคเวลาตองลงเวลาเขาหรอออกงาน * fetch เชคเวลาตองลงเวลาเขาหรอออกงาน
*/ */
@ -31,8 +32,10 @@ async function fetchCheckTime() {
.get(config.API.checkTime()) .get(config.API.checkTime())
.then(async (res) => { .then(async (res) => {
const data = await res.data.result const data = await res.data.result
statusCheckin.value = data.checkInId ? false : true statusCheckin.value = data.checkInId ? false : true
checkInId.value = data.checkInId ? data.checkInId : '' checkInId.value = data.checkInId ? data.checkInId : ''
endTimeAfternoon.value = data.endTimeAfternoon
}) })
.catch((err) => { .catch((err) => {
if (err.response.status === 500) { if (err.response.status === 500) {
@ -243,16 +246,28 @@ async function getCheck() {
await http await http
.get(config.API.checkoutCheck) .get(config.API.checkoutCheck)
.then(async (res) => { .then(async (res) => {
const data = await res.data.result.status checkStatus.value = await res.data.result.status.toLocaleUpperCase()
checkStatus.value = data.toLocaleUpperCase()
if (checkStatus.value == 'ABSENT') { if (checkStatus.value == 'ABSENT') {
const options: Intl.DateTimeFormatOptions = {
hour12: false,
hour: '2-digit',
minute: '2-digit',
}
const timeVal =
new Intl.DateTimeFormat('en-US', options).format(
new Date(res.data.result.serverTime)
) ?? ''
const endTimeAfternoonVal = endTimeAfternoon.value ?? ''
// dialog
dialogConfirm( dialogConfirm(
$q, $q,
() => { () => confirm(),
confirm() 'ยืนยันการลงเวลาออกงาน',
}, `เวลาออกจากงานของคุณคือ ${endTimeAfternoonVal} แต่ขณะนี้เป็นเวลา ${timeVal} น. หากคุณออกจากงานในเวลานี้สถานะการลงเวลาจะเป็น "${res.data.result.statusText}" คุณแน่ใจว่าจะลงเวลาออกงานในตอนนี้ใช่หรือไม่?`,
'หากลงเวลาออกเวลานี้สถานะการเข้างานของคุณจะเป็นขาดราชการ', () => {},
'ยืนยันการลงเวลาออก?' 'red',
'ยืนยัน'
) )
} else if (checkStatus.value == 'NORMAL') { } else if (checkStatus.value == 'NORMAL') {
confirm() confirm()