Download route PDF on route index
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b2886bdca8
commit
cd74e9684a
|
@ -8,6 +8,11 @@
|
|||
<vn-table model="model">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th shrink>
|
||||
<vn-multi-check
|
||||
model="model">
|
||||
</vn-multi-check>
|
||||
</vn-th>
|
||||
<vn-th field="id" number>Id</vn-th>
|
||||
<vn-th th-id="worker">Worker</vn-th>
|
||||
<vn-th th-id="agency">Agency</vn-th>
|
||||
|
@ -22,6 +27,12 @@
|
|||
<a ng-repeat="route in model.data"
|
||||
class="clickable vn-tr search-result"
|
||||
ui-sref="route.card.summary({id: {{::route.id}}})">
|
||||
<vn-td shrink>
|
||||
<vn-check
|
||||
ng-model="route.checked"
|
||||
vn-click-stop>
|
||||
</vn-check>
|
||||
</vn-td>
|
||||
<vn-td number>{{::route.id | dashIfEmpty}}</vn-td>
|
||||
<vn-td expand>
|
||||
<span
|
||||
|
@ -55,9 +66,26 @@
|
|||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
<a ui-sref="route.create"
|
||||
vn-tooltip="New route"
|
||||
|
||||
|
||||
</vn-data-viewer>
|
||||
<div fixed-bottom-right>
|
||||
<vn-vertical style="align-items: center;">
|
||||
<vn-button class="round sm vn-mb-sm"
|
||||
icon="cloud_download"
|
||||
ng-show="$ctrl.totalChecked > 0"
|
||||
ng-click="$ctrl.showRouteReport()"
|
||||
vn-tooltip="Download selected routes as PDF"
|
||||
tooltip-position="left">
|
||||
</vn-button>
|
||||
|
||||
<a ui-sref="route.create">
|
||||
<vn-button class="round md vn-mb-sm"
|
||||
icon="add"
|
||||
vn-bind="+"
|
||||
fixed-bottom-right>
|
||||
<vn-float-button icon="add"></vn-float-button>
|
||||
</a>
|
||||
vn-tooltip="New route"
|
||||
tooltip-position="left">
|
||||
</vn-button>
|
||||
</a>
|
||||
</vn-vertical>
|
||||
</div>
|
|
@ -2,12 +2,46 @@ import ngModule from '../module';
|
|||
import Section from 'salix/components/section';
|
||||
|
||||
export default class Controller extends Section {
|
||||
constructor($element, $, vnReport) {
|
||||
super($element, $);
|
||||
this.vnReport = vnReport;
|
||||
}
|
||||
|
||||
preview(route) {
|
||||
this.routeSelected = route;
|
||||
this.$.summary.show();
|
||||
}
|
||||
|
||||
get checked() {
|
||||
const rows = this.$.model.data || [];
|
||||
const checkedRows = [];
|
||||
for (let row of rows) {
|
||||
if (row.checked)
|
||||
checkedRows.push(row);
|
||||
}
|
||||
|
||||
return checkedRows;
|
||||
}
|
||||
|
||||
get totalChecked() {
|
||||
return this.checked.length;
|
||||
}
|
||||
|
||||
showRouteReport() {
|
||||
const routes = [];
|
||||
for (let route of this.checked)
|
||||
routes.push(route.id);
|
||||
const routesId = routes.join(',');
|
||||
|
||||
this.vnReport.show('driver-route', {
|
||||
authorization: this.vnToken.token,
|
||||
routeId: routesId
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$element', '$scope', 'vnReport'];
|
||||
|
||||
ngModule.vnComponent('vnRouteIndex', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
Vehicle: Vehículo
|
||||
Download selected routes as PDF: Descargar rutas seleccionadas como PDF
|
|
@ -24,8 +24,9 @@ p.privacy {
|
|||
text-align: center
|
||||
}
|
||||
|
||||
.page .pageCount {
|
||||
text-align: right
|
||||
.pageCount {
|
||||
text-align: right;
|
||||
float: right
|
||||
}
|
||||
|
||||
.footer .page > div {
|
||||
|
|
|
@ -33,6 +33,7 @@ class Report extends Component {
|
|||
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
||||
});
|
||||
const page = await browser.newPage();
|
||||
await page.emulateMedia('screen');
|
||||
await page.setContent(template);
|
||||
|
||||
const element = await page.$('#pageFooter');
|
||||
|
|
|
@ -47,3 +47,8 @@ section.text-area {
|
|||
padding-right: 1em;
|
||||
background-color: #e5e5e5;
|
||||
}
|
||||
|
||||
.route-block {
|
||||
margin-bottom: 100px;
|
||||
page-break-after: always;
|
||||
}
|
|
@ -8,9 +8,9 @@
|
|||
<!-- Header block -->
|
||||
<report-header v-bind="$props"></report-header>
|
||||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-row route-block" v-for="route in routes">
|
||||
<div class="grid-block">
|
||||
<h1 class="title uppercase">{{route.id}}</h1>
|
||||
<h1 class="title uppercase">{{$t('route')}} {{route.id}}</h1>
|
||||
<div class="panel">
|
||||
<div class="header">{{$t('information')}}</div>
|
||||
<div class="body">
|
||||
|
@ -80,7 +80,8 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="no-page-break" v-for="ticket in tickets">
|
||||
<!-- Route ticket list -->
|
||||
<div class="no-page-break" v-for="ticket in route.tickets">
|
||||
<div>
|
||||
<table class="column-oriented repeatable">
|
||||
<thead>
|
||||
|
@ -151,7 +152,7 @@
|
|||
</div>
|
||||
<!-- Footer block -->
|
||||
<report-footer id="pageFooter"
|
||||
v-bind:left-text="$t('routeId', [route.id])"
|
||||
v-bind:left-text="$t('routeId', [routeId])"
|
||||
v-bind="$props">
|
||||
</report-footer>
|
||||
</td>
|
||||
|
|
|
@ -6,15 +6,27 @@ const reportFooter = new Component('report-footer');
|
|||
module.exports = {
|
||||
name: 'driver-route',
|
||||
async serverPrefetch() {
|
||||
this.route = await this.fetchRoute(this.routeId);
|
||||
this.tickets = await this.fetchTickets(this.routeId);
|
||||
const routesId = this.routeId.split(',');
|
||||
const routes = await this.fetchRoutes(routesId);
|
||||
const tickets = await this.fetchTickets(routesId);
|
||||
console.log(tickets);
|
||||
|
||||
if (!this.route)
|
||||
for (let route of routes) {
|
||||
const routeTickets = tickets.filter(ticket => {
|
||||
return ticket.routeFk == route.id;
|
||||
});
|
||||
|
||||
route.tickets = routeTickets;
|
||||
}
|
||||
|
||||
this.routes = routes;
|
||||
|
||||
if (!this.routes)
|
||||
throw new Error('Something went wrong');
|
||||
},
|
||||
methods: {
|
||||
fetchRoute(id) {
|
||||
return db.findOne(
|
||||
fetchRoutes(routesId) {
|
||||
return db.rawSql(
|
||||
`SELECT
|
||||
r.id,
|
||||
r.m3,
|
||||
|
@ -30,9 +42,9 @@ module.exports = {
|
|||
LEFT JOIN worker w ON w.id = r.workerFk
|
||||
LEFT JOIN account.user u ON u.id = w.userFk
|
||||
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
|
||||
WHERE r.id = :routeId`, {routeId: id});
|
||||
WHERE r.id IN(:routesId)`, {routesId});
|
||||
},
|
||||
fetchTickets(routeId) {
|
||||
fetchTickets(routesId) {
|
||||
return db.rawSql(
|
||||
`SELECT
|
||||
t.nickname addressName,
|
||||
|
@ -41,6 +53,7 @@ module.exports = {
|
|||
t.id,
|
||||
t.clientFk,
|
||||
t.companyFk,
|
||||
t.routeFk,
|
||||
if(a.phone, a.phone, c.phone) AS phone,
|
||||
if(a.mobile, a.mobile, c.mobile) AS mobile,
|
||||
wh.name warehouseName,
|
||||
|
@ -65,8 +78,8 @@ module.exports = {
|
|||
LEFT JOIN warehouse wh ON wh.id = t.warehouseFk
|
||||
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
LEFT JOIN stowaway s ON s.id = t.id
|
||||
WHERE r.id = ?
|
||||
ORDER BY t.priority, t.id`, [routeId]);
|
||||
WHERE r.id IN(:routesId)
|
||||
ORDER BY t.priority, t.id`, {routesId});
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
|
Loading…
Reference in New Issue