2023-01-23 12:15:30 +00:00
|
|
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
2019-04-10 07:45:45 +00:00
|
|
|
|
|
|
|
module.exports = {
|
2019-11-06 07:20:45 +00:00
|
|
|
name: 'driver-route',
|
2023-01-23 12:15:30 +00:00
|
|
|
mixins: [vnReport],
|
2019-11-04 12:55:20 +00:00
|
|
|
async serverPrefetch() {
|
2022-09-26 06:07:45 +00:00
|
|
|
let ids = this.id;
|
|
|
|
const hasMultipleRoutes = String(this.id).includes(',');
|
|
|
|
if (hasMultipleRoutes)
|
|
|
|
ids = this.id.split(',');
|
|
|
|
|
2024-01-31 11:33:52 +00:00
|
|
|
const routes = await this.rawSqlFromDef('routes', [ids]);
|
2023-01-23 12:15:30 +00:00
|
|
|
const tickets = await this.rawSqlFromDef('tickets', [ids, ids]);
|
2019-04-10 07:45:45 +00:00
|
|
|
|
2020-09-14 09:44:10 +00:00
|
|
|
const map = new Map();
|
2020-08-25 08:00:21 +00:00
|
|
|
|
2020-09-14 09:44:10 +00:00
|
|
|
for (let route of routes)
|
|
|
|
map.set(route.id, route);
|
|
|
|
|
|
|
|
for (let ticket of tickets) {
|
|
|
|
const route = map.get(ticket.routeFk);
|
|
|
|
if (!route.tickets) route.tickets = [];
|
|
|
|
route.tickets.push(ticket);
|
2020-08-25 08:00:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.routes = routes;
|
|
|
|
|
2023-01-23 12:15:30 +00:00
|
|
|
this.checkMainEntity(this.routes);
|
2019-04-10 07:45:45 +00:00
|
|
|
},
|
2019-11-04 12:55:20 +00:00
|
|
|
props: {
|
2022-09-26 06:07:45 +00:00
|
|
|
id: {
|
2024-01-31 11:50:32 +00:00
|
|
|
type: String,
|
2022-09-26 11:33:27 +00:00
|
|
|
required: true,
|
|
|
|
description: 'The route id'
|
2019-11-04 12:55:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-10 07:45:45 +00:00
|
|
|
};
|