2018-04-13 14:03:43 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-18 07:35:59 +00:00
|
|
|
import Section from 'salix/components/section';
|
2018-04-13 14:03:43 +00:00
|
|
|
import './style.scss';
|
2018-05-10 11:36:26 +00:00
|
|
|
|
2020-03-18 07:35:59 +00:00
|
|
|
class Controller extends Section {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
2018-08-31 05:53:38 +00:00
|
|
|
this.filter = {
|
|
|
|
order: 'concept ASC',
|
|
|
|
include: [{
|
|
|
|
relation: 'item',
|
2020-04-28 12:26:02 +00:00
|
|
|
}, {
|
2018-08-31 05:53:38 +00:00
|
|
|
relation: 'components',
|
|
|
|
scope: {
|
|
|
|
fields: ['componentFk', 'value'],
|
|
|
|
include: {
|
2019-12-27 07:01:53 +00:00
|
|
|
relation: 'component',
|
2018-08-31 05:53:38 +00:00
|
|
|
scope: {
|
2019-09-24 11:45:54 +00:00
|
|
|
fields: ['typeFk', 'name'],
|
2018-08-31 05:53:38 +00:00
|
|
|
include: {
|
|
|
|
relation: 'componentType',
|
|
|
|
scope: {
|
2019-04-02 06:00:16 +00:00
|
|
|
fields: ['type', 'isBase']
|
2018-08-31 05:53:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
};
|
2018-05-10 11:36:26 +00:00
|
|
|
}
|
2020-07-16 05:43:07 +00:00
|
|
|
get ticket() {
|
|
|
|
return this._ticket;
|
|
|
|
}
|
|
|
|
|
|
|
|
set ticket(value) {
|
|
|
|
this._ticket = value;
|
|
|
|
|
|
|
|
if (!value) return;
|
2020-09-09 13:49:59 +00:00
|
|
|
this.getTheoricalCost();
|
2020-07-21 09:11:09 +00:00
|
|
|
this.getComponentsSum();
|
2020-12-03 09:26:49 +00:00
|
|
|
if (this.ticket.zone && this.ticket.zone.isVolumetric)
|
2020-10-29 10:09:58 +00:00
|
|
|
this.getTicketVolume();
|
2020-07-16 05:43:07 +00:00
|
|
|
}
|
2018-04-13 14:03:43 +00:00
|
|
|
|
|
|
|
base() {
|
2020-03-18 07:35:59 +00:00
|
|
|
let sales = this.$.model.data;
|
2018-08-31 05:53:38 +00:00
|
|
|
let sum = 0;
|
|
|
|
if (!sales) return;
|
|
|
|
|
2018-11-06 09:49:38 +00:00
|
|
|
for (let sale of sales) {
|
2019-12-27 07:01:53 +00:00
|
|
|
for (let saleComponent of sale.components) {
|
|
|
|
if (saleComponent.component.componentType.isBase)
|
|
|
|
sum += sale.quantity * saleComponent.value;
|
2018-11-06 09:49:38 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-13 14:03:43 +00:00
|
|
|
return sum;
|
|
|
|
}
|
2020-07-16 05:43:07 +00:00
|
|
|
|
|
|
|
getTotal() {
|
2020-09-09 13:49:59 +00:00
|
|
|
const sales = this.$.model.data;
|
2020-07-16 05:43:07 +00:00
|
|
|
let total = 0;
|
|
|
|
if (!sales) return;
|
|
|
|
for (let sale of sales) {
|
|
|
|
for (let saleComponent of sale.components)
|
|
|
|
total += sale.quantity * saleComponent.value;
|
|
|
|
}
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
2020-09-09 13:49:59 +00:00
|
|
|
getTheoricalCost() {
|
|
|
|
this.$http.get(`Tickets/${this.ticket.id}/freightCost`)
|
|
|
|
.then(res => this.theoricalCost = res.data);
|
2020-07-21 09:11:09 +00:00
|
|
|
}
|
2020-07-16 05:43:07 +00:00
|
|
|
|
2020-07-21 09:11:09 +00:00
|
|
|
getComponentsSum() {
|
|
|
|
this.$http.get(`Tickets/${this.ticket.id}/getComponentsSum`)
|
|
|
|
.then(res => this.componentsList = res.data);
|
2020-07-16 05:43:07 +00:00
|
|
|
}
|
2020-10-29 10:09:58 +00:00
|
|
|
|
|
|
|
getTicketVolume() {
|
|
|
|
if (!this.ticket) return;
|
|
|
|
|
|
|
|
this.$http.get(`Tickets/${this.ticket.id}/getVolume`)
|
2021-07-27 14:17:47 +00:00
|
|
|
.then(res => {
|
|
|
|
if (res.data.length)
|
|
|
|
this.ticketVolume = res.data[0].volume;
|
|
|
|
});
|
2020-10-29 10:09:58 +00:00
|
|
|
}
|
2018-04-13 14:03:43 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnTicketComponents', {
|
2018-05-25 08:03:45 +00:00
|
|
|
template: require('./index.html'),
|
2018-04-13 14:03:43 +00:00
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
ticket: '<'
|
|
|
|
}
|
|
|
|
});
|