From bb718ad0e37b22a5bd5aff6a6d2a15de46b4a8ca Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 25 Dec 2023 10:39:14 +0700 Subject: [PATCH 1/2] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A?= =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=87=E0=B8=B2=E0=B8=99=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B8=A5=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/3_Report/DetailReport.vue | 142 +++++++++++++++--- 1 file changed, 120 insertions(+), 22 deletions(-) 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 + ); });