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

72 lines
1.7 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',
'workerFk',
'agencyModeFk',
'created',
'm3',
'warehouseFk',
'description',
'vehicleFk',
'kmStart',
'kmEnd',
'started',
'finished',
'cost',
'zoneFk'
],
where: {id: $stateParams.id},
include: [
{
relation: 'agencyMode',
scope: {
fields: ['id', 'name']
}
},
{
relation: 'vehicle',
scope: {
fields: ['id', 'm3']
}
},
{
relation: 'zone',
scope: {
fields: ['id', 'name']
}
}
]
};
}
$onInit() {
this.getCard();
}
getCard() {
let json = encodeURIComponent(JSON.stringify(this.filter));
this.$http.get(`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
});