diff --git a/src/modules/05_leave/componenst/Forms/06_OrdinationForm.vue b/src/modules/05_leave/componenst/Forms/06_OrdinationForm.vue index 5e7c8ce..60fb7c5 100644 --- a/src/modules/05_leave/componenst/Forms/06_OrdinationForm.vue +++ b/src/modules/05_leave/componenst/Forms/06_OrdinationForm.vue @@ -29,9 +29,9 @@ const writeatRef = ref(null) const birthdayRef = ref(null) const governmentRef = ref(null) const totalLeaveRef = ref(null) -const dateLeaveEndRef = ref(null) +const endLeaveDateRef = ref(null) const dateOrdinationRef = ref(null) -const dateLeaveStartRef = ref(null) +const startLeaveDateRef = ref(null) const addressMeasureRef = ref(null) const addressBuddhistRef = ref(null) const measureLocationNameRef = ref(null) @@ -42,8 +42,8 @@ const formData = reactive({ writeat: "", government: new Date(), birthday: new Date(), - dateLeaveStart: null, - dateLeaveEnd: null, + startLeaveDate: null, + endLeaveDate: null, totalLeave: new Date(), dateOrdination: new Date(), measureLocationName: "", @@ -60,8 +60,8 @@ const formRef: FormRef06 = { writeat: writeatRef, government: governmentRef, birthday: birthdayRef, - dateLeaveStart: dateLeaveStartRef, - dateLeaveEnd: dateLeaveEndRef, + startLeaveDate: startLeaveDateRef, + endLeaveDate: endLeaveDateRef, totalLeave: totalLeaveRef, dateOrdination: dateOrdinationRef, measureLocationName: measureLocationNameRef, @@ -71,10 +71,10 @@ const formRef: FormRef06 = { addressBuddhist: addressBuddhistRef, } -// Watch for changes in dateLeaveEnd and update leaveTotal accordingly -watch(formData.dateLeaveEnd, async () => { - if (formData.dateLeaveStart !== undefined && formData.dateLeaveEnd !== undefined) { - const newLeaveTotal = calculateDurationYmd(formData.dateLeaveStart, formData.dateLeaveEnd) +// Watch for changes in endLeaveDate and update leaveTotal accordingly +watch(formData.endLeaveDate, async () => { + if (formData.startLeaveDate !== undefined && formData.endLeaveDate !== undefined) { + const newLeaveTotal = calculateDurationYmd(formData.startLeaveDate, formData.endLeaveDate) formData.leaveTotal = newLeaveTotal console.log(newLeaveTotal) } @@ -86,7 +86,7 @@ watch(formData.dateLeaveEnd, async () => { * function อัพเดทค่า LeaveTotal */ function updateLeaveTotal() { - const newLeaveTotal = calculateDurationYmd(formData.dateLeaveStart, formData.dateLeaveEnd) + const newLeaveTotal = calculateDurationYmd(formData.startLeaveDate, formData.endLeaveDate) formData.leaveTotal = newLeaveTotal console.log("test") } @@ -144,7 +144,7 @@ function onSubmit() { :rules="[val => !!val || `${'เขียนที่'}`]" /> - + @@ -156,10 +156,10 @@ function onSubmit() { outlined bg-color="white" dense - ref="dateLeaveStartRef" + ref="startLeaveDateRef" hide-bottom-space class="full-width datepicker" - :model-value="formData.dateLeaveStart != null ? date2Thai(formData.dateLeaveStart) : null" + :model-value="formData.startLeaveDate != null ? date2Thai(formData.startLeaveDate) : null" :label="`${'ลาตั้งแต่วันที่'}`" :rules="[val => !!val || `${'กรุณาเลือกลาตั้งแต่วันที่'}`]" > @@ -173,14 +173,14 @@ function onSubmit() {