51 lines
1.2 KiB
JavaScript
51 lines
1.2 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'
|
|
},
|
|
order: 'concept'
|
|
};
|
|
|
|
this.ticketVolumes = [];
|
|
}
|
|
|
|
get sales() {
|
|
return this._sales;
|
|
}
|
|
|
|
set sales(value) {
|
|
this._sales = value;
|
|
|
|
if (value && value.length) this.applyVolumes();
|
|
}
|
|
|
|
applyVolumes() {
|
|
const ticket = this.sales[0].ticketFk;
|
|
this.$http.get(`Tickets/${ticket}/getVolume`).then(res => {
|
|
const saleVolume = res.data.saleVolume;
|
|
|
|
const volumes = new Map();
|
|
for (const volume of saleVolume)
|
|
volumes.set(volume.saleFk, volume);
|
|
|
|
for (const sale of this.sales)
|
|
sale.saleVolume = volumes.get(sale.id);
|
|
|
|
this.packingTypeVolume = res.data.packingTypeVolume;
|
|
});
|
|
}
|
|
}
|
|
|
|
ngModule.vnComponent('vnTicketVolume', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
ticket: '<'
|
|
}
|
|
});
|