2020-11-16 18:04:37 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import Section from 'salix/components/section';
|
|
|
|
import './style.scss';
|
|
|
|
|
|
|
|
class Controller extends Section {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
|
|
|
}
|
|
|
|
|
2020-11-17 14:54:45 +00:00
|
|
|
get travelId() {
|
|
|
|
return this._travelId;
|
|
|
|
}
|
|
|
|
|
|
|
|
set travelId(value) {
|
|
|
|
this._travelId = value;
|
|
|
|
|
|
|
|
if (value) this.loadData();
|
|
|
|
}
|
|
|
|
|
|
|
|
loadData() {
|
|
|
|
const filter = {
|
|
|
|
fields: [
|
|
|
|
'id',
|
|
|
|
'ref',
|
|
|
|
'shipped',
|
|
|
|
'landed',
|
|
|
|
'totalEntries',
|
|
|
|
'agencyFk',
|
|
|
|
'warehouseInFk',
|
|
|
|
'warehouseOutFk',
|
|
|
|
'cargoSupplierFk'
|
|
|
|
],
|
|
|
|
include: [
|
|
|
|
{
|
|
|
|
relation: 'warehouseIn',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
relation: 'warehouseOut',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
2021-06-15 14:41:01 +00:00
|
|
|
this.$http.get(`Travels/${this.travelId}`, {filter})
|
2020-11-17 14:54:45 +00:00
|
|
|
.then(res => this.travel = res.data);
|
2021-06-15 14:41:01 +00:00
|
|
|
|
|
|
|
this.$http.get(`Travels/${this.travelId}/getEntries`)
|
|
|
|
.then(res => this.entries = res.data);
|
2020-11-17 14:54:45 +00:00
|
|
|
}
|
|
|
|
|
2020-12-29 06:52:36 +00:00
|
|
|
get isBuyer() {
|
|
|
|
return this.aclService.hasAny(['buyer']);
|
|
|
|
}
|
|
|
|
|
2021-06-15 14:41:01 +00:00
|
|
|
onDeleteAccept() {
|
|
|
|
this.$http.delete(`Travels/${this.travelId}`)
|
|
|
|
.then(() => this.$state.go('travel.index'))
|
|
|
|
.then(() => this.vnApp.showSuccess(this.$t('Travel deleted')));
|
|
|
|
}
|
|
|
|
|
2020-11-16 18:04:37 +00:00
|
|
|
onCloneAccept() {
|
|
|
|
const params = JSON.stringify({
|
|
|
|
ref: this.travel.ref,
|
|
|
|
agencyModeFk: this.travel.agencyFk,
|
|
|
|
shipped: this.travel.shipped,
|
|
|
|
landed: this.travel.landed,
|
|
|
|
warehouseInFk: this.travel.warehouseInFk,
|
|
|
|
warehouseOutFk: this.travel.warehouseOutFk
|
|
|
|
});
|
|
|
|
this.$state.go('travel.create', {q: params});
|
|
|
|
}
|
2020-12-28 13:53:26 +00:00
|
|
|
|
|
|
|
onCloneWithEntriesAccept() {
|
|
|
|
this.$http.post(`Travels/${this.travelId}/cloneWithEntries`)
|
|
|
|
.then(res => this.$state.go('travel.card.basicData', {id: res.data}));
|
|
|
|
}
|
2020-11-16 18:04:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Controller.$inject = ['$element', '$scope'];
|
|
|
|
|
|
|
|
ngModule.vnComponent('vnTravelDescriptorMenu', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
2020-11-17 14:54:45 +00:00
|
|
|
travelId: '<',
|
2020-11-16 18:04:37 +00:00
|
|
|
}
|
|
|
|
});
|