ทะเบียนประวัติ => DownloadFile
This commit is contained in:
parent
ead02a85dd
commit
b74e9550ed
1 changed files with 27 additions and 5 deletions
|
|
@ -259,11 +259,33 @@ async function fetchDataPersonal() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClickDownloadKp7(type: string) {
|
function onClickDownloadKp7(type: string) {
|
||||||
if (type === "FULL") {
|
showLoader();
|
||||||
window.open(config.API.profileReportId(profileId.value));
|
const url =
|
||||||
} else if (type === "SHORT") {
|
type === "FULL"
|
||||||
window.open(config.API.profileKp7ShortId(profileId.value));
|
? config.API.profileReportId(profileId.value)
|
||||||
}
|
: config.API.profileKp7ShortId(profileId.value);
|
||||||
|
const fileName = type === "FULL" ? "ก.พ.7/ก.ก.1" : "ประวัติแบบย่อ";
|
||||||
|
http
|
||||||
|
.get(url, {
|
||||||
|
responseType: "arraybuffer", //
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
const data = res.data;
|
||||||
|
console.log(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();
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
messageError($q, err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ช่วยราชการ */
|
/** ช่วยราชการ */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue