feat(collection-label): refs #6602 add qr to the report #2292

Merged
pablone merged 5 commits from 6602-barcode-to-qr into dev 2024-05-03 11:52:23 +00:00
6 changed files with 40 additions and 25 deletions
Showing only changes of commit bd1499a6f7 - Show all commits

View File

@ -77,8 +77,7 @@
tabindex="-1"> tabindex="-1">
</vn-fetched-tags> </vn-fetched-tags>
</vn-td> </vn-td>
<vn-td number>{{::sale.quantity | dashIfEmpty}}</vn-td> <vn-td number>{{::sale.quantity | dashIfEmpty}}</vn-td>
</vn-tr>
</vn-tbody> </vn-tbody>
</vn-table> </vn-table>
</vn-card> </vn-card>

View File

@ -32,9 +32,12 @@ html {
#bold { #bold {
font-weight: bold; font-weight: bold;
} }
#barcode{ .barcode{
width: 370px; width: 370px;
} }
.qr{
max-height: 137px;
}
#shipped { #shipped {
font-weight: bold; font-weight: bold;
width: 50px; width: 50px;

View File

@ -8,15 +8,15 @@
<td id="ticketFk"> <td id="ticketFk">
{{labelData.clientFk ? `${labelData.ticketFk} « ${labelData.clientFk}` : labelData.ticketFk}} {{labelData.clientFk ? `${labelData.ticketFk} « ${labelData.clientFk}` : labelData.ticketFk}}
</td> </td>
<td colspan="2" id="shipped">{{labelData.shipped || '---'}}</td> <td colspan="2" id="shipped">{{dashIfEmpty(labelData.shipped)}}</td>
</tr> </tr>
<tr v-if="labelData.scannableCodeType === 'qr'"> <tr v-if="labelData?.qrData">
<td rowspan="3"><div v-html="getQr(labelData.ticketFk)" id="barcode"></div></td> <td rowspan="3"><img :src="labelData.qrData" class="qr"/></td>
<td id="outline" class="ellipsize">{{labelData.workerCode || '---'}}</td> <td id="outline" class="ellipsize">{{dashIfEmpty(labelData.workerCode)}}</td>
pablone marked this conversation as resolved Outdated

buscar opcion sin --- que no aparezca nada por ejemplo

buscar opcion sin --- que no aparezca nada por ejemplo
</tr> </tr>
<tr v-else> <tr v-else>
<td rowspan="3"><div v-html="getBarcode(labelData.ticketFk)" id="barcode"></div></td> <td rowspan="3"><div v-html="getBarcode(labelData.ticketFk)" class="basrcode"></div></td>
<td id="outline" class="ellipsize">{{labelData.workerCode || '---'}}</td> <td id="outline" class="ellipsize">{{dashIfEmpty(labelData.workerCode)}}</td>
</tr> </tr>
<tr> <tr>
<td id="outline" class="ellipsize">{{labelData.labelCount || 0}}</td> <td id="outline" class="ellipsize">{{labelData.labelCount || 0}}</td>
@ -25,11 +25,11 @@
<td id="outline" class="ellipsize">{{labelData.code == 'V' ? (labelData.size || 0) + 'cm' : (labelData.volume || 0) + 'm³'}}</td> <td id="outline" class="ellipsize">{{labelData.code == 'V' ? (labelData.size || 0) + 'cm' : (labelData.volume || 0) + 'm³'}}</td>
</tr> </tr>
<tr> <tr>
<td><div id="agencyDescripton" class="ellipsize">{{getAgencyDescripton(labelData)}}</div></td> <td><div id="agencyDescripton" class="ellipsize">{{dashIfEmpty(getAgencyDescription(labelData))}}</div></td>
<td id="bold">{{labelData.lineCount || 0}}</td> <td id="bold">{{labelData.lineCount || 0}}</td>
</tr> </tr>
<tr> <tr>
<td id="nickname" class="ellipsize">{{labelData.nickName ? labelData.nickName.toUpperCase() : '---'}}</td> <td id="nickname" class="ellipsize">{{dashIfEmpty(labelData?.nickName.toUpperCase()) }}</td>
<td id="bold">{{labelData.shippedHour || labelData.zoneHour}}</td> <td id="bold">{{labelData.shippedHour || labelData.zoneHour}}</td>
</tr> </tr>
</tbody> </tbody>

View File

@ -1,8 +1,9 @@
import qrcode from 'qrcode'; const qrCode = require('qrcode');
import jsBarcode from 'jsbarcode'; const jsBarcode = require('jsbarcode');
const {DOMImplementation, XMLSerializer} = require('xmldom'); const {DOMImplementation, XMLSerializer} = require('xmldom');
const vnReport = require('../../../core/mixins/vn-report.js'); const vnReport = require('../../../core/mixins/vn-report.js');
const {TRUE} = require('node-sass');
module.exports = { module.exports = {
name: 'collection-label', name: 'collection-label',
@ -29,19 +30,27 @@ module.exports = {
} else } else
ticketIds = [this.id]; ticketIds = [this.id];
this.labelsData = await this.rawSqlFromDef('labelsData', [ticketIds]); const labels = await this.rawSqlFromDef('labelsData', [ticketIds]);
const [{scannableCodeType}] = await this.rawSqlFromDef('barcodeType');
if (scannableCodeType === 'qr') {
for (const labelData of labels)
labelData.qrData = await this.getQr(labelData?.ticketFk, labelData?.workerFk);
}
this.labelsData = labels;
this.checkMainEntity(this.labelsData); this.checkMainEntity(this.labelsData);
}, },
methods: { methods: {
getQR(id) { async getQr(ticketFk, workerFk = null) {
let QRdata = JSON.stringify({ const QRdata = JSON.stringify({
company: 'vnl', company: 'vnl',
user: this.userFk, user: workerFk,
created: Date.vnNew(), created: Date.vnNew(),
table: 'ticket', table: 'ticket',
id id: ticketFk
}); });
return qrcode.toDataURL(QRdata, {margin: 0}); return qrCode.toDataURL(QRdata, {margin: 0});
}, },
getBarcode(id) { getBarcode(id) {
const xmlSerializer = new XMLSerializer(); const xmlSerializer = new XMLSerializer();
@ -64,18 +73,16 @@ module.exports = {
if (labelData.code == 'V') if (labelData.code == 'V')
value = value + `${labelData.wagon}-${labelData.level}`; value = value + `${labelData.wagon}-${labelData.level}`;
else else
value = value + `${labelData.color.substring(0, 4)}`; value = value + `${labelData.color?.substring(0, 4)}`;
} else } else
value = '-'.repeat(19); value = '-'.repeat(19);
return value; return value;
}, },
getAgencyDescripton(labelData) { getAgencyDescription(labelData) {
let value; let value;
if (labelData.agencyDescription) if (labelData.agencyDescription)
value = labelData.agencyDescription.toUpperCase().substring(0, 11); value = labelData.agencyDescription.toUpperCase().substring(0, 11);
else
value = '---';
if (labelData.routeFk) { if (labelData.routeFk) {
let routeFk = labelData.routeFk.toString(); let routeFk = labelData.routeFk.toString();
@ -84,5 +91,8 @@ module.exports = {
return value; return value;
}, },
dashIfEmpty(value) {
return value || '---';
}
}, },
}; };

View File

@ -0,0 +1,3 @@
SELECT scannableCodeType
FROM productionConfig
LIMIT 1

View File

@ -11,14 +11,14 @@ SELECT c.itemPackingTypeFk code,
IF(sgd.id, IFNULL(pc.itemPreviousDefaultSize, i.`size`), i.`size`) IF(sgd.id, IFNULL(pc.itemPreviousDefaultSize, i.`size`), i.`size`)
) `size`, ) `size`,
w.code workerCode, w.code workerCode,
w.id workerFk,
TIME_FORMAT(t.shipped, '%H:%i') shippedHour, TIME_FORMAT(t.shipped, '%H:%i') shippedHour,
TIME_FORMAT(zo.`hour`, '%H:%i') zoneHour, TIME_FORMAT(zo.`hour`, '%H:%i') zoneHour,
DATE_FORMAT(t.shipped, '%d/%m/%y') shipped, DATE_FORMAT(t.shipped, '%d/%m/%y') shipped,
tt.labelCount, tt.labelCount,
t.nickName, t.nickName,
SUM(IF(sgd.id IS NULL, 1, 0)) + IF(sgd.id , 1, 0) lineCount, SUM(IF(sgd.id IS NULL, 1, 0)) + IF(sgd.id , 1, 0) lineCount,
rm.routeFk, rm.routeFk
pc.scannableCodeType
FROM vn.ticket t FROM vn.ticket t
JOIN vn.ticketCollection tc ON tc.ticketFk = t.id JOIN vn.ticketCollection tc ON tc.ticketFk = t.id
JOIN vn.collection c ON c.id = tc.collectionFk JOIN vn.collection c ON c.id = tc.collectionFk