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

76 lines
1.6 KiB
JavaScript

import ngModule from '../module';
import Section from 'salix/components/section';
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.filter = {
include: [{
relation: 'item'
}]
};
this.ticketVolumes = [];
}
get sales() {
return this._sales;
}
set sales(value) {
this._sales = value;
if (value) this.applyVolumes();
}
get volumes() {
return this._volumes;
}
set volumes(value) {
this._volumes = value;
if (value) this.applyVolumes();
}
applyVolumes() {
if (!this.sales || !this.volumes) return;
this.sales.forEach(sale => {
this.volumes.forEach(volume => {
if (sale.id === volume.saleFk)
sale.volume = volume;
});
});
}
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('vnTicketVolume', {
template: require('./index.html'),
controller: Controller,
bindings: {
ticket: '<'
}
});