|
|
@@ -5,6 +5,8 @@ var app = new Vue({ |
|
|
|
data() { |
|
|
|
return Object.assign({ |
|
|
|
order: null, |
|
|
|
timerAjaxInfosProducts: false, |
|
|
|
xhr: false, |
|
|
|
loading: false, |
|
|
|
loadingProducts: false, |
|
|
|
loadingInit: true, |
|
|
@@ -132,9 +134,26 @@ var app = new Vue({ |
|
|
|
var app = this ; |
|
|
|
|
|
|
|
if(loadingProducts) { |
|
|
|
if(app.cancelTokenSource !== null) { |
|
|
|
app.cancelTokenSource.cancel(); |
|
|
|
if (app.timerAjaxInfosProducts) { |
|
|
|
clearTimeout(app.timerAjaxInfosProducts); |
|
|
|
} |
|
|
|
app.timerAjaxInfosProducts = setTimeout(function(app) { |
|
|
|
app.loadingProducts = true ; |
|
|
|
if(app.xhr) { |
|
|
|
app.xhr.abort(); |
|
|
|
} |
|
|
|
app.xhr = $.get('ajax-infos', { |
|
|
|
date : app.getDate(), |
|
|
|
pointSaleId: app.pointSaleActiveId ? app.pointSaleActiveId : (app.pointSaleActive ? app.pointSaleActive.id : 0), |
|
|
|
productsJson: JSON.stringify(app.getProductsArray()), |
|
|
|
loadingProducts: loadingProducts |
|
|
|
}, function(response) { |
|
|
|
app.products = response.products; |
|
|
|
app.loadingProducts = false; |
|
|
|
}, 'json'); |
|
|
|
}.bind(this, app), 300); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
else { |
|
|
|
this.loading = true ; |
|
|
@@ -145,9 +164,9 @@ var app = new Vue({ |
|
|
|
app.products = [] ; |
|
|
|
} |
|
|
|
|
|
|
|
app.cancelTokenSource = axios.CancelToken.source(); |
|
|
|
//app.cancelTokenSource = axios.CancelToken.source(); |
|
|
|
axios.get("ajax-infos",{ |
|
|
|
cancelToken: app.cancelTokenSource.token, |
|
|
|
//cancelToken: app.cancelTokenSource.token, |
|
|
|
params: { |
|
|
|
date : this.getDate(), |
|
|
|
pointSaleId: this.pointSaleActiveId ? this.pointSaleActiveId : (this.pointSaleActive ? this.pointSaleActive.id : 0), |
|
|
@@ -156,8 +175,6 @@ var app = new Vue({ |
|
|
|
}}) |
|
|
|
.catch(function (thrown) { |
|
|
|
if (axios.isCancel(thrown)) { |
|
|
|
//console.log('Request canceled', thrown.message); |
|
|
|
//return Promise.reject(thrown); |
|
|
|
} |
|
|
|
}) |
|
|
|
.then(function(response) { |