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

81 lines
2.1 KiB
JavaScript
Raw Normal View History

import ngModule from '../module';
import './style.scss';
class Controller {
constructor($scope, $stateParams) {
this.$stateParams = $stateParams;
this.$scope = $scope;
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.$scope.model.data;
let sum = 0;
if (!sales) return;
2018-11-06 09:49:38 +00:00
for (let sale of sales) {
for (let saleComponent of sale.components) {
if (saleComponent.component.componentType.isBase)
sum += sale.quantity * saleComponent.value;
2018-11-06 09:49:38 +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},
warehouseFk: ${this.ticket.warehouseFk},
ticketFk: ${this.ticket.id}
2018-09-04 09:49:00 +00:00
})`,
tooltip: 'Item diary'
}
};
2018-05-29 12:33:29 +00:00
this.$scope.descriptor.itemFk = itemFk;
this.$scope.descriptor.parent = event.target;
this.$scope.descriptor.show();
}
onDescriptorLoad() {
this.$scope.popover.relocate();
}
}
Controller.$inject = ['$scope', '$stateParams'];
ngModule.component('vnTicketComponents', {
template: require('./index.html'),
controller: Controller,
bindings: {
ticket: '<'
}
});