refactor: refs #7644 Optimized barcode
gitea/salix/pipeline/pr-master This commit looks good
Details
gitea/salix/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
cfebee86f3
commit
1a2ed9ce68
|
@ -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: {
|
||||||
|
|
Loading…
Reference in New Issue