From 1cad82f2588597ee5db234ab43966c2e14a0f097 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Fri, 29 Aug 2025 15:40:07 +0700 Subject: [PATCH] =?UTF-8?q?fix=20bug=20=3D=3D>=20=E0=B8=94=E0=B8=B2?= =?UTF-8?q?=E0=B8=A7=E0=B8=99=E0=B9=8C=E0=B9=82=E0=B8=AB=E0=B8=A5=E0=B8=94?= =?UTF-8?q?=E0=B9=84=E0=B8=9F=E0=B8=A5=E0=B9=8C=E0=B8=9B=E0=B8=A3=E0=B8=B0?= =?UTF-8?q?=E0=B8=A7=E0=B8=B1=E0=B8=95=E0=B8=B4=E0=B8=AA=E0=B8=B3=E0=B8=AB?= =?UTF-8?q?=E0=B8=A3=E0=B8=B1=E0=B8=9A=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B9=80?= =?UTF-8?q?=E0=B8=AA=E0=B8=99=E0=B8=AD=E0=B8=82=E0=B8=AD=E0=B8=9E=E0=B8=A3?= =?UTF-8?q?=E0=B8=B0=E0=B8=A3=E0=B8=B2=E0=B8=8A=E0=B8=97=E0=B8=B2=E0=B8=99?= =?UTF-8?q?=E0=B9=80=E0=B8=AB=E0=B8=A3=E0=B8=B5=E0=B8=A2=E0=B8=8D=E0=B8=88?= =?UTF-8?q?=E0=B8=B1=E0=B8=81=E0=B8=A3=E0=B8=9E=E0=B8=A3=E0=B8=A3=E0=B8=94?= =?UTF-8?q?=E0=B8=B4=E0=B8=A1=E0=B8=B2=E0=B8=A5=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../07_insignia/components/2_Manage/Tab1.vue | 8 +-- .../components/2_Manage/downloadFile.vue | 72 ++++++------------- 2 files changed, 24 insertions(+), 56 deletions(-) diff --git a/src/modules/07_insignia/components/2_Manage/Tab1.vue b/src/modules/07_insignia/components/2_Manage/Tab1.vue index 5641ad146..884864418 100644 --- a/src/modules/07_insignia/components/2_Manage/Tab1.vue +++ b/src/modules/07_insignia/components/2_Manage/Tab1.vue @@ -1245,17 +1245,15 @@ onMounted(async () => { - + {{ props.rowIndex + 1 }} diff --git a/src/modules/07_insignia/components/2_Manage/downloadFile.vue b/src/modules/07_insignia/components/2_Manage/downloadFile.vue index e879bd3e6..caca2bc65 100644 --- a/src/modules/07_insignia/components/2_Manage/downloadFile.vue +++ b/src/modules/07_insignia/components/2_Manage/downloadFile.vue @@ -6,7 +6,8 @@ import { useCounterMixin } from "@/stores/mixin"; import http from "@/plugins/http"; import config from "@/app.config"; -import type { Optionround } from "@/modules/07_insignia/interface/index/Main"; +import genReport from "@/plugins/genreport"; +import genReportXLSX from "@/plugins/genreportxlsx"; /** use*/ const $q = useQuasar(); @@ -15,68 +16,37 @@ const { messageError, showLoader, hideLoader } = mixin; /** props*/ const props = defineProps({ - profileId: { + rowId: { type: String, }, - round: { - type: String, - }, - optionRound: { - type: Object, - }, }); -const titleReport = ref(""); //ชื่อรายงาน - /** * function ดาวน์โหลดไฟล์ * @param type ประเภท file */ async function downloadDocument(type: string) { - let round = []; - if (props.optionRound) { - round = props.optionRound.find((e: Optionround) => e.id === props.round); - } - titleReport.value = round.name; - const download: boolean = true; - if (props.profileId) { - showLoader(); - await http - .get(config.API.reportInsignia("46", type, props.profileId), { - responseType: "blob", - }) - .then(async (res) => { - if (download) { - downloadFile( - res, - `ประวัติสำหรับการเสนอขอพระราชทานเหรียญจักรพรรดิมาลา.${type}` - ); - } - }) - .catch(async (e) => { - messageError($q, JSON.parse(await e.response.data.text())); - }) - .finally(() => { - hideLoader(); - }); - } -} + showLoader(); + try { + const res = await http.post( + config.API.reportInsigniaNew + `/report8/${props.rowId}` + ); -/** - * function โหลดเอกสาร - * @param response ข้อมู - * @param filename ชื่อไฟล์ - */ -function downloadFile(response: any, filename: string) { - const link = document.createElement("a"); - var fileName = filename; - link.href = window.URL.createObjectURL(new Blob([response.data])); - link.setAttribute("download", fileName); - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); + const reportTitle = "ประวัติสำหรับการเสนอขอพระราชทานเหรียญจักรพรรดิมาลา"; + + if (type === "xlsx") { + await genReportXLSX(res.data.result, reportTitle, type); + } else { + await genReport(res.data.result, reportTitle, type); + } + } catch (error) { + messageError($q, error); + } finally { + hideLoader(); + } } +