salix/print/templates/reports/expedition-pallet-label/expedition-pallet-label.js

44 lines
1.2 KiB
JavaScript

const vnReport = require('../../../core/mixins/vn-report.js');
const jsBarcode = require('jsbarcode');
const {DOMImplementation, XMLSerializer} = require('xmldom');
const qrcode = require('qrcode');
module.exports = {
name: 'expedition-pallet-label',
mixins: [vnReport],
props: {
id: {
type: Number,
required: true,
description: 'The pallet id'
},
userFk: {
type: Number,
description: 'The user id'
}
},
async serverPrefetch() {
this.username = null;
this.labelsData = await this.rawSqlFromDef('labelData', this.id);
if (this.userFk) this.username = await this.findOneFromDef('username', this.userFk);
this.labelData = this.labelsData[0];
this.checkMainEntity(this.labelData);
let QRdata = JSON.stringify({
company: 'vnl',
user: this.userFk,
created: Date.vnNew(),
table: 'expeditionPallet',
id: this.id
});
this.QR = await this.getQR(QRdata);
},
methods: {
getQR(id) {
const data = String(id);
return qrcode.toDataURL(data, {margin: 0});
},
},
};