|
|
|
|
|
|
|
|
data() { |
|
|
data() { |
|
|
return Object.assign({ |
|
|
return Object.assign({ |
|
|
order: null, |
|
|
order: null, |
|
|
|
|
|
timerAjaxInfosProducts: false, |
|
|
|
|
|
xhr: false, |
|
|
loading: false, |
|
|
loading: false, |
|
|
loadingProducts: false, |
|
|
loadingProducts: false, |
|
|
loadingInit: true, |
|
|
loadingInit: true, |
|
|
|
|
|
|
|
|
var app = this ; |
|
|
var app = this ; |
|
|
|
|
|
|
|
|
if(loadingProducts) { |
|
|
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 { |
|
|
else { |
|
|
this.loading = true ; |
|
|
this.loading = true ; |
|
|
|
|
|
|
|
|
app.products = [] ; |
|
|
app.products = [] ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
app.cancelTokenSource = axios.CancelToken.source(); |
|
|
|
|
|
|
|
|
//app.cancelTokenSource = axios.CancelToken.source(); |
|
|
axios.get("ajax-infos",{ |
|
|
axios.get("ajax-infos",{ |
|
|
cancelToken: app.cancelTokenSource.token, |
|
|
|
|
|
|
|
|
//cancelToken: app.cancelTokenSource.token, |
|
|
params: { |
|
|
params: { |
|
|
date : this.getDate(), |
|
|
date : this.getDate(), |
|
|
pointSaleId: this.pointSaleActiveId ? this.pointSaleActiveId : (this.pointSaleActive ? this.pointSaleActive.id : 0), |
|
|
pointSaleId: this.pointSaleActiveId ? this.pointSaleActiveId : (this.pointSaleActive ? this.pointSaleActive.id : 0), |
|
|
|
|
|
|
|
|
}}) |
|
|
}}) |
|
|
.catch(function (thrown) { |
|
|
.catch(function (thrown) { |
|
|
if (axios.isCancel(thrown)) { |
|
|
if (axios.isCancel(thrown)) { |
|
|
//console.log('Request canceled', thrown.message); |
|
|
|
|
|
//return Promise.reject(thrown); |
|
|
|
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
.then(function(response) { |
|
|
.then(function(response) { |