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

65 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-03-22 10:07:44 +00:00
import ngModule from '../module';
export default class Controller {
constructor($stateParams, $http) {
this.$http = $http;
this.$stateParams = $stateParams;
this.route = null;
this.filter = {
2019-03-23 15:16:47 +00:00
fields: [
'id',
'workerFk',
'agencyModeFk',
'created',
'm3',
'warehouseFk',
'description',
'vehicleFk',
'kmStart',
'kmEnd',
'started',
'finished',
'cost'
],
2019-03-22 10:07:44 +00:00
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
});