diff --git a/src/modules/01_exam/views/ExamDetail.vue b/src/modules/01_exam/views/ExamDetail.vue index c808521..4fdf970 100644 --- a/src/modules/01_exam/views/ExamDetail.vue +++ b/src/modules/01_exam/views/ExamDetail.vue @@ -82,10 +82,10 @@
-
+
-
หมดเขตรับสมัครสอบ !
- ไม่สามารถทำรายการได้ เนื่องจากหมดเขตรับสมัครแล้ว +
{{isBeforeToday && timeout ? 'ยังไม่ถึงรอบรับสมัครสอบ':'หมดเขตรับสมัครสอบ'}} !
+ {{`ไม่สามารถทำรายการได้ ${isBeforeToday && timeout ? 'เนื่องจากยังไม่ถึงรอบรับสมัครสอบ':'เนื่องจากหมดเขตรับสมัครแล้ว'}`}}
@@ -114,11 +114,12 @@ import keycloak from '@/plugins/keycloak' const $q = useQuasar() const storeExam = useExamDataStore() const mixin = useCounterMixin() -const { modalError, messageError, dateThaiRange } = mixin +const { modalError, messageError, dateThaiRange, dateToISO } = mixin const dataStore = useDataStore() const { loaderPage } = dataStore const step = ref(1) const stepRaw = ref(1) +const isBeforeToday = ref(false) const tittle = ref('') const position = ref('') const positionLevel = ref('') @@ -174,7 +175,9 @@ const candidateCheck = async () => { modalConsend.value = true stepRaw.value = 2 step.value = 2 + isBeforeToday.value = false } else { + isBeforeToday.value = dateToISO(data.registerEndDate) > dateToISO(new Date()) registerStartDate.value = new Date(data.registerStartDate) registerEndDate.value = new Date(data.registerEndDate) timeout.value = true diff --git a/src/stores/mixin.ts b/src/stores/mixin.ts index 93fccd8..373a956 100644 --- a/src/stores/mixin.ts +++ b/src/stores/mixin.ts @@ -205,16 +205,22 @@ export const useCounterMixin = defineStore('mixin', () => { } function dateToISO(date: Date) { - return ( - date.getFullYear() + - '-' + - appendLeadingZeroes(date.getMonth() + 1) + - '-' + - appendLeadingZeroes(date.getDate()) - ) + if (date != null) { + const srcDate = new Date(date) + + return ( + srcDate.getFullYear() + + '-' + + appendLeadingZeroes(srcDate.getMonth() + 1) + + '-' + + appendLeadingZeroes(srcDate.getDate()) + ) + } else { + return '' + } } - function appendLeadingZeroes(n: Number) { + function appendLeadingZeroes(n: number) { if (n <= 9) return '0' + n return n }