From bd348d1663a5b5256d1db1547206a76e644b2896 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 14 Sep 2023 17:11:41 +0700 Subject: [PATCH] validationDate => Exit interview --- .../components/ExitInterview/exitMain.vue | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/modules/06_retirement/components/ExitInterview/exitMain.vue b/src/modules/06_retirement/components/ExitInterview/exitMain.vue index 1919fa77f..0872ebb6d 100644 --- a/src/modules/06_retirement/components/ExitInterview/exitMain.vue +++ b/src/modules/06_retirement/components/ExitInterview/exitMain.vue @@ -14,6 +14,7 @@ import type { ResponseItems } from "@/modules/06_retirement/interface/response/e import DialogFooter from "@/modules/05_placement/components/PersonalList/DialogFooter.vue"; import DialogHeader from "@/modules/05_placement/components/PersonalList/DialogHeader.vue"; import { identity } from "@fullcalendar/core/internal"; +import { tabList } from "@/interface/request/main/main"; const $q = useQuasar(); //ใช้ noti quasar const router = useRouter(); @@ -138,6 +139,7 @@ const columns = ref([ const visibleColumns = ref([]); const dateBreak = ref(null); +const daterow = ref(""); const id = ref(""); const filters = ref([]); const rows2 = ref([]); @@ -177,6 +179,7 @@ const openModalCalendar = (rows: any) => { openModal(); dateBreak.value = null; id.value = rows.id; + daterow.value = convertThaiDateToNumeric(rows.datetext); }; const openModalOrder = () => { @@ -256,6 +259,38 @@ const saveAppoint = async () => { } }); }; +const validationDate = (thaiDate: string | null) => { + if (thaiDate && daterow.value) { + let a = convertThaiDateToNumeric(thaiDate); + let b = daterow.value; + if (a) { + return a > b; + } + } +}; +const convertThaiDateToNumeric = (thaiDate: string) => { + const parts = thaiDate.split(" "); + if (parts.length !== 3) return null; + const [day, month, year] = parts; + const monthMap: any = { + "ม.ค.": "01", + "ก.พ.": "02", + "มี.ค.": "03", + "เม.ย.": "04", + "พ.ค.": "05", + "มิ.ย.": "06", + "ก.ค.": "07", + "ส.ค.": "08", + "ก.ย.": "09", + "ต.ค.": "10", + "พ.ย.": "11", + "ธ.ค.": "12", + }; + if (!(month in monthMap)) return null; + const numericDate = `${year}${monthMap[month]}${day}`; + return numericDate; +}; + // const saveOrder = async () => { // const id = selected.value.map((r) => r.id); // const body = { @@ -617,8 +652,14 @@ const saveAppoint = async () => { " hide-bottom-space :label="`${' วันนัดหมายเพื่อทําการสัมภาษณ์การลาออก'}`" - :rules="[(val) => !!val || `${'กรุณาเลือกลงวันที่'}`]" + :rules="[ + (val) => !!val || `${'กรุณาเลือกลงวันที่'}`, + (val) => + validationDate(val) || + `${'วันที่นัดหมายต้องมากกว่าวันที่สร้าง'}`, + ]" > +