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(() => {}); } /**