|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
init: function(type) { |
|
|
|
|
|
|
|
|
init: function(type, oldStep, step) { |
|
|
|
|
|
|
|
|
var app = this ; |
|
|
var app = this ; |
|
|
this.loading = true ; |
|
|
this.loading = true ; |
|
|
|
|
|
|
|
|
|
|
|
if(app.isChangeState('date', 'date', 'point-sale')) { |
|
|
|
|
|
app.pointSaleActive = null ; |
|
|
|
|
|
app.products = [] ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
axios.get("ajax-infos",{params: { |
|
|
axios.get("ajax-infos",{params: { |
|
|
date : this.getDate(), |
|
|
date : this.getDate(), |
|
|
pointSaleId: this.pointSaleActive ? this.pointSaleActive.id : 0 |
|
|
pointSaleId: this.pointSaleActive ? this.pointSaleActive.id : 0 |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// produits |
|
|
|
|
|
if(response.data.products) { |
|
|
|
|
|
app.products = response.data.products ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// catégories |
|
|
// catégories |
|
|
if(response.data.categories) { |
|
|
if(response.data.categories) { |
|
|
app.categories = response.data.categories ; |
|
|
app.categories = response.data.categories ; |
|
|
app.setCategoryCurrent(response.data.categories[0]) ; |
|
|
app.setCategoryCurrent(response.data.categories[0]) ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// producer |
|
|
|
|
|
app.producer = response.data.producer; |
|
|
|
|
|
|
|
|
|
|
|
// user |
|
|
|
|
|
app.user = response.data.user; |
|
|
|
|
|
|
|
|
if(type != 'products') { |
|
|
|
|
|
|
|
|
// use credit |
|
|
|
|
|
app.useCredit = response.data.producer.use_credit_checked_default; |
|
|
|
|
|
|
|
|
app.producer = response.data.producer; |
|
|
|
|
|
app.user = response.data.user; |
|
|
|
|
|
app.useCredit = response.data.producer.use_credit_checked_default; |
|
|
|
|
|
|
|
|
// points de vente |
|
|
|
|
|
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.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(app.isChangeState('point-sale', 'point-sale', 'date')) { |
|
|
|
|
|
app.date = null ; |
|
|
|
|
|
app.dateFormat = null ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// update order |
|
|
|
|
|
var updateOrder = false ; |
|
|
|
|
|
if(app.isChangeState('date', 'point-sale', 'products') |
|
|
|
|
|
|| app.isChangeState('date', 'date', 'point-sale') |
|
|
|
|
|
|| app.isChangeState('point-sale', 'date', 'products') |
|
|
|
|
|
|| app.isChangeState('point-sale', 'point-sale', 'date')) { |
|
|
|
|
|
|
|
|
|
|
|
updateOrder = true ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(updateOrder) { |
|
|
|
|
|
// products |
|
|
|
|
|
if(response.data.products) { |
|
|
|
|
|
app.products = response.data.products ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// commande |
|
|
|
|
|
|
|
|
// order |
|
|
app.order = null ; |
|
|
app.order = null ; |
|
|
if(response.data.order) { |
|
|
if(response.data.order) { |
|
|
app.order = response.data.order ; |
|
|
app.order = response.data.order ; |
|
|
app.comment = app.order.comment ; |
|
|
app.comment = app.order.comment ; |
|
|
console.log(app.order) ; |
|
|
|
|
|
app.delivery = app.order.delivery_home ; |
|
|
app.delivery = app.order.delivery_home ; |
|
|
if(app.order.delivery_address && app.order.delivery_address.length > 0) { |
|
|
if(app.order.delivery_address && app.order.delivery_address.length > 0) { |
|
|
app.deliveryAddress = app.order.delivery_address ; |
|
|
app.deliveryAddress = app.order.delivery_address ; |
|
|
|
|
|
|
|
|
if(app.user.address.length > 0) { |
|
|
if(app.user.address.length > 0) { |
|
|
app.deliveryAddress = app.user.address ; |
|
|
app.deliveryAddress = app.user.address ; |
|
|
} |
|
|
} |
|
|
app.pointSaleActive = null ; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
isChangeState: function(entryPoint, oldStep, newStep) { |
|
|
|
|
|
|
|
|
|
|
|
return this.producer |
|
|
|
|
|
&& entryPoint == this.producer.option_order_entry_point |
|
|
|
|
|
&& oldStep == this.oldStep |
|
|
|
|
|
&& newStep == this.step ; |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
nextStep: function() { |
|
|
nextStep: function() { |
|
|
this.errors = [] ; |
|
|
this.errors = [] ; |
|
|
var oldStep = this.step ; |
|
|
var oldStep = this.step ; |
|
|
|
|
|
|
|
|
changeStep: function(step) { |
|
|
changeStep: function(step) { |
|
|
this.errors = [] ; |
|
|
this.errors = [] ; |
|
|
var oldStep = this.step ; |
|
|
var oldStep = this.step ; |
|
|
|
|
|
this.oldStep = oldStep ; |
|
|
|
|
|
|
|
|
if(oldStep == 'products' && step == 'payment') { |
|
|
if(oldStep == 'products' && step == 'payment') { |
|
|
this.checkProducts() ; |
|
|
this.checkProducts() ; |
|
|
|
|
|
|
|
|
if(!this.errors.length) { |
|
|
if(!this.errors.length) { |
|
|
this.step = step ; |
|
|
this.step = step ; |
|
|
window.scroll(0, $('#page-title').position().top - 25) ; |
|
|
window.scroll(0, $('#page-title').position().top - 25) ; |
|
|
|
|
|
|
|
|
if((oldStep == 'date' && step == 'point-sale') |
|
|
|
|
|
|| (oldStep == 'date' && step == 'products')) { |
|
|
|
|
|
|
|
|
|
|
|
this.init('basic') ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if((oldStep == 'point-sale' && step == 'products') |
|
|
|
|
|
|| (oldStep == 'point-sale' && step == 'date')) { |
|
|
|
|
|
|
|
|
|
|
|
this.init('products') ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.init('basic', oldStep, step) ; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
dayClickList: function(event) { |
|
|
dayClickList: function(event) { |