diff --git a/src/stores/mixin.ts b/src/stores/mixin.ts index f49ec40..3826256 100644 --- a/src/stores/mixin.ts +++ b/src/stores/mixin.ts @@ -106,7 +106,9 @@ export const useCounterMixin = defineStore('mixin', () => { ok?: OkCallback, title?: string, // ถ้ามี cancel action ใส่เป็น null desc?: string, // ถ้ามี cancel action ใส่เป็น null - cancel?: CancelCallback + cancel?: CancelCallback, + color?: string, + okText?: string ) { q.dialog({ component: CustomComponent, @@ -117,8 +119,8 @@ export const useCounterMixin = defineStore('mixin', () => { ? desc : 'ต้องการยืนยันการบันทึกข้อมูลนี้ใช่หรือไม่?', icon: 'info', - color: 'public', - textOk: 'ตกลง', + color: color ? color : 'public', + textOk: okText ? okText : 'ตกลง', onlycancel: false, }, }) diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index b2c4799..1fb4673 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -22,6 +22,7 @@ const statusCheckin = ref(true) // สถานะเวลา เข const msgCheckTime = ref('') // ข้อความแจ้งเตือน const isDisabledCheckTime = ref(false) // ข้อความแจ้งเตือน +const endTimeAfternoon = ref('12:00:00') //เวลาเช็คเอาท์ตามรอบ /** * fetch เช็คเวลาต้องลงเวลาเข้าหรือออกงาน */ @@ -31,8 +32,10 @@ async function fetchCheckTime() { .get(config.API.checkTime()) .then(async (res) => { const data = await res.data.result + statusCheckin.value = data.checkInId ? false : true checkInId.value = data.checkInId ? data.checkInId : '' + endTimeAfternoon.value = data.endTimeAfternoon }) .catch((err) => { if (err.response.status === 500) { @@ -243,16 +246,28 @@ async function getCheck() { await http .get(config.API.checkoutCheck) .then(async (res) => { - const data = await res.data.result.status - checkStatus.value = data.toLocaleUpperCase() + checkStatus.value = await res.data.result.status.toLocaleUpperCase() 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( $q, - () => { - confirm() - }, - 'หากลงเวลาออกเวลานี้สถานะการเข้างานของคุณจะเป็นขาดราชการ', - 'ยืนยันการลงเวลาออก?' + () => confirm(), + 'ยืนยันการลงเวลาออกงาน', + `เวลาออกจากงานของคุณคือ ${endTimeAfternoonVal} แต่ขณะนี้เป็นเวลา ${timeVal} น. หากคุณออกจากงานในเวลานี้สถานะการลงเวลาจะเป็น "${res.data.result.statusText}" คุณแน่ใจว่าจะลงเวลาออกงานในตอนนี้ใช่หรือไม่?`, + () => {}, + 'red', + 'ยืนยัน' ) } else if (checkStatus.value == 'NORMAL') { confirm()