salix/modules/ticket/front/component/index.js

79 lines
2.1 KiB
JavaScript

import ngModule from '../module';
import Section from 'salix/components/section';
import './style.scss';
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.filter = {
order: 'concept ASC',
include: [{
relation: 'item',
},
{
relation: 'components',
scope: {
fields: ['componentFk', 'value'],
include: {
relation: 'component',
scope: {
fields: ['typeFk', 'name'],
include: {
relation: 'componentType',
scope: {
fields: ['type', 'isBase']
}
}
}
}
}
}]
};
}
base() {
let sales = this.$.model.data;
let sum = 0;
if (!sales) return;
for (let sale of sales) {
for (let saleComponent of sale.components) {
if (saleComponent.component.componentType.isBase)
sum += sale.quantity * saleComponent.value;
}
}
return sum;
}
showDescriptor(event, itemFk) {
this.quicklinks = {
btnThree: {
icon: 'icon-transaction',
state: `item.card.diary({
id: ${itemFk},
warehouseFk: ${this.ticket.warehouseFk},
ticketFk: ${this.ticket.id}
})`,
tooltip: 'Item diary'
}
};
this.$.descriptor.itemFk = itemFk;
this.$.descriptor.parent = event.target;
this.$.descriptor.show();
}
onDescriptorLoad() {
this.$.popover.relocate();
}
}
ngModule.component('vnTicketComponents', {
template: require('./index.html'),
controller: Controller,
bindings: {
ticket: '<'
}
});