salix/modules/ticket/front/basic-data/step-two/index.js

59 lines
1.5 KiB
JavaScript

import ngModule from '../../module';
class Controller {
constructor($http) {
this.$http = $http;
}
$onInit() {
this.data.registerChild(this);
this.getTotalPrice();
this.getTotalNewPrice();
this.getTotalDifferenceOfPrice();
}
onStepChange(state) {
return true;
}
getTotalPrice() {
let totalPrice = 0;
this.ticket.sale.items.forEach(item => {
let itemTotalPrice = item.quantity * item.price;
totalPrice += itemTotalPrice;
});
this.totalPrice = totalPrice;
}
getTotalNewPrice() {
let totalNewPrice = 0;
this.ticket.sale.items.forEach(item => {
let itemTotalNewPrice = item.quantity * item.component.newPrice;
totalNewPrice += itemTotalNewPrice;
});
this.totalNewPrice = totalNewPrice;
}
getTotalDifferenceOfPrice() {
let totalPriceDifference = 0;
this.ticket.sale.items.forEach(item => {
let itemTotalPriceDifference = item.quantity * item.component.difference;
totalPriceDifference += itemTotalPriceDifference;
});
this.totalPriceDifference = totalPriceDifference;
}
}
Controller.$inject = ['$http'];
ngModule.component('vnTicketBasicDataStepTwo', {
template: require('./index.html'),
controller: Controller,
bindings: {
ticket: '<'
},
require: {
data: '^vnTicketBasicData'
}
});