diff --git a/src/modules/09_leave/components/02_WorkList/DialogReport.vue b/src/modules/09_leave/components/02_WorkList/DialogReport.vue deleted file mode 100644 index eddf37943..000000000 --- a/src/modules/09_leave/components/02_WorkList/DialogReport.vue +++ /dev/null @@ -1,297 +0,0 @@ - - - - diff --git a/src/modules/09_leave/views/!07_ReportCheckin.vue b/src/modules/09_leave/views/!07_ReportCheckin.vue deleted file mode 100644 index d5fa6d21f..000000000 --- a/src/modules/09_leave/views/!07_ReportCheckin.vue +++ /dev/null @@ -1,676 +0,0 @@ - - - - - diff --git a/src/modules/09_leave/views/02_WorkingMain.vue b/src/modules/09_leave/views/02_WorkingMain.vue index d28f5b1ab..5294527d8 100644 --- a/src/modules/09_leave/views/02_WorkingMain.vue +++ b/src/modules/09_leave/views/02_WorkingMain.vue @@ -4,7 +4,6 @@ import { ref } from "vue"; /** import Components */ import Tab1 from "@/modules/09_leave/components/02_WorkList/Tab1.vue"; import Tab2 from "@/modules/09_leave/components/02_WorkList/Tab2.vue"; -// import DialogReport from "@/modules/09_leave/components/02_WorkList/DialogReport.vue"; const tab = ref("1"); diff --git a/src/modules/09_leave/views/06_ReportMain.vue b/src/modules/09_leave/views/06_ReportMain.vue index 45712cace..f87fd32f2 100644 --- a/src/modules/09_leave/views/06_ReportMain.vue +++ b/src/modules/09_leave/views/06_ReportMain.vue @@ -16,6 +16,7 @@ import config from "@/app.config"; import type { DataStructureTree } from "@/interface/main"; import type { DataOption, + DataOption2, DataDateMonthObject, } from "@/modules/09_leave/interface/index/Main"; @@ -54,43 +55,28 @@ const pageName = ref(route.name as string); const dateWeek = ref(getCurrentWeek()); const date = ref(new Date()); -const typeReport = ref(""); -const optionReport = ref([]); -const optionReportMain = ref( +const typeReport = ref(null); +const optionReport = ref([ + { + id: 3, + name: "รายงานการเข้างาน", + }, + { + id: 4, + name: "รายงานการเข้างานสาย", + }, + { id: 1, name: "รายงานการลางานตามประเภทการลา" }, + { + id: 2, + name: "รายงานการลางาน จำแนกตามเพศ ประเภทการลา หน่วยงาน/ส่วนราชการ", + }, +]); +const optionReportMain = ref( route.name?.toString() === "reportLeave" - ? [ - { - id: "3", - name: "รายงานการเข้างาน", - }, - { - id: "4", - name: "รายงานการเข้างานสาย", - }, - { id: "1", name: "รายงานการลางานตามประเภทการลา" }, - { - id: "2", - name: "รายงานการลางาน จำแนกตามเพศ ประเภทการลา หน่วยงาน/ส่วนราชการ", - }, - ] + ? optionReport.value : route.name?.toString() === "leaveReport" - ? [ - { id: "1", name: "รายงานการลางานตามประเภทการลา" }, - { - id: "2", - name: "รายงานการลางาน จำแนกตามเพศ ประเภทการลา หน่วยงาน/ส่วนราชการ", - }, - ] - : [ - { - id: "3", - name: "รายงานการเข้างาน", - }, - { - id: "4", - name: "รายงานการเข้างานสาย", - }, - ] + ? optionReport.value.filter((item) => item.id === 1 || item.id === 2) + : optionReport.value.filter((item) => item.id === 3 || item.id === 4) ); const employeeClass = ref("officer"); @@ -158,7 +144,7 @@ function onSelectedNode(data: any) { */ async function updateLeaveday() { const list = - typeReport.value == "3" || typeReport.value == "4" + typeReport.value == 3 || typeReport.value == 4 ? leaveType.value : yearType.value; switch (list) { @@ -251,11 +237,11 @@ async function fetchLeaveday( }; const pathAPI = - typeReport.value === "1" + typeReport.value === 1 ? config.API.leaveReportLeaveday(type) - : typeReport.value === "2" + : typeReport.value === 2 ? config.API.leaveReportLeave2(type) - : typeReport.value === "3" + : typeReport.value === 3 ? config.API.leaveReportTimeRecords(type) : config.API.leaveReportTimeLate(type); @@ -349,7 +335,7 @@ function clearData() { nodeId.value = ""; nodeLevel.value = 0; org.value = ""; - typeReport.value = ""; + typeReport.value = null; yearType.value = "FULL"; leaveType.value = "DAY"; pdfSrc.value = undefined; @@ -370,7 +356,7 @@ function onSearch() { updateLeaveday(); fetchLeaveday( employeeClass.value, - typeReport.value == "3" || typeReport.value == "4" + typeReport.value == 3 || typeReport.value == 4 ? leaveType.value : yearType.value, dateStart.value, @@ -389,7 +375,7 @@ function getCurrentWeek() { } function updateValue(val: string) { - if (typeReport.value == "3" || typeReport.value == "4") { + if (typeReport.value == 3 || typeReport.value == 4) { leaveType.value = val; } else { yearType.value = val; @@ -409,7 +395,7 @@ const isLoad = ref(false); * @param isName ชื่อไฟล์ * @param fileType pdf/xlsx */ -function getReport(isName: string) { +function getReport() { showLoader(); const body = { type: @@ -449,7 +435,7 @@ function getReport(isName: string) { // สร้างลิงก์เพื่อดาวน์โหลดไฟล์ const link = document.createElement("a"); link.href = url; - link.download = `${isName}.xlsx`; // กำหนดชื่อไฟล์ที่จะดาวน์โหลด + link.download = `${reportName()}.xlsx`; // กำหนดชื่อไฟล์ที่จะดาวน์โหลด document.body.appendChild(link); link.click(); @@ -464,6 +450,19 @@ function getReport(isName: string) { hideLoader(); }); } + +const reportName = () => { + const employeeClassName = + employeeClass.value === "officer" + ? " (ข้าราชการ กทม. สามัญ)" + : " (ลูกจ้างประจำ กทม.)"; + + const reportNameVal = + optionReportMain.value.find((item) => item.id === typeReport.value)?.name || + ""; + return reportNameVal + employeeClassName; +}; + onMounted(() => { fetchDataTree(); }); @@ -509,7 +508,7 @@ onMounted(() => { round color="primary" icon="download" - v-if="checkPermission($route)?.attrIsGet && typeReport !== '3'" + v-if="checkPermission($route)?.attrIsGet && typeReport !== 3" > @@ -517,23 +516,7 @@ onMounted(() => { clickable v-close-popup @click=" - genReportXLSX( - detailReport, - `${ - typeReport === '1' - ? `รายงานการลางานตามประเภทการลา (${ - employeeClass === 'officer' - ? 'ข้าราชการ กทม. สามัญ' - : 'ลูกจ้างประจำ กทม.' - })` - : `รายงานการลางาน จำแนกตามเพศ ประเภทการลา หน่วยงาน/ส่วนราชการ (${ - employeeClass === 'officer' - ? 'ข้าราชการ กทม. สามัญ' - : 'ลูกจ้างประจำ กทม.' - })` - }`, - 'pdf' - ) + genReportXLSX(detailReport, `${reportName()}`, 'pdf') " > { { round color="primary" icon="download" - v-if="checkPermission($route)?.attrIsGet && typeReport == '3'" - @click=" - getReport( - `${`รายงานการลางาน จำแนกตามเพศ ประเภทการลา หน่วยงาน/ส่วนราชการ (${ - employeeClass === 'officer' - ? 'ข้าราชการ กทม. สามัญ' - : 'ลูกจ้างประจำ กทม.' - })`}` - ) - " + v-if="checkPermission($route)?.attrIsGet && typeReport == 3" + @click="getReport()" > @@ -744,12 +702,12 @@ onMounted(() => { class="bg-white" dense :model-value=" - typeReport == '3' || typeReport == '4' + typeReport == 3 || typeReport == 4 ? leaveType : yearType " :options=" - typeReport == '3' || typeReport == '4' + typeReport == 3 || typeReport == 4 ? leaveTypeOptionOption : yearTypeOptionOption " @@ -765,8 +723,8 @@ onMounted(() => { class="col-12" v-if=" yearType !== 'MONTH' && - typeReport !== '3' && - typeReport !== '4' + typeReport !== 3 && + typeReport !== 4 " > { class="col-12" v-if=" yearType !== 'MONTH' && - typeReport !== '3' && - typeReport !== '4' + typeReport !== 3 && + typeReport !== 4 " > { class="col-12" v-if=" yearType !== 'MONTH' && - typeReport !== '3' && - typeReport !== '4' + typeReport !== 3 && + typeReport !== 4 " > { -
+
{
-
+
{
{ { type="submit" :disable=" typeReport && - (typeReport == '2' || - typeReport == '3' || - typeReport == '4') && + (typeReport == 2 || typeReport == 3 || typeReport == 4) && org " /> @@ -1028,7 +968,7 @@ onMounted(() => {