diff --git a/src/api/api.checkin.ts b/src/api/api.checkin.ts index b14ccaf..a0078fa 100644 --- a/src/api/api.checkin.ts +++ b/src/api/api.checkin.ts @@ -14,5 +14,7 @@ export default { `${urlFile}/file/${name}/${group}/${id}/${fileName}`, changePassword:`${orgKeycloak}/user/change-password`, - resetPassword:`${orgKeycloak}/user/reset-password` + resetPassword:`${orgKeycloak}/user/reset-password`, + + checkoutCheck:`${leave}/user/checkout-check` } diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index da900af..b558009 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -13,11 +13,12 @@ import type { FormRef } from '@/interface/response/checkin' import MapCheck from '@/components/AscGISMap.vue' const mixin = useCounterMixin() -const { date2Thai, showLoader, hideLoader, messageError } = mixin +const { date2Thai, showLoader, hideLoader, messageError, dialogConfirm } = mixin const $q = useQuasar() const modalTime = ref(false) // Dailog ลงเวลาเข้างานของคุณ const stetusCheckin = ref(true) // สถานะเวลา เข้า,ออก +const checkStatus = ref('') const msgCheckTime = ref('') // ข้อความแจ้งเตือน const isDisabledCheckTime = ref(false) // ข้อความแจ้งเตือน @@ -188,7 +189,11 @@ function validateForm() { } } if (hasError.every((result) => result === true)) { - confirm() + if (stetusCheckin.value == false) { + getCheck() + } else if (stetusCheckin.value) { + confirm() + } } } @@ -233,6 +238,33 @@ async function confirm() { }) } +async function getCheck() { + showLoader() + await http + .get(config.API.checkoutCheck) + .then(async (res) => { + const data = await res.data.result.status + checkStatus.value = data.toLocaleUpperCase() + if (checkStatus.value == 'ABSENT') { + dialogConfirm( + $q, + () => { + confirm() + }, + 'หากลงเวลาออกเวลานี้สถานะการเข้างานของคุณจะเป็นขาดราชการ', + 'ยืนยันการลงเวลาออก?' + ) + } else if (checkStatus.value == 'NORMAL') { + confirm() + } + }) + .catch((e) => { + messageError($q, e) + }) + .finally(() => { + hideLoader() + }) +} /** ปิด popup แสดงการลงเวลา*/ async function onClickConfirm() { showLoader()