2023-01-23 12:15:30 +00:00
|
|
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
2022-11-21 12:31:55 +00:00
|
|
|
const qrcode = require('qrcode');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
name: 'previa-label',
|
2023-01-23 12:15:30 +00:00
|
|
|
mixins: [vnReport],
|
2022-11-21 12:31:55 +00:00
|
|
|
async serverPrefetch() {
|
2023-01-23 12:15:30 +00:00
|
|
|
this.sector = await this.findOneFromDef('sector', [this.id]);
|
|
|
|
this.checkMainEntity(this.sector);
|
|
|
|
this.previa = await this.findOneFromDef('previa', [this.id]);
|
2022-11-21 12:31:55 +00:00
|
|
|
this.barcode = await this.getBarcodeBase64(this.id);
|
|
|
|
|
2022-12-22 07:00:18 +00:00
|
|
|
if (this.previa)
|
|
|
|
this.previa = this.previa[0];
|
2022-11-21 12:31:55 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getBarcodeBase64(id) {
|
|
|
|
const data = String(id);
|
|
|
|
|
|
|
|
return qrcode.toDataURL(data, {margin: 0});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
id: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
description: 'The saleGroupFk id'
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|