diff --git a/src/modules/09_leave/components/3_Report/DetailReport.vue b/src/modules/09_leave/components/3_Report/DetailReport.vue index 0683e748b..2483038c7 100644 --- a/src/modules/09_leave/components/3_Report/DetailReport.vue +++ b/src/modules/09_leave/components/3_Report/DetailReport.vue @@ -46,8 +46,8 @@ const dateMonth = ref({ year: new Date().getFullYear(), }); const year = ref(new Date().getFullYear()); -const dateStart = ref(new Date()); -const dateEnd = ref(new Date()); +const dateStart = ref(new Date(year.value, 9, 1)); +const dateEnd = ref(new Date(year.value, 8, 30)); const employeeClass = ref("employee"); const yearType = ref("FULL"); const filterType = ref("daily"); @@ -68,7 +68,8 @@ const employeeClassMain = ref([ ]); const yearTypeOptionMain = ref([ { id: "FULL", name: "รายปี" }, - { id: "HAFT", name: "ครึ่งปี" }, + { id: "FIRSTHAFT", name: "ครึ่งปีแรก" }, + { id: "SECONDHAFT", name: "ครึ่งปีหลัง" }, ]); const employeeClassOption = ref(employeeClassMain.value); const yearTypeOptionOption = ref(yearTypeOptionMain.value); @@ -145,10 +146,19 @@ async function fetchReportTimeRecords(body: any) { }); } -async function fetchLeaveday(type: string, year: string) { +async function fetchLeaveday( + type: string, + year: string, + startDate: Date, + endDate: Date +) { showLoader(); + const body = { type: year, + year: 2024, + startDate: dateToISO(startDate), + endDate: dateToISO(endDate), }; await http @@ -188,7 +198,6 @@ async function updateMonth() { // วันสิ้นสุดของเดือนถัดไป const lastDay = new Date(dateMonth.value.year, mount, 0); - console.log(firstDay, lastDay); const body = { startDate: dateToISO(firstDay), @@ -263,7 +272,23 @@ async function genReportXLSX(data: any) { } async function updateLeaveday() { - fetchLeaveday(employeeClass.value, yearType.value); + if (yearType.value === "FULL") { + dateStart.value = new Date(year.value, 9, 1); + dateEnd.value = new Date(year.value, 8, 30); + } else if (yearType.value === "FIRSTHAFT") { + dateStart.value = new Date(year.value, 9, 1); + dateEnd.value = new Date(year.value, 2, 31); + } else if (yearType.value === "SECONDHAFT") { + dateStart.value = new Date(year.value, 3, 1); + dateEnd.value = new Date(year.value, 8, 30); + } + + fetchLeaveday( + employeeClass.value, + yearType.value, + dateStart.value, + dateEnd.value + ); } async function downloadReport(data: any, type: string) { @@ -281,9 +306,15 @@ onMounted(() => { startDate: dateToISO(date.value), endDate: dateToISO(date.value), }; + typeReport === "time-records" ? fetchReportTimeRecords(body) - : fetchLeaveday(employeeClass.value, yearType.value); + : fetchLeaveday( + employeeClass.value, + yearType.value, + dateStart.value, + dateEnd.value + ); });