76 lines
1.6 KiB
JavaScript
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, sale) {
|
|
this.quicklinks = {
|
|
btnThree: {
|
|
icon: 'icon-transaction',
|
|
state: `item.card.diary({
|
|
id: ${sale.itemFk},
|
|
warehouseFk: ${this.ticket.warehouseFk},
|
|
lineFk: ${sale.id}
|
|
})`,
|
|
tooltip: 'Item diary'
|
|
}
|
|
};
|
|
this.$.descriptor.itemFk = sale.itemFk;
|
|
this.$.descriptor.parent = event.target;
|
|
this.$.descriptor.show();
|
|
}
|
|
|
|
onDescriptorLoad() {
|
|
this.$.popover.relocate();
|
|
}
|
|
}
|
|
|
|
ngModule.component('vnTicketVolume', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
ticket: '<'
|
|
}
|
|
});
|