50 lines
1.1 KiB
JavaScript
50 lines
1.1 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();
|
|
}
|
|
|
|
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: '<'
|
|
}
|
|
});
|