feat: replaced await by recursive function
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
dc62841c3d
commit
9d53360d50
|
@ -50,15 +50,32 @@ class Controller extends Dialog {
|
|||
this.$.invoiceButton.disabled = false;
|
||||
}
|
||||
|
||||
invoice() {
|
||||
invoiceOut(invoice, clientsAndAddresses) {
|
||||
const clientAndAddress = clientsAndAddresses[this.pos];
|
||||
return this.post(`InvoiceOuts/globalInvoicing`, params, options).then(() => {
|
||||
this.pos++;
|
||||
this.invoice();
|
||||
});
|
||||
if (!clientAndAddress) return;
|
||||
this.currentClientId = clientAndAddress.clientId;
|
||||
const params = {
|
||||
clientId: clientAndAddress.clientId,
|
||||
addressId: clientAndAddress.addressId,
|
||||
invoiceDate: invoice.invoiceDate,
|
||||
maxShipped: invoice.maxShipped,
|
||||
companyFk: invoice.companyFk,
|
||||
minShipped: invoice.minShipped,
|
||||
|
||||
};
|
||||
this.canceler = this.$q.defer();
|
||||
const options = {
|
||||
timeout: this.canceler.promise
|
||||
};
|
||||
|
||||
return this.$http.post(`InvoiceOuts/globalInvoicing`, params, options)
|
||||
.then(() => {
|
||||
this.pos++;
|
||||
return this.invoiceOut(invoice, clientsAndAddresses);
|
||||
});
|
||||
}
|
||||
|
||||
async responseHandler(response) {
|
||||
responseHandler(response) {
|
||||
try {
|
||||
if (response !== 'accept')
|
||||
return super.responseHandler(response);
|
||||
|
@ -77,33 +94,14 @@ class Controller extends Dialog {
|
|||
this.$.invoiceButton.disabled = true;
|
||||
if (this.clientsNumber == 'allClients') this.getMaxClientId();
|
||||
|
||||
this.pos = 0;
|
||||
this.invoice();
|
||||
|
||||
this.$http.post(`InvoiceOuts/clientToInvoice`, this.invoice)
|
||||
.then(async res => {
|
||||
.then(res => {
|
||||
const invoice = res.data.invoice;
|
||||
const clientsAndAddresses = res.data.clientsAndAddresses;
|
||||
if (!clientsAndAddresses.length) return super.responseHandler(response);
|
||||
this.lastClientId = clientsAndAddresses[clientsAndAddresses.length - 1].clientId;
|
||||
|
||||
for (let clientAndAddress of clientsAndAddresses) {
|
||||
this.currentClientId = clientAndAddress.clientId;
|
||||
const params = {
|
||||
clientId: clientAndAddress.clientId,
|
||||
addressId: clientAndAddress.addressId,
|
||||
invoiceDate: invoice.invoiceDate,
|
||||
maxShipped: invoice.maxShipped,
|
||||
companyFk: invoice.companyFk,
|
||||
minShipped: invoice.minShipped,
|
||||
|
||||
};
|
||||
this.canceler = this.$q.defer();
|
||||
const options = {
|
||||
timeout: this.canceler.promise
|
||||
};
|
||||
await this.$http.post(`InvoiceOuts/globalInvoicing`, params, options).then();
|
||||
}
|
||||
this.pos = 0;
|
||||
return this.invoiceOut(invoice, clientsAndAddresses);
|
||||
})
|
||||
.then(() => super.responseHandler(response))
|
||||
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')))
|
||||
|
|
Loading…
Reference in New Issue