salix/print/templates/reports/previa-label/previa-label.js

31 lines
820 B
JavaScript
Executable File

const vnReport = require('../../../core/mixins/vn-report.js');
const qrcode = require('qrcode');
module.exports = {
name: 'previa-label',
mixins: [vnReport],
async serverPrefetch() {
this.sector = await this.findOneFromDef('sector', [this.id]);
this.checkMainEntity(this.sector);
this.previa = await this.findOneFromDef('previa', [this.id]);
this.barcode = await this.getBarcodeBase64(this.id);
if (this.previa)
this.previa = this.previa[0];
},
methods: {
getBarcodeBase64(id) {
const data = String(id);
return qrcode.toDataURL(data, {margin: 0});
},
},
props: {
id: {
type: Number,
required: true,
description: 'The saleGroupFk id'
},
}
};