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;
|
|
|
|
this.getTheoricalPorts();
|
2020-07-21 09:11:09 +00:00
|
|
|
this.getComponentsSum();
|
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() {
|
|
|
|
let sales = this.$.model.data;
|
|
|
|
let total = 0;
|
|
|
|
if (!sales) return;
|
|
|
|
for (let sale of sales) {
|
|
|
|
for (let saleComponent of sale.components)
|
|
|
|
total += sale.quantity * saleComponent.value;
|
|
|
|
}
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
|
|
|
getTheoricalPorts() {
|
|
|
|
this.$http.get(`Tickets/${this.ticket.id}/freightPorts`)
|
|
|
|
.then(res => this.theoricalPorts = 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
|
|
|
}
|
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: '<'
|
|
|
|
}
|
|
|
|
});
|