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

72 lines
1.7 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',
2019-10-16 05:18:05 +00:00
'cost',
'zoneFk'
2019-03-23 15:16:47 +00:00
],
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']
}
2019-10-16 05:18:05 +00:00
},
{
relation: 'zone',
scope: {
fields: ['id', 'name']
}
2019-03-22 10:07:44 +00:00
}
]
};
}
$onInit() {
this.getCard();
}
getCard() {
let json = encodeURIComponent(JSON.stringify(this.filter));
this.$http.get(`Routes?filter=${json}`).then(response => {
2019-03-22 10:07:44 +00:00
this.route = response.data[0];
});
}
reload() {
this.getCard();
}
}
Controller.$inject = ['$stateParams', '$http'];
ngModule.component('vnRouteCard', {
template: require('./index.html'),
controller: Controller
});