From 1225254062cc0f7f5feee8691c51e84e7f927a81 Mon Sep 17 00:00:00 2001 From: "STW_TTTY\\stwtt" Date: Wed, 18 Sep 2024 14:33:32 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B9=80=E0=B8=81=E0=B9=89=E0=B9=82?= =?UTF-8?q?=E0=B8=AB=E0=B8=A5=E0=B8=94=E0=B9=84=E0=B8=9F=E0=B8=A5=E0=B9=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../04_registryPerson/views/detailView.vue | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/modules/04_registryPerson/views/detailView.vue b/src/modules/04_registryPerson/views/detailView.vue index 97cccd13e..aab696c0e 100644 --- a/src/modules/04_registryPerson/views/detailView.vue +++ b/src/modules/04_registryPerson/views/detailView.vue @@ -10,6 +10,9 @@ import { useQuasar } from "quasar"; import http from "@/plugins/http"; import config from "@/app.config"; import axios from "axios"; + +import genReport from "@/plugins/genreport"; + /** * importType */ @@ -298,7 +301,7 @@ async function fetchDataPersonal() { }); } -function onClickDownloadKp7(type: string) { +async function onClickDownloadKp7(type: string) { showLoader(); const url = type === "FULL" @@ -310,26 +313,18 @@ function onClickDownloadKp7(type: string) { : config.API.profileKp7ShortId(profileId.value); const fileName = type === "FULL" ? "ก.พ.7/ก.ก.1" : "ประวัติแบบย่อ"; - http - .get(url, { - responseType: "arraybuffer", // - }) - .then((res) => { - const data = res.data; - const blob = new Blob([data], { type: "application/pdf" }); - const url = URL.createObjectURL(blob); - const link = document.createElement("a"); - link.href = url; - link.download = `${fileName}.pdf`; - document.body.appendChild(link); - link.click(); + await http + .get(url) + .then(async (res) => { + const data = await res.data.result; + await genReport(data, `${fileName}`, type); + hideLoader(); }) .catch((err) => { messageError($q, err); - }) - .finally(() => { hideLoader(); - }); + }) + .finally(() => {}); } /**