Browse Source

[producer] Prise de commande : mise à jour des prix lors de la sélection d'un point de vente

dev
Guillaume 3 years ago
parent
commit
616c061e2f
1 changed files with 76 additions and 71 deletions
  1. +76
    -71
      producer/web/js/vuejs/order-order.js

+ 76
- 71
producer/web/js/vuejs/order-order.js View File

@@ -104,7 +104,7 @@ var app = new Vue({
}
}
},
init: function() {
init: function(updateOnlyProducts) {
var app = this ;
this.loading = true ;
axios.get("ajax-infos",{params: {
@@ -112,91 +112,94 @@ var app = new Vue({
pointSaleId: this.pointSaleActive ? this.pointSaleActive.id : 0
}})
.then(function(response) {
app.producer = response.data.producer ;
app.user = response.data.user ;
app.useCredit = response.data.producer.use_credit_checked_default ;
app.calendar.attrs = [] ;
app.calendar.availableDates = [] ;
var distributions = response.data.distributions ;
if(distributions.length) {
app.distributions = distributions ;
var arrayDate ;
for(var i= 0; i < distributions.length; i++) {
app.calendar.attrs.push({
highlight: {
backgroundColor: '#5cb85c',
},
contentStyle: {
color: 'white',
},
dates: distributions[i].date,
}) ;
arrayDate = distributions[i].date.split('-') ;
app.calendar.availableDates.push({
start: new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]),
end: new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2])
}) ;

}
}
var orders = [] ;
if(response.data.orders) {
orders = response.data.orders ;
}
if(orders.length) {

for(var i= 0; i < orders.length; i++) {
arrayDate = orders[i].date_distribution.split('-') ;
var dateOrder = new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]) ;
if(app.isAvailableDate(dateOrder)) {

if(!updateOnlyProducts) {
app.producer = response.data.producer;
app.user = response.data.user;
app.useCredit = response.data.producer.use_credit_checked_default;
app.calendar.attrs = [];
app.calendar.availableDates = [];
var distributions = response.data.distributions;
if (distributions.length) {
app.distributions = distributions;
var arrayDate;
for (var i = 0; i < distributions.length; i++) {
app.calendar.attrs.push({
highlight: {
backgroundColor: '#FF7F00'
backgroundColor: '#5cb85c',
},
contentStyle: {
color: 'white'
color: 'white',
},
popover: {
label: orders[i].pointSale.name + ' / '+app.formatPrice(orders[i].amount_total),
hideIndicator: true
},
dates: orders[i].date_distribution,
}) ;
dates: distributions[i].date,
});

arrayDate = distributions[i].date.split('-');
app.calendar.availableDates.push({
start: new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]),
end: new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2])
});

}
}
}
if(response.data.distribution) {
app.distribution = response.data.distribution ;
}
var orders = [];
if (response.data.orders) {
orders = response.data.orders;
}

if (orders.length) {
for (var i = 0; i < orders.length; i++) {
arrayDate = orders[i].date_distribution.split('-');
var dateOrder = new Date(arrayDate[0], arrayDate[1] - 1, arrayDate[2]);
if (app.isAvailableDate(dateOrder)) {

if(response.data.points_sale) {
app.pointsSale = [] ;
var orderPointSale = 0 ;
for(var key in response.data.points_sale) {
response.data.points_sale[key].order = orderPointSale ++ ;
app.pointsSale[response.data.points_sale[key].id] = response.data.points_sale[key] ;
app.pointsSaleCodes[response.data.points_sale[key].id] = '' ;
Vue.set(app.pointsSaleCodes, response.data.points_sale[key].id, '');
app.calendar.attrs.push({
highlight: {
backgroundColor: '#FF7F00'
},
contentStyle: {
color: 'white'
},
popover: {
label: orders[i].pointSale.name + ' / ' + app.formatPrice(orders[i].amount_total),
hideIndicator: true
},
dates: orders[i].date_distribution,
});
}
}
}

if (response.data.distribution) {
app.distribution = response.data.distribution;
}

if (response.data.points_sale) {
app.pointsSale = [];
var orderPointSale = 0;
for (var key in response.data.points_sale) {
response.data.points_sale[key].order = orderPointSale++;
app.pointsSale[response.data.points_sale[key].id] = response.data.points_sale[key];
app.pointsSaleCodes[response.data.points_sale[key].id] = '';
Vue.set(app.pointsSaleCodes, response.data.points_sale[key].id, '');
}
}
}
if(response.data.products) {
app.products = response.data.products ;
}
app.order = null ;
if(response.data.order) {
app.order = response.data.order ;
app.pointSaleActive = app.getPointSale(response.data.order.id_point_sale) ;
}
else {
app.pointSaleActive = null ;

if(!updateOnlyProducts) {
app.order = null ;
if(response.data.order) {
app.order = response.data.order ;
app.pointSaleActive = app.getPointSale(response.data.order.id_point_sale) ;
}
else {
app.pointSaleActive = null ;
}
}
app.loading = false ;
});
},
@@ -272,6 +275,8 @@ var app = new Vue({
else {
this.validatePointSale(idPointSale) ;
}

app.init(true) ;
},

validatePointSale: function(idPointSale) {

Loading…
Cancel
Save