let winOri = window.location.origin;
let _url =
winOri +
`/pdtz/sxbl/sl/bItemAcceptAttachment_downloadZipByAcceptId?acceptId=${this.formId}`;
fetch(_url, {
method: "GET",
headers: {
//"Access-Control-Allow-Origin: *"
["Authorization"]: sessionStorage.getItem("token"),
["Access-Control-Allow-Origin"]: "*",
["Access-Control-Allow-Methods"]: "options",
},
}).then(async (res) => {
const attachment = res.headers.get("Content-Disposition");
console.log(attachment);
if (attachment) {
const attachmentArr = attachment.split("; ");
console.log(attachmentArr);
if (attachmentArr[0] === "attachment") {
const attachmentArrJq = attachmentArr[1].split("=");
const attachmentArrTo = attachmentArrJq[1].substring(
0,
attachmentArrJq[1].length - 1
);
const fileNameUtf8 = attachmentArrTo.substr(1)
if (fileNameUtf8.length > 1) {
const fileName = fileNameUtf8[1];
console.log(fileName);
const fileBlob = await res.blob();
const link = document.createElement("a");
link.download = fileName;
link.style.display = "none";
link.href = URL.createObjectURL(fileBlob);
document.body.appendChild(link);
link.click();
URL.revokeObjectURL(link.href);
document.body.removeChild(link);
}
}
}
});