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

106 lines
2.9 KiB
JavaScript
Raw Normal View History

2019-03-22 10:07:44 +00:00
import ngModule from '../module';
2020-04-25 09:50:04 +00:00
import Descriptor from 'salix/components/descriptor';
2020-04-25 09:50:04 +00:00
class Controller extends Descriptor {
get route() {
return this.entity;
2019-04-15 12:34:33 +00:00
}
set route(value) {
this.entity = value;
2019-04-15 12:34:33 +00:00
}
showRouteReport() {
this.showReport('driver-route', {
2020-03-16 11:32:26 +00:00
clientId: this.vnConfig.storage.currentUserWorkerId,
routeId: this.id
});
2019-04-15 12:34:33 +00:00
}
sendRouteReport() {
const params = {
recipient: user.emailUser.email,
2020-03-16 11:32:26 +00:00
clientId: this.vnConfig.storage.currentUserWorkerId,
routeId: this.id
};
return this.$http.get(`email/driver-route`, {params})
.then(() => this.vnApp.showSuccess(this.$t('Report sent')));
2019-04-15 12:34:33 +00:00
}
updateVolume() {
this.$http.post(`Routes/${this.id}/updateVolume`)
.then(() => {
if (this.cardReload) this.cardReload();
this.vnApp.showSuccess(this.$t('Volume updated'));
});
}
loadData() {
const filter = {
fields: [
'id',
'workerFk',
'agencyModeFk',
'created',
'm3',
'warehouseFk',
'description',
'vehicleFk',
'kmStart',
'kmEnd',
'started',
'finished',
'cost',
'zoneFk'
],
include: [
{
relation: 'agencyMode',
scope: {
fields: ['id', 'name']
}
}, {
relation: 'vehicle',
scope: {
fields: ['id', 'm3']
}
}, {
relation: 'zone',
scope: {
fields: ['id', 'name']
}
}, {
relation: 'worker',
scope: {
fields: ['userFk'],
include: {
relation: 'user',
scope: {
fields: ['id'],
include: {
relation: 'emailUser',
scope: {
fields: ['email']
}
}
}
}
}
}
]
};
return this.getData(`Routes/${this.id}`, {filter})
.then(res => this.entity = res.data);
}
2019-03-22 10:07:44 +00:00
}
2020-04-25 09:50:04 +00:00
ngModule.vnComponent('vnRouteDescriptor', {
2019-03-22 10:07:44 +00:00
template: require('./index.html'),
2020-04-25 09:50:04 +00:00
controller: Controller,
2019-03-22 10:07:44 +00:00
bindings: {
route: '<',
2020-04-25 09:50:04 +00:00
cardReload: '&?'
}
2019-03-22 10:07:44 +00:00
});