38 lines
982 B
JavaScript
Executable File
38 lines
982 B
JavaScript
Executable File
const vnReport = require('../../../core/mixins/vn-report.js');
|
|
|
|
module.exports = {
|
|
name: 'driver-route',
|
|
mixins: [vnReport],
|
|
async serverPrefetch() {
|
|
let ids = this.id;
|
|
const hasMultipleRoutes = String(this.id).includes(',');
|
|
if (hasMultipleRoutes)
|
|
ids = this.id.split(',');
|
|
|
|
const routes = await this.rawSqlFromDef('routes', [ids]);
|
|
const tickets = await this.rawSqlFromDef('tickets', [ids, ids]);
|
|
|
|
const map = new Map();
|
|
|
|
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);
|
|
}
|
|
|
|
this.routes = routes;
|
|
|
|
this.checkMainEntity(this.routes);
|
|
},
|
|
props: {
|
|
id: {
|
|
type: String,
|
|
required: true,
|
|
description: 'The route id'
|
|
}
|
|
}
|
|
};
|