salix/modules/travel/front/descriptor-menu/index.js

96 lines
2.5 KiB
JavaScript
Raw Normal View History

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',
2022-07-13 12:36:03 +00:00
'agencyModeFk',
2020-11-17 14:54:45 +00:00
'warehouseInFk',
'warehouseOutFk',
'cargoSupplierFk'
],
include: [
{
relation: 'warehouseIn',
scope: {
fields: ['name']
}
}, {
relation: 'warehouseOut',
scope: {
fields: ['name']
}
}
]
};
this.$http.get(`Travels/${this.travelId}`, {filter})
2020-11-17 14:54:45 +00:00
.then(res => this.travel = res.data);
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']);
}
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,
2022-07-13 12:36:03 +00:00
agencyModeFk: this.travel.agencyModeFk,
2020-11-16 18:04:37 +00:00
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
2024-06-07 06:32:59 +00:00
async redirectToCreateEntry() {
this.$state.go('home');
window.location.href = await this.vnApp.getUrl(`entry/create?travelFk=${this.travelId}`);
}
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
}
});