refactor: refs #7644 Optimized barcode #2819
|
@ -35,8 +35,10 @@ module.exports = {
|
||||||
logger.error(`[Print] => ${err.message}`);
|
logger.error(`[Print] => ${err.message}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
cluster.on('queue', () =>
|
cluster.on('queue', () => {
|
||||||
process.env.SPEC_IS_RUNNING === 'false' && logger.info('Printing task initialized by pool'));
|
if (process.env.SPEC_IS_RUNNING !== 'true')
|
||||||
|
logger.info('Printing task initialized by pool');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,11 +7,11 @@ table {
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
|
page-break-before: always;
|
||||||
}
|
}
|
||||||
td {
|
td {
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
width: 100%;
|
|
||||||
}
|
}
|
||||||
span {
|
span {
|
||||||
font-size: 48px;
|
font-size: 48px;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<table v-for="buy in buys" style="break-before: page">
|
<table v-for="buy in buys" :key="buy.id">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
|
|
|
@ -12,20 +12,28 @@ module.exports = {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
this.weekNum = moment(date).isoWeek();
|
this.weekNum = moment(date).isoWeek();
|
||||||
this.dayNum = moment(date).day();
|
this.dayNum = moment(date).day();
|
||||||
|
this.barcodes = [];
|
||||||
|
await this.generateAllBarcodes(this.buys);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getBarcode(id) {
|
generateAllBarcodes(buys) {
|
||||||
const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null);
|
const uniqueBuyIds = new Set(buys.map(buy => buy.id));
|
||||||
const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
for (let buy of uniqueBuyIds) {
|
||||||
|
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, {
|
jsBarcode(svgNode, buy, {
|
||||||
xmlDocument: document,
|
xmlDocument: document,
|
||||||
format: 'code128',
|
format: 'code128',
|
||||||
displayValue: false,
|
displayValue: false,
|
||||||
width: 3.8,
|
width: 3.8,
|
||||||
height: 115,
|
height: 115,
|
||||||
});
|
});
|
||||||
return new XMLSerializer().serializeToString(svgNode);
|
this.barcodes.push({id: buy, barcode: new XMLSerializer().serializeToString(svgNode)});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getBarcode(id) {
|
||||||
|
return this.barcodes.find(item => item.id === id).barcode;
|
||||||
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
|
|
@ -6,7 +6,7 @@ color: Color
|
||||||
origin: Origin
|
origin: Origin
|
||||||
packing: Packing
|
packing: Packing
|
||||||
grouping: Grouping
|
grouping: Grouping
|
||||||
unitSale: Un. sale
|
saleUnit: Un. sale
|
||||||
producer: Producer
|
producer: Producer
|
||||||
control: Control
|
control: Control
|
||||||
boxNum: Box no.
|
boxNum: Box no.
|
||||||
|
|
Loading…
Reference in New Issue
Podries haver fet que this.barcodes fora un Map (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) axina despres sols has de accedir a ixe registre en concret encomter de buscar cada 1
https://www.measurethat.net/Benchmarks/Show/23555/5/arrayfind-vs-mapget#latest_results_block