แก้ download ทะเบียนประวัติ
This commit is contained in:
parent
21fb81243c
commit
e24f66f978
1 changed files with 27 additions and 6 deletions
|
|
@ -21,7 +21,7 @@ import { useQuasar } from "quasar";
|
||||||
const store = useRegistryInFormationStore();
|
const store = useRegistryInFormationStore();
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { messageError, dialogConfirm } = mixin;
|
const { messageError, dialogConfirm ,showLoader,hideLoader } = mixin;
|
||||||
const profileImg = ref<string>("");
|
const profileImg = ref<string>("");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const tab = ref<string>("information");
|
const tab = ref<string>("information");
|
||||||
|
|
@ -89,11 +89,32 @@ function getType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClickDownloadKp7(type: string) {
|
function onClickDownloadKp7(type: string) {
|
||||||
if (type === "FULL") {
|
showLoader();
|
||||||
window.open(config.API.profileReportId(store.profileId));
|
const url =
|
||||||
} else if (type === "SHORT") {
|
type === "FULL"
|
||||||
window.open(config.API.profileKp7ShortId(store.profileId));
|
? config.API.profileReportId(store.profileId)
|
||||||
}
|
: config.API.profileKp7ShortId(store.profileId);
|
||||||
|
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();
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
messageError($q, err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue