diff --git a/src/modules/09_leave/components/2_Leave/DetailLeave.vue b/src/modules/09_leave/components/2_Leave/DetailLeave.vue index 2eb4b9cf6..17feacfa5 100644 --- a/src/modules/09_leave/components/2_Leave/DetailLeave.vue +++ b/src/modules/09_leave/components/2_Leave/DetailLeave.vue @@ -97,7 +97,7 @@ const formData = reactive({ leaveTotal: 0, //จำนวนวันที่ลา(Auto) leavebirthDate: new Date(), //วันเดือนปีเกิด(Auto) leavegovernmentDate: new Date(), //วันที่เข้ารับราชการ(Auto) - leaveSalary: 0, //เงินเดือนปัจจุบัน(Auto) + leaveSalary: "", //เงินเดือนปัจจุบัน(Auto) leaveSalaryText: "", //เงินเดือนปัจจุบัน(เขียนเป็นคำอ่าน) leaveTypeDay: "", //ประเภทการลาในวันนั้นเช่น wifeDayName: "", //ชื่อภรรยา(ลาไปช่วยเหลือภริยาที่คลอดบุตร) @@ -196,7 +196,9 @@ async function fetchDetailLeave(paramsId: string) { data.leaveBirthDate && date2Thai(data.leaveBirthDate); formData.leavegovernmentDate = data.leaveGovernmentDate && date2Thai(data.leaveGovernmentDate); - formData.leaveSalary = data.leaveSalary ? data.leaveSalary : "-"; + formData.leaveSalary = data.leaveSalary + ? formattedNumber(data.leaveSalary) + : "-"; formData.leaveSalaryText = data.leaveSalaryText ? data.leaveSalaryText : "-"; @@ -307,7 +309,7 @@ async function fectOptionType() { .then((res) => { console.log(res); leaveType.value = res.data.result; - checkLeaveType(formData.leaveTypeId, formData.leaveTypeName); + checkLeaveType(formData.leaveTypeId, formData); }) .catch((err) => { messageError($q, err); @@ -319,7 +321,7 @@ const checkForm = ref(""); * Function เช็คประเภทการลา * @param type รับค่า */ -function checkLeaveType(leaveTypeId: string, leaveTypeName: string) { +function checkLeaveType(leaveTypeId: string, formData: FremData) { if (leaveType.value) { const filtertype: LeaveType | undefined = leaveType.value.find( (e: any) => e.id === leaveTypeId @@ -331,13 +333,13 @@ function checkLeaveType(leaveTypeId: string, leaveTypeName: string) { checkForm.value = "FormChildbirth"; } else if (type === "LV-005") { checkForm.value = "FormHoliday"; - } else if (type === "LV-006") { + } else if (type === "LV-006" && formData.ordainDayLocationName !== "-") { checkForm.value = "FormUpasom"; - } else if (type === "LV-006" && leaveTypeName === "พิธีฮัจญ์ฯ") { + } else if (type === "LV-006") { checkForm.value = "FormHajj"; } else if (type === "LV-007") { checkForm.value = "FormCheckSelect"; - } else if (type === "LV-008" && leaveTypeName === "ลาไปศีกษา") { + } else if (type === "LV-008" && formData.studyDayTrainingSubject === "-") { checkForm.value = "FormStudy"; } else if (type === "LV-008") { checkForm.value = "FormLeaveToTraining"; @@ -481,6 +483,10 @@ async function onClickDownloadFile(id: string, fileName: string, type: string) { hideLoader(); }); } + +function formattedNumber(x: number) { + return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); +}