salix/print/templates/reports/zone/zone.js

31 lines
793 B
JavaScript
Executable File

const db = require(`${appPath}/core/database`);
module.exports = {
name: 'zone',
async serverPrefetch() {
this.zone = await this.fetchZone(this.routeId);
if (!this.zone)
throw new Error('Something went wrong');
},
methods: {
fetchZone(routeId) {
return db.findOne(
`SELECT
r.id,
r.time,
am.name agencyName,
v.numberPlate plateNumber
FROM route r
JOIN agencyMode am ON am.id = r.agencyModeFk
JOIN vehicle v ON v.id = r.vehicleFk
WHERE r.id = :routeId`, {routeId});
}
},
props: {
routeId: {
required: true
}
}
};