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-03-05 12:56:45 +00:00
|
|
|
|
2020-04-25 09:50:04 +00:00
|
|
|
class Controller extends Descriptor {
|
2020-04-30 10:48:52 +00:00
|
|
|
get route() {
|
|
|
|
return this.entity;
|
2019-04-15 12:34:33 +00:00
|
|
|
}
|
2019-06-05 11:51:34 +00:00
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
set route(value) {
|
|
|
|
this.entity = value;
|
2019-04-15 12:34:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
showRouteReport() {
|
2020-06-12 12:28:29 +00:00
|
|
|
this.vnReport.show('driver-route', {
|
2020-04-30 10:48:52 +00:00
|
|
|
routeId: this.id
|
|
|
|
});
|
2019-04-15 12:34:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sendRouteReport() {
|
2020-05-22 13:20:55 +00:00
|
|
|
const workerUser = this.route.worker.user;
|
2020-06-12 12:28:29 +00:00
|
|
|
this.vnEmail.send('driver-route', {
|
2020-05-22 13:20:55 +00:00
|
|
|
recipient: workerUser.emailUser.email,
|
2020-04-30 10:48:52 +00:00
|
|
|
routeId: this.id
|
2020-05-22 13:20:55 +00:00
|
|
|
});
|
2019-04-15 12:34:33 +00:00
|
|
|
}
|
2019-06-05 11:51:34 +00:00
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
updateVolume() {
|
|
|
|
this.$http.post(`Routes/${this.id}/updateVolume`)
|
|
|
|
.then(() => {
|
|
|
|
if (this.cardReload) this.cardReload();
|
|
|
|
this.vnApp.showSuccess(this.$t('Volume updated'));
|
|
|
|
});
|
2019-06-05 11:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
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-06-05 11:51:34 +00:00
|
|
|
}
|
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
|
|
|
});
|