2018-04-13 14:03:43 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import './style.scss';
|
2018-05-10 11:36:26 +00:00
|
|
|
|
2018-08-31 05:53:38 +00:00
|
|
|
class Controller {
|
|
|
|
constructor($scope, $stateParams) {
|
|
|
|
this.$stateParams = $stateParams;
|
2018-05-10 11:36:26 +00:00
|
|
|
this.$scope = $scope;
|
2018-08-31 05:53:38 +00:00
|
|
|
this.filter = {
|
|
|
|
order: 'concept ASC',
|
|
|
|
include: [{
|
|
|
|
relation: 'item',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'components',
|
|
|
|
scope: {
|
|
|
|
fields: ['componentFk', 'value'],
|
|
|
|
include: {
|
|
|
|
relation: 'componentRate',
|
|
|
|
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() {
|
2018-08-31 05:53:38 +00:00
|
|
|
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 component of sale.components) {
|
2019-04-02 06:00:16 +00:00
|
|
|
if (component.componentRate.componentType.isBase)
|
2018-08-31 05:53:38 +00:00
|
|
|
sum += sale.quantity * component.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'
|
|
|
|
}
|
|
|
|
};
|
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();
|
|
|
|
}
|
2018-04-13 14:03:43 +00:00
|
|
|
}
|
|
|
|
|
2018-08-31 05:53:38 +00:00
|
|
|
Controller.$inject = ['$scope', '$stateParams'];
|
2018-05-10 11:36:26 +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: '<'
|
|
|
|
}
|
|
|
|
});
|