fixed bulk action export action

This commit is contained in:
Cüneyt Şentürk 2021-05-23 18:45:33 +03:00
parent 4e924ab46d
commit e6e74a44b7

View File

@ -106,37 +106,43 @@ export default class BulkAction {
}));
download_promise.then((response) => {
const blob = new Blob([response.data], {type: response.data.type});
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
const contentDisposition = response.headers['content-disposition'];
let fileName = 'unknown';
if (contentDisposition) {
const fileNameMatch = contentDisposition.match(/filename=(.+)/);
if (fileNameMatch.length === 2) {
fileName = fileNameMatch[1];
if (response.data.type != 'application/json') {
const blob = new Blob([response.data], {type: response.data.type});
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
const contentDisposition = response.headers['content-disposition'];
let fileName = 'unknown';
if (contentDisposition) {
const fileNameMatch = contentDisposition.match(/filename=(.+)/);
if (fileNameMatch.length === 2) {
fileName = fileNameMatch[1];
}
}
link.setAttribute('download', fileName);
document.body.appendChild(link);
link.click();
link.remove();
window.URL.revokeObjectURL(url);
this.loading = false;
this.modal = false;
this.value = '*';
this.clear();
return;
}
link.setAttribute('download', fileName);
document.body.appendChild(link);
link.click();
link.remove();
window.URL.revokeObjectURL(url);
this.loading = false;
this.modal = false;
this.value = '*';
this.clear();
window.location.reload(false);
});
break;
default: