เเก้โหลดไฟล์
This commit is contained in:
parent
1f5e610df2
commit
1225254062
1 changed files with 12 additions and 17 deletions
|
|
@ -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(() => {});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue