feat: refs #6401 Added QR and CIF in the CMR report #2111
|
@ -3,7 +3,7 @@ html {
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
font-size: 22px;
|
font-size: 22px;
|
||||||
}
|
}
|
||||||
.mainTable, .specialTable, .categoryTable {
|
.mainTable, .specialTable, .categoryTable, .observationTable {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
|
@ -98,4 +98,19 @@ img {
|
||||||
#merchandiseLabels td {
|
#merchandiseLabels td {
|
||||||
padding-bottom: 11px;
|
padding-bottom: 11px;
|
||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.observationTable tr td {
|
||||||
|
border: none;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#qrSection {
|
||||||
|
text-align: center;
|
||||||
|
width: 30%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#truckPlateQr {
|
||||||
|
width: 125px;
|
||||||
|
margin-bottom: 10px;
|
||||||
}
|
}
|
|
@ -30,8 +30,11 @@
|
||||||
<span id="label">16. Transportista / Transporteur / Carrier</span>
|
<span id="label">16. Transportista / Transporteur / Carrier</span>
|
||||||
<hr>
|
<hr>
|
||||||
<b>{{data.carrierName}}</b><br>
|
<b>{{data.carrierName}}</b><br>
|
||||||
{{data.carrierStreet}}<br>
|
{{data.carrierStreet}} {{data.carrierPostalCode}}
|
||||||
{{data.carrierPostalCode}} {{data.carrierCity}} {{(data.carrierCountry) ? `(${data.carrierCountry})` : null}}
|
{{data.carrierCity}} {{(data.carrierCountry)
|
||||||
guillermo marked this conversation as resolved
|
|||||||
|
? `(${data.carrierCountry})`
|
||||||
|
: null}}<br>
|
||||||
|
<b>CIF:</b> {{data.carrierCif}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -71,8 +74,19 @@
|
||||||
Carrier's reservations and observations
|
Carrier's reservations and observations
|
||||||
</span>
|
</span>
|
||||||
<hr>
|
<hr>
|
||||||
<b>{{data.truckPlate}}</b><br>
|
<table class="observationTable">
|
||||||
{{data.observations}}
|
<tr>
|
||||||
|
<td>
|
||||||
|
{{data.observations}}
|
||||||
|
</td>
|
||||||
|
<td id="qrSection">
|
||||||
|
<img id="truckPlateQr" v-bind:src="truckPlateQr"/>
|
||||||
|
<br>
|
||||||
guillermo marked this conversation as resolved
alexm
commented
Crec que es mala practica gastar els Per exemple, jo habria fet que el fora flex column i ja teu fica en una columna. i si volvera separacio ficaria margin fora sols un element o gap si foren varios. Pero teu dic per a un futur Crec que es mala practica gastar els <br> de esta manera.
En teoria soles se deuen gastar per a separar parrafos en un <p> per exemple (https://desarrolloweb-apuntes.blogspot.com/2017/11/errores-o-malas-practicas-en-html.html#:~:text=El%20elemento%20no%20se,decir%2C%20como%20dos%20p%C3%A1rrafos%20independientes.)
Per exemple, jo habria fet que el <td> fora flex column i ja teu fica en una columna. i si volvera separacio ficaria margin fora sols un element o gap si foren varios.
Pero teu dic per a un futur
|
|||||||
|
<b>{{data.truckPlate}}</b>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -2,44 +2,53 @@ const config = require(`vn-print/core/config`);
|
||||||
const vnReport = require('../../../core/mixins/vn-report.js');
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
||||||
const md5 = require('md5');
|
const md5 = require('md5');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
|
const qrcode = require('qrcode');
|
||||||
|
|
||||||
const prefixBase64 = 'data:image/png;base64,';
|
const prefixBase64 = 'data:image/png;base64,';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'cmr',
|
name: 'cmr',
|
||||||
mixins: [vnReport],
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.data = await this.findOneFromDef('data', [this.id]);
|
this.data = await this.findOneFromDef('data', [this.id]);
|
||||||
if (this.data.ticketFk) {
|
if (this.data.ticketFk) {
|
||||||
this.merchandises = await this.rawSqlFromDef('merchandise', [this.data.ticketFk]);
|
this.merchandises = await this.rawSqlFromDef('merchandise', [this.data.ticketFk]);
|
||||||
this.signature = await this.findOneFromDef('signature', [this.data.ticketFk]);
|
this.signature = await this.findOneFromDef('signature', [this.data.ticketFk]);
|
||||||
} else
|
} else
|
||||||
this.merchandises = null;
|
this.merchandises = null;
|
||||||
|
|
||||||
this.senderStamp = (this.data.senderStamp)
|
this.senderStamp = (this.data.senderStamp)
|
||||||
? `${prefixBase64} ${this.data.senderStamp.toString('base64')}`
|
? `${prefixBase64} ${this.data.senderStamp.toString('base64')}`
|
||||||
: null;
|
: null;
|
||||||
this.deliveryStamp = (this.data.deliveryStamp)
|
this.deliveryStamp = (this.data.deliveryStamp)
|
||||||
? `${prefixBase64} ${this.data.deliveryStamp.toString('base64')}`
|
? `${prefixBase64} ${this.data.deliveryStamp.toString('base64')}`
|
||||||
: null;
|
: null;
|
||||||
},
|
this.truckPlateQr = await this.getQR(this.data.truckPlate);
|
||||||
props: {
|
},
|
||||||
id: {
|
props: {
|
||||||
type: Number,
|
id: {
|
||||||
required: true,
|
type: Number,
|
||||||
description: 'The cmr id'
|
required: true,
|
||||||
},
|
description: 'The cmr id'
|
||||||
},
|
},
|
||||||
computed: {
|
},
|
||||||
signPath() {
|
computed: {
|
||||||
if (!this.signature) return;
|
signPath() {
|
||||||
|
if (!this.signature) return;
|
||||||
|
|
||||||
const signatureName = this.signature.signature
|
const signatureName = this.signature.signature;
|
||||||
const hash = md5(signatureName.toString()).substring(0, 3);
|
const hash = md5(signatureName.toString()).substring(0, 3);
|
||||||
const file = `${config.storage.root}/${hash}/${signatureName}.png`;
|
const file = `${config.storage.root}/${hash}/${signatureName}.png`;
|
||||||
if (!fs.existsSync(file)) return null;
|
if (!fs.existsSync(file)) return null;
|
||||||
|
|
||||||
return `${prefixBase64} ${Buffer.from(fs.readFileSync(file), 'utf8').toString('base64')}`;
|
return `${prefixBase64} ${Buffer.from(fs.readFileSync(file), 'utf8').toString('base64')}`;
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
};
|
methods: {
|
||||||
|
getQR(id) {
|
||||||
|
const data = String(id);
|
||||||
|
|
||||||
|
return qrcode.toDataURL(data, {margin: 0});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -10,6 +10,7 @@ SELECT c.id cmrFk,
|
||||||
c.merchandiseDetail,
|
c.merchandiseDetail,
|
||||||
c.ead,
|
c.ead,
|
||||||
s.name carrierName,
|
s.name carrierName,
|
||||||
|
s.nif carrierCif,
|
||||||
s.street carrierStreet,
|
s.street carrierStreet,
|
||||||
s.postCode carrierPostCode,
|
s.postCode carrierPostCode,
|
||||||
s.city carrierCity,
|
s.city carrierCity,
|
||||||
|
|
Loading…
Reference in New Issue
Esta ultima part:
{(data.carrierCountry) ? (${data.carrierCountry}): null}}
No te val fica soles
{{data.carrierCountry}}
?I també podries fer
{{ data.carrierCountry ?? null }}
si fera falta q foranull
i noundefined
Crec que ho vaig ficar aixina perque si era undefined me retornaba error el report