diff --git a/src/modules/07_insignia/views/06_ReportMain.vue b/src/modules/07_insignia/views/06_ReportMain.vue index af628457b..5f090531a 100644 --- a/src/modules/07_insignia/views/06_ReportMain.vue +++ b/src/modules/07_insignia/views/06_ReportMain.vue @@ -110,6 +110,30 @@ async function fecthlistRound() { }); } +const roundId2 = ref(""); +const roundOtionMain2 = ref([]); +const roundOtion2 = ref([]); +/** ฟังก์ชันคึงข้อมูลรอบการเสนอขอ note*/ +async function fecthlistRound2() { + showLoader(); + await http + .get(config.API.noteround(), { params: { path: "RECORD" } }) + .then((res: any) => { + roundOtionMain2.value = res.data.result.map((e: any) => ({ + id: e.id, + year: e.year, + name: e.name, + })); + roundOtion2.value = roundOtionMain2.value; + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + /** * function ค้นหาข้อมูลใน option * @param val คำค้นหา @@ -163,7 +187,13 @@ async function onUpdateFilter() { name: "รายงานแสดงรายชื่อลูกจ้างประจำที่ได้รับ/ไม่ได้รับ การจ่ายใบกำกับฯ เครื่องราชอิสริยาภรณที่ได้รับพระราชทาน (ลูกจ้าง)", }; } - if (typeReport.value && roundId.value && nodeId.value) { + if ( + (typeReport.value.val === "report1" || + typeReport.value.val === "report2" || + typeReport.value.val === "report3") && + (roundId.value || roundId2.value) && + nodeId.value + ) { isLoadPDF.value = true; pdfSrc.value = undefined; @@ -180,13 +210,34 @@ async function onUpdateFilter() { .then(async (res) => { const data = await res.data.result; detailReport.value = data; - const type = - typeReport.value.val === "report4" || - typeReport.value.val === "report5" || - typeReport.value.val === "report6" - ? "xlsx" - : "docx"; - await fetchDocumentTemplate(data, type); + + await fetchDocumentTemplate(data, "docx"); + }) + .catch(async (e) => { + messageError($q, JSON.parse(await e.response.data.text())); + }) + .finally(() => { + isLoadPDF.value = false; + }); + } else if (roundId2.value && nodeId.value) { + isLoadPDF.value = true; + pdfSrc.value = undefined; + + await http + .post( + config.API.reportInsigniaNew + + `/${typeReport.value.val}/${employeeClass.value}`, + { + roundId: roundId2.value, + node: nodeLevel.value, + nodeId: nodeId.value, + } + ) + .then(async (res) => { + const data = await res.data.result; + detailReport.value = data; + + await fetchDocumentTemplate(data, "xlsx"); }) .catch(async (e) => { messageError($q, JSON.parse(await e.response.data.text())); @@ -239,19 +290,21 @@ function backPage() { } } -function downloadReport(type: string) { +function downloadReport(type: string, download: "docx" | "" | "xlsx" = "") { const fileName = optionReport.value.find((e) => e.id === typeReport.value.id)?.name || ""; - if (type === "xlsx") { + if (type === "xlsx" && download === "") { genReportXLSX(detailReport.value, fileName, type); + } else if (type === "pdf" && download === "xlsx") { + genReportXLSX(detailReport.value, fileName, "pdf"); } else { genReport(detailReport.value, fileName, type); } } onMounted(async () => { - await Promise.all([fetchDataTree(), fecthlistRound()]); + await Promise.all([fetchDataTree(), fecthlistRound(), fecthlistRound2()]); }); @@ -284,20 +337,42 @@ onMounted(async () => { flat round :loading="isLoadPDF" - :disable="!nodeId || !employeeClass || !roundId" + :disable="!nodeId || !employeeClass || (!roundId && !roundId2)" color="primary" icon="download" v-if="checkPermission($route)?.attrIsGet" > - + ไฟล์ .pdf - + @@ -342,6 +417,12 @@ onMounted(async () => {
{ + + + +
diff --git a/src/modules/21_report/views/05_reportSalary.vue b/src/modules/21_report/views/05_reportSalary.vue index 39d75df21..45611bd43 100644 --- a/src/modules/21_report/views/05_reportSalary.vue +++ b/src/modules/21_report/views/05_reportSalary.vue @@ -152,10 +152,11 @@ function fetchReportPDF() { async function fetchDataReportUnified( reportCode: string, - employeeClass: string, + employeeClass: string ) { isLoadFilePdf.value = true; - pdfSrc.value = undefined + pdfSrc.value = undefined; + page.value = 1; const isHalfYearReport = (id: string) => ["go1", "go2", "go2-01", "emp-08", "emp2-08"].includes(id);