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

50 lines
1.2 KiB
JavaScript

import ngModule from '../module';
export default class Controller {
constructor($stateParams, $http) {
this.$http = $http;
this.$stateParams = $stateParams;
this.route = null;
this.filter = {
fields: ['id', 'agencyModeFk', 'created', 'm3', 'warehouseFk', 'description', 'vehicleFk'],
where: {id: $stateParams.id},
include: [
{
relation: 'agencyMode',
scope: {
fields: ['id', 'name']
}
},
{
relation: 'vehicle',
scope: {
fields: ['id', 'm3']
}
}
]
};
}
$onInit() {
this.getCard();
}
getCard() {
let json = encodeURIComponent(JSON.stringify(this.filter));
this.$http.get(`/client/api/Routes?filter=${json}`).then(response => {
this.route = response.data[0];
});
}
reload() {
this.getCard();
}
}
Controller.$inject = ['$stateParams', '$http'];
ngModule.component('vnRouteCard', {
template: require('./index.html'),
controller: Controller
});