2023-01-23 12:15:30 +00:00
|
|
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
2022-12-22 07:04:03 +00:00
|
|
|
const jsBarcode = require('jsbarcode');
|
|
|
|
const {DOMImplementation, XMLSerializer} = require('xmldom');
|
2022-12-12 17:27:45 +00:00
|
|
|
const qrcode = require('qrcode');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
name: 'expedition-pallet-label',
|
2023-01-23 12:15:30 +00:00
|
|
|
mixins: [vnReport],
|
2022-12-12 17:27:45 +00:00
|
|
|
props: {
|
|
|
|
id: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
description: 'The pallet id'
|
|
|
|
},
|
|
|
|
userFk: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
description: 'The user id'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async serverPrefetch() {
|
|
|
|
this.labelsData = await this.rawSqlFromDef('labelData', this.id);
|
|
|
|
this.username = await this.findOneFromDef('username', this.userFk);
|
|
|
|
this.labelData = this.labelsData[0];
|
2023-03-08 16:30:28 +00:00
|
|
|
this.checkMainEntity(this.labelData);
|
2022-12-12 17:27:45 +00:00
|
|
|
|
|
|
|
let QRdata = JSON.stringify({
|
|
|
|
company: 'vnl',
|
2022-12-12 18:36:11 +00:00
|
|
|
user: this.userFk,
|
2023-01-16 14:18:24 +00:00
|
|
|
created: Date.vnNew(),
|
2022-12-12 17:27:45 +00:00
|
|
|
table: 'expeditionPallet',
|
|
|
|
id: this.id
|
|
|
|
});
|
|
|
|
|
|
|
|
this.QR = await this.getQR(QRdata);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getQR(id) {
|
|
|
|
const data = String(id);
|
|
|
|
return qrcode.toDataURL(data, {margin: 0});
|
|
|
|
},
|
2022-12-22 07:04:03 +00:00
|
|
|
getBarcode(id) {
|
|
|
|
const xmlSerializer = new XMLSerializer();
|
|
|
|
const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null);
|
|
|
|
const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
|
|
|
|
|
|
jsBarcode(svgNode, id, {
|
|
|
|
xmlDocument: document,
|
|
|
|
format: 'code128',
|
|
|
|
displayValue: false,
|
|
|
|
width: 6,
|
|
|
|
height: 90,
|
|
|
|
});
|
|
|
|
return xmlSerializer.serializeToString(svgNode);
|
|
|
|
},
|
2022-12-12 17:27:45 +00:00
|
|
|
},
|
|
|
|
};
|