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

105 lines
2.8 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() {
2022-09-26 06:07:45 +00:00
this.vnReport.show(`Routes/${this.id}/driver-route-pdf`, {
id: 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;
2022-09-26 06:07:45 +00:00
this.vnEmail.send(`Routes/${this.id}/driver-route-email`, {
2020-05-22 13:20:55 +00:00
recipient: workerUser.emailUser.email,
2022-09-26 06:07:45 +00:00
id: this.id
2020-05-22 13:20:55 +00:00
});
2022-09-13 11:34:32 +00:00
const params = {isOk: true};
return this.$http.patch(`Routes/${this.id}`, params);
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
});