salix/modules/travel/front/card/index.js

59 lines
1.4 KiB
JavaScript

import ngModule from '../module';
export default class Controller {
constructor($stateParams, $http) {
this.$http = $http;
this.$stateParams = $stateParams;
this.travel = null;
this.filter = {
fields: [
'id',
'ref',
'warehouseInFk',
'warehouseOutFk',
'shipped',
'landed',
'totalEntries'
],
where: {id: $stateParams.id},
include: [
{
relation: 'warehouseIn',
scope: {
fields: ['id', 'name']
}
},
{
relation: 'warehouseOut',
scope: {
fields: ['id', 'name']
}
}
]
};
}
$onInit() {
this.getCard();
}
getCard() {
const params = {filter: this.filter};
this.$http.get(`/api/Travels/${this.$stateParams.id}`, {params}).then(response => {
this.travel = response.data;
});
}
reload() {
this.getCard();
}
}
Controller.$inject = ['$stateParams', '$http'];
ngModule.component('vnTravelCard', {
template: require('./index.html'),
controller: Controller
});