mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Merge branch 'bulk-download-invoices' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into staging
This commit is contained in:
@@ -91,7 +91,11 @@
|
||||
},
|
||||
successHandler(response) {
|
||||
this.isLoading = false;
|
||||
this.returnData = response;
|
||||
if (response.message) {
|
||||
this.returnData = response;
|
||||
} else {
|
||||
this.returnData = null;
|
||||
}
|
||||
},
|
||||
hasMarkingParameter() {
|
||||
const urlSearchParams = new URLSearchParams(window.location.search);
|
||||
|
||||
+29
-9
@@ -13,19 +13,39 @@ export default {
|
||||
let statusCode = response.status,
|
||||
success = response.ok;
|
||||
|
||||
response.json().then(response => {
|
||||
if (response.headers.get("content-type") === "application/zip") {
|
||||
const fileName = response.headers.get('Content-Disposition').split('filename=')[1];
|
||||
|
||||
if(!success){
|
||||
this.openModal();
|
||||
errorNotification ? this.$store.dispatch('createNotification', {title: response.title, message: response.message, type: 'error'}): null;
|
||||
this.errorHandler(response, statusCode); return;
|
||||
}
|
||||
response.blob().then(response => {
|
||||
if (!success) {
|
||||
this.openModal();
|
||||
errorNotification ? this.$store.dispatch('createNotification', { title: response.title, message: response.message, type: 'error' }) : null;
|
||||
this.errorHandler(response, statusCode); return;
|
||||
}
|
||||
|
||||
successNotification ? this.$store.dispatch('createNotification', {title: response.title, message: response.message, type: 'success'}): null;
|
||||
this.successHandler(response)
|
||||
successNotification ? this.$store.dispatch('createNotification', { title: response.title, message: response.message, type: 'success' }) : null;
|
||||
|
||||
const link = document.createElement('a');
|
||||
link.href = window.URL.createObjectURL(response);
|
||||
link.download = fileName;
|
||||
link.click();
|
||||
this.successHandler(response)
|
||||
});
|
||||
} else {
|
||||
response.json().then(response => {
|
||||
|
||||
if (!success) {
|
||||
this.openModal();
|
||||
errorNotification ? this.$store.dispatch('createNotification', { title: response.title, message: response.message, type: 'error' }) : null;
|
||||
this.errorHandler(response, statusCode); return;
|
||||
}
|
||||
|
||||
successNotification ? this.$store.dispatch('createNotification', { title: response.title, message: response.message, type: 'success' }) : null;
|
||||
this.successHandler(response)
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
this.$store.dispatch('createNotification', {title: 'Unexpected Error', message: 'An unexpected error has occurred. Try again!', type: 'error'});
|
||||
|
||||
Reference in New Issue
Block a user