Ver código fonte

Compatibilité IE : update tous les scripts vuejs (syntaxe function en argument)

dev
Guillaume Bourgeois 5 anos atrás
pai
commit
af20d8b205
2 arquivos alterados com 77 adições e 68 exclusões
  1. +47
    -40
      backend/web/js/vuejs/distribution-index.js
  2. +30
    -28
      producer/web/js/vuejs/subscription-form.js

+ 47
- 40
backend/web/js/vuejs/distribution-index.js Ver arquivo

@@ -105,53 +105,54 @@ var app = new Vue({
return false ;
},
init: function(idActivePointSale) {
var app = this ;
this.showLoading = true ;
axios.get("ajax-infos",{params: {date : this.getDate()}})
.then(response => {
this.distribution = response.data.distribution ;
.then(function(response) {
app.distribution = response.data.distribution ;
this.products = response.data.products ;
this.initCountActiveProducts() ;
app.products = response.data.products ;
app.initCountActiveProducts() ;
this.oneDistributionWeekActive = response.data.one_distribution_week_active ;
app.oneDistributionWeekActive = response.data.one_distribution_week_active ;
this.countOrders = 0 ;
app.countOrders = 0 ;
if(response.data.orders) {
this.orders = response.data.orders ;
app.orders = response.data.orders ;
for(i=0 ; i < this.orders.length ; i++) {
if(!this.orders[i].date_delete) {
this.countOrders ++ ;
for(i=0 ; i < app.orders.length ; i++) {
if(!app.orders[i].date_delete) {
app.countOrders ++ ;
}
}
}
else {
this.orders = [] ;
app.orders = [] ;
}
if(response.data.order_create) {
this.orderCreate = response.data.order_create ;
app.orderCreate = response.data.order_create ;
}
if(response.data.points_sale) {
this.pointsSale = response.data.points_sale ;
this.initPointsSale(idActivePointSale) ;
app.pointsSale = response.data.points_sale ;
app.initPointsSale(idActivePointSale) ;
}
else {
this.pointsSale = [] ;
app.pointsSale = [] ;
}
if(response.data.users) {
this.users = response.data.users ;
app.users = response.data.users ;
}
this.calendar.attrs = [] ;
app.calendar.attrs = [] ;
var distributions = response.data.distributions ;
if(distributions.length) {
for(var i= 0; i < distributions.length; i++) {
this.calendar.attrs.push({
app.calendar.attrs.push({
highlight: {
backgroundColor: '#5cb85c',
},
@@ -163,7 +164,7 @@ var app = new Vue({
}
}
this.showLoading = false ;
app.showLoading = false ;
}) ;
},
initCountActiveProducts: function() {
@@ -211,7 +212,7 @@ var app = new Vue({
idProduct: event.currentTarget.getAttribute('data-id-product'),
quantityMax: event.currentTarget.value
}})
.then(response => {
.then(function(response) {

}) ;
},
@@ -223,7 +224,7 @@ var app = new Vue({
idProduct: idProduct,
active: activeProduct
}})
.then(response => {
.then(function(response) {
}) ;
@@ -243,7 +244,7 @@ var app = new Vue({
idPointSale: idPointSale,
delivery: deliveryPointSale
}})
.then(response => {
.then(function(response) {
}) ;
@@ -256,23 +257,25 @@ var app = new Vue({
this.initPointsSale() ;
},
activeDistribution: function(event) {
var app = this ;
axios.get("ajax-process-active-distribution",{params: {
idDistribution: this.distribution.id,
active: event.currentTarget.getAttribute('data-active')
}})
.then(response => {
this.init() ;
.then(function(response) {
app.init() ;
}) ;
},
activeWeekDistribution: function(event) {
var app = this ;
axios.get("ajax-process-active-week-distribution",{params: {
date: this.date.getFullYear() + '-'
+ ('0' + (this.date.getMonth() +1)).slice(-2) + '-'
+ ('0' + this.date.getDate()).slice(-2),
active: event.currentTarget.getAttribute('data-active')
}})
.then(response => {
this.init() ;
.then(function(response) {
app.init() ;
}) ;
},
pointSaleClick: function(event) {
@@ -288,12 +291,13 @@ var app = new Vue({
this.init(this.idActivePointSale) ;
},
deleteOrderClick: function(event) {
var app = this ;
var idOrder = event.currentTarget.getAttribute('data-id-order') ;
axios.get(UrlManager.getBaseUrlAbsolute()+"order/ajax-delete",{params: {
idOrder: idOrder
}})
.then(response => {
this.init(this.idActivePointSale) ;
.then(function(response) {
app.init(app.idActivePointSale) ;
}) ;
},
updateOrderClick: function(event) {
@@ -307,14 +311,15 @@ var app = new Vue({
this.showModalPayment = true ;
},
orderPaymentClick: function(event) {
var app = this ;
var idOrder = event.currentTarget.getAttribute('data-id-order') ;
axios.get(UrlManager.getBaseUrlAbsolute()+"order/ajax-payment",{params: {
idOrder: this.idOrderPayment,
type: event.currentTarget.getAttribute('data-type'),
amount: event.currentTarget.getAttribute('data-amount')
}})
.then(response => {
this.init(this.idActivePointSale) ;
.then(function(response) {
app.init(app.idActivePointSale) ;
}) ;
},
orderViewClick: function(event) {
@@ -378,6 +383,7 @@ Vue.component('order-form',{
},
submitFormCreate: function() {
var app = this ;
if(this.checkForm()) {
axios.get(UrlManager.getBaseUrlAbsolute()+"order/ajax-create",{params: {
date: this.date.getFullYear() + '-'
@@ -389,20 +395,21 @@ Vue.component('order-form',{
products: JSON.stringify(this.order.productOrder),
comment: this.order.comment
}})
.then(response => {
this.order.id_point_sale = 0 ;
this.order.id_user = 0 ;
this.order.username = '' ;
this.order.comment = '' ;
for(i=0 ; i<this.order.productOrder.length ; i++) {
this.order.productOrder[i] = 0 ;
.then(function(response) {
app.order.id_point_sale = 0 ;
app.order.id_user = 0 ;
app.order.username = '' ;
app.order.comment = '' ;
for(i=0 ; i<app.order.productOrder.length ; i++) {
app.order.productOrder[i] = 0 ;
}

this.$emit('ordercreatedupdated') ;
app.$emit('ordercreatedupdated') ;
}) ;
}
},
submitFormUpdate: function() {
var app = this ;
if(this.checkForm()) {
axios.get(UrlManager.getBaseUrlAbsolute()+"order/ajax-update",{params: {
date: this.date.getFullYear() + '-'
@@ -415,8 +422,8 @@ Vue.component('order-form',{
products: JSON.stringify(this.order.productOrder),
comment: this.comment
}})
.then(response => {
this.$emit('ordercreatedupdated') ;
.then(function(response) {
app.$emit('ordercreatedupdated') ;
}) ;
}
},

+ 30
- 28
producer/web/js/vuejs/subscription-form.js Ver arquivo

@@ -29,6 +29,7 @@ var app = new Vue({
},
methods: {
init: function() {
var app = this ;
if($('#subscription-id').val() != 0) {
this.idSubscription = $('#subscription-id').val() ;
}
@@ -36,31 +37,31 @@ var app = new Vue({
this.dateBegin = new Date() ;

axios.get("ajax-infos",{params: {idSubscription : this.idSubscription}})
.then(response => {
.then(function(response) {
this.products = response.data.products ;
this.pointsSale = response.data.points_sale ;
app.products = response.data.products ;
app.pointsSale = response.data.points_sale ;
if(this.idSubscription > 0) {
this.validatePointSale(response.data.id_point_sale) ;
this.weekFrequency = response.data.week_frequency ;
this.autoPayment = response.data.auto_payment ;
if(app.idSubscription > 0) {
app.validatePointSale(response.data.id_point_sale) ;
app.weekFrequency = response.data.week_frequency ;
app.autoPayment = response.data.auto_payment ;
var arrayDateBegin = response.data.date_begin.split('-') ;
this.dateBegin = new Date(arrayDateBegin[0], arrayDateBegin[1] - 1, arrayDateBegin[2]) ;
app.dateBegin = new Date(arrayDateBegin[0], arrayDateBegin[1] - 1, arrayDateBegin[2]) ;
if(response.data.date_end && response.data.date_end.length > 0) {
var arrayDateEnd = response.data.date_begin.split('-') ;
this.dateEnd = new Date(arrayDateEnd[0], arrayDateEnd[1] - 1, arrayDateEnd[2]) ;
app.dateEnd = new Date(arrayDateEnd[0], arrayDateEnd[1] - 1, arrayDateEnd[2]) ;
}
this.monday = response.data.monday ;
this.tuesday = response.data.tuesday ;
this.wednesday = response.data.wednesday ;
this.thursday = response.data.thursday ;
this.friday = response.data.friday ;
this.saturday = response.data.saturday ;
this.sunday = response.data.sunday ;
app.monday = response.data.monday ;
app.tuesday = response.data.tuesday ;
app.wednesday = response.data.wednesday ;
app.thursday = response.data.thursday ;
app.friday = response.data.friday ;
app.saturday = response.data.saturday ;
app.sunday = response.data.sunday ;
}
this.loading = false ;
app.loading = false ;
});
},
@@ -71,7 +72,7 @@ var app = new Vue({
return false ;
},
pointSaleClick: function(event) {
var app = this ;
var idPointSale = event.currentTarget.getAttribute('data-id-point-sale') ;
var hasCode = event.currentTarget.getAttribute('data-code') ;
@@ -79,14 +80,14 @@ var app = new Vue({
axios.get('ajax-validate-code-point-sale',{params: {
idPointSale: idPointSale,
code: this.pointsSaleCodes[idPointSale]
}}).then(response => {
}}).then(function(response) {
if(response.data) {
this.getPointSale(idPointSale).invalid_code = false ;
this.validatePointSale(idPointSale) ;
app.getPointSale(idPointSale).invalid_code = false ;
app.validatePointSale(idPointSale) ;
}
else {
this.getPointSale(idPointSale).invalid_code = true ;
Vue.set(this.pointsSaleCodes, idPointSale, '');
app.getPointSale(idPointSale).invalid_code = true ;
Vue.set(app.pointsSaleCodes, idPointSale, '');
}
}) ;
}
@@ -219,12 +220,13 @@ var app = new Vue({
sunday: this.sunday == true ? 1 : 0,
products: productsArray
}
}).then(response => {
}).then(function(response) {
window.location.href = chat_base_url(true)+'subscription/index' ;
});
}
},
checkForm: function() {
var app = this ;
this.errors = [] ;
if(!this.idPointSaleActive) {
@@ -235,13 +237,13 @@ var app = new Vue({
axios.get('ajax-validate-code-point-sale',{params: {
idPointSale: this.idPointSaleActive,
code: this.pointSaleActive.code
}}).then(response => {
}}).then(function(response) {
if(response.data) {
this.pointsSale[idPointSale].invalid_code = false ;
app.pointsSale[idPointSale].invalid_code = false ;
}
else {
this.pointsSale[idPointSale].invalid_code = true ;
Vue.set(this.pointsSaleCodes, idPointSale, '');
app.pointsSale[idPointSale].invalid_code = true ;
Vue.set(app.pointsSaleCodes, idPointSale, '');
}
}) ;
}

Carregando…
Cancelar
Salvar