axios(process.env.BASE_API + "/drawing/templateDownload", {
method: "get",
params: {
docIdList: selectedIdList,
projectId: parseInt(this.$route.query.projectId)
},
paramsSerializer: params => {
return qs.stringify(params, { indices: false });
},
withCredentials: true,
responseType: "arraybuffer"
}).then(result => {
const blob = new Blob([result.data]);
const fileName = result.headers["x-suggested-filename"];
Tools.download(blob, fileName);
});
/**
* Download File
* @param blob blob
* @param fileName File Name
*/
static download(blob, fileName) {
fileName = decodeURIComponent(fileName);
if (window.navigator.msSaveOrOpenBlob) {
// Compatible with IE10
navigator.msSaveBlob(blob, fileName);
} else {
// Chrome/Firefox
let aTag = document.createElement("a");
aTag.download = fileName;
aTag.href = URL.createObjectURL(blob);
aTag.click();
URL.revokeObjectURL(aTag.href);
}
}