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',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
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-08-31 05:53:38 +00:00
|
|
|
|
2018-04-13 14:03:43 +00:00
|
|
|
return sum;
|
|
|
|
}
|
2018-05-29 12:33:29 +00:00
|
|
|
|
|
|
|
showDescriptor(event, itemFk) {
|
2018-09-04 09:49:00 +00:00
|
|
|
this.quicklinks = {
|
|
|
|
btnThree: {
|
|
|
|
icon: 'icon-transaction',
|
|
|
|
state: `item.card.diary({
|
|
|
|
id: ${itemFk},
|
2018-10-05 12:03:59 +00:00
|
|
|
warehouseFk: ${this.ticket.warehouseFk},
|
|
|
|
ticketFk: ${this.ticket.id}
|
2018-09-04 09:49:00 +00:00
|
|
|
})`,
|
|
|
|
tooltip: 'Item diary'
|
|
|
|
}
|
|
|
|
};
|
2020-03-18 07:35:59 +00:00
|
|
|
this.$.descriptor.itemFk = itemFk;
|
|
|
|
this.$.descriptor.parent = event.target;
|
|
|
|
this.$.descriptor.show();
|
2018-05-29 12:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onDescriptorLoad() {
|
2020-03-18 07:35:59 +00:00
|
|
|
this.$.popover.relocate();
|
2018-05-29 12:33:29 +00:00
|
|
|
}
|
2018-04-13 14:03:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.component('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: '<'
|
|
|
|
}
|
|
|
|
});
|