59 lines
1.4 KiB
JavaScript
59 lines
1.4 KiB
JavaScript
|
import ngModule from '../module';
|
||
|
import './style.scss';
|
||
|
|
||
|
class Controller {
|
||
|
constructor($scope, $http) {
|
||
|
this.$http = $http;
|
||
|
this.$ = $scope;
|
||
|
}
|
||
|
|
||
|
set route(value) {
|
||
|
this._route = value;
|
||
|
if (value && value.id)
|
||
|
this.getSummary();
|
||
|
}
|
||
|
|
||
|
sumPackages() {
|
||
|
this.packagesTotal = 0;
|
||
|
this.summary.route.ticket.forEach(ticket => {
|
||
|
this.packagesTotal += ticket.packages;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
showTicketDescriptor(event, ticketFk) {
|
||
|
this.$.ticketDescriptor.ticketFk = ticketFk;
|
||
|
this.$.ticketDescriptor.parent = event.target;
|
||
|
this.$.ticketDescriptor.show();
|
||
|
event.preventDefault();
|
||
|
}
|
||
|
|
||
|
showClientDescriptor(event, clientFk) {
|
||
|
this.$.clientDescriptor.clientFk = clientFk;
|
||
|
this.$.clientDescriptor.parent = event.target;
|
||
|
this.$.clientDescriptor.show();
|
||
|
event.preventDefault();
|
||
|
}
|
||
|
|
||
|
get route() {
|
||
|
return this._route;
|
||
|
}
|
||
|
|
||
|
getSummary() {
|
||
|
this.$http.get(`/api/Routes/${this.route.id}/summary`).then(response => {
|
||
|
this.summary = response.data;
|
||
|
if (response.data && response.data.route && response.data.route.ticket)
|
||
|
this.sumPackages();
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Controller.$inject = ['$scope', '$http'];
|
||
|
|
||
|
ngModule.component('vnRouteSummary', {
|
||
|
template: require('./index.html'),
|
||
|
controller: Controller,
|
||
|
bindings: {
|
||
|
route: '<'
|
||
|
}
|
||
|
});
|