fixed bulk action export action
This commit is contained in:
parent
4e924ab46d
commit
e6e74a44b7
64
resources/assets/js/plugins/bulk-action.js
vendored
64
resources/assets/js/plugins/bulk-action.js
vendored
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user