diff --git a/src/modules/05_placement/components/PersonalDetail/Information/Education.vue b/src/modules/05_placement/components/PersonalDetail/Information/Education.vue index 4143bd249..10b51cb5a 100644 --- a/src/modules/05_placement/components/PersonalDetail/Information/Education.vue +++ b/src/modules/05_placement/components/PersonalDetail/Information/Education.vue @@ -79,10 +79,10 @@ const durationYear = ref(0); const other = ref(); const fundName = ref(); const finishDate = ref(new Date()); -const startDate = ref(new Date().getFullYear()); -const startDate2 = ref(new Date()); -const endDate = ref(new Date().getFullYear()); -const endDate2 = ref(new Date()); +const startDate = ref(new Date().getFullYear()); +const startDate2 = ref(new Date()); +const endDate = ref(new Date().getFullYear()); +const endDate2 = ref(new Date()); const minDate = ref(); const myForm = ref(); //form data input const edit = ref(false); //เช็คการกดปุ่มแก้ไขใน dialog @@ -451,12 +451,20 @@ const saveData = async () => { finishDate: convertDateToAPI(finishDate.value), startDate: isDate.value == "true" - ? convertDateToAPI(new Date(startDate2.value)) - : convertDateToAPI(new Date(`${startDate.value}-01-01`)), + ? startDate2.value + ? convertDateToAPI(new Date(startDate2.value)) + : null + : startDate.value + ? convertDateToAPI(new Date(`${startDate.value}-01-01`)) + : null, endDate: isDate.value == "true" - ? convertDateToAPI(new Date(endDate2.value)) - : convertDateToAPI(new Date(`${endDate.value}-01-01`)), + ? endDate2.value + ? convertDateToAPI(new Date(endDate2.value)) + : null + : endDate.value + ? convertDateToAPI(new Date(`${endDate.value}-01-01`)) + : null, isDate: isDate.value == "true", }) .then(async () => { @@ -499,12 +507,20 @@ const editData = async () => { finishDate: new Date(finishDate.value), startDate: isDate.value == "true" - ? convertDateToAPI(new Date(startDate2.value)) - : convertDateToAPI(new Date(`${startDate.value}-01-01`)), + ? startDate2.value + ? convertDateToAPI(new Date(startDate2.value)) + : null + : startDate.value + ? convertDateToAPI(new Date(`${startDate.value}-01-01`)) + : null, endDate: isDate.value == "true" - ? convertDateToAPI(new Date(endDate2.value)) - : convertDateToAPI(new Date(`${endDate.value}-01-01`)), + ? endDate2.value + ? convertDateToAPI(new Date(endDate2.value)) + : null + : endDate.value + ? convertDateToAPI(new Date(`${endDate.value}-01-01`)) + : null, isDate: isDate.value == "true", }) .then(async () => { @@ -594,10 +610,16 @@ const selectData = async (_props: DataProps) => { other.value = _props.row.other; fundName.value = _props.row.fundName; finishDate.value = _props.row.finishDate; - startDate.value = new Date(_props.row.startDate).getFullYear(); - endDate.value = new Date(_props.row.endDate).getFullYear(); - startDate2.value = new Date(_props.row.startDate); - endDate2.value = new Date(_props.row.endDate); + startDate.value = _props.row.startDate + ? new Date(_props.row.startDate).getFullYear() + : null; + endDate.value = _props.row.endDate + ? new Date(_props.row.endDate).getFullYear() + : null; + startDate2.value = _props.row.startDate + ? new Date(_props.row.startDate) + : null; + endDate2.value = _props.row.endDate ? new Date(_props.row.endDate) : null; id.value = _props.row.id; isDate.value = _props.row.isDate; isEducation.value = _props.row.isEducation; @@ -778,7 +800,7 @@ onMounted(async () => { @submit.prevent @validation-success="clickSave" > - +
@@ -868,7 +890,7 @@ onMounted(async () => { :outlined="edit" dense :borderless="!edit" - :model-value="startDate + 543" + :model-value="startDate ? startDate + 543 : ''" :rules="[ (val:string) => !!val || `${'กรุณาเลือกปีที่เริ่มต้นศึกษา'}`, @@ -961,7 +983,7 @@ onMounted(async () => { :outlined="edit" dense :borderless="!edit" - :model-value="endDate + 543" + :model-value="endDate ? endDate + 543 : ''" :rules="[ (val:string) => !!val || `${'กรุณาเลือกปีที่จบการศึกษา'}`, ]" diff --git a/src/modules/05_placement/interface/request/Education.ts b/src/modules/05_placement/interface/request/Education.ts index 63bc67e28..006b6c033 100644 --- a/src/modules/05_placement/interface/request/Education.ts +++ b/src/modules/05_placement/interface/request/Education.ts @@ -22,8 +22,8 @@ interface RequestItemsObject { other: string; fundName: string; finishDate: Date; - startDate: number; - endDate: number; + startDate: number | null; + endDate: number | null; createdFullName: string; createdAt: Date; isDate: string;