refs #7644 First commit
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-06-28 12:57:27 +02:00
parent 7af2ae80b7
commit 19bf606330
9 changed files with 261 additions and 0 deletions

View File

@ -0,0 +1,36 @@
module.exports = Self => {
Self.remoteMethodCtx('entryLabel', {
description: 'Returns the entry labels',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The entry id',
http: {source: 'path'}
}
],
returns: [
{
arg: 'body',
type: 'file',
root: true
}, {
arg: 'Content-Type',
type: 'String',
http: {target: 'header'}
}, {
arg: 'Content-Disposition',
type: 'String',
http: {target: 'header'}
}
],
http: {
path: '/:id/entry-label',
verb: 'GET'
}
});
Self.entryLabel = (ctx, id) => Self.printReport(ctx, id, 'entry-label');
};

View File

@ -9,6 +9,7 @@ module.exports = Self => {
require('../methods/entry/entryOrderPdf')(Self);
require('../methods/entry/addFromPackaging')(Self);
require('../methods/entry/addFromBuy')(Self);
require('../methods/entry/entryLabel')(Self);
Self.observe('before save', async function(ctx, options) {
if (ctx.isNewInstance) return;

View File

@ -0,0 +1,12 @@
const Stylesheet = require(`vn-print/core/stylesheet`);
const path = require('path');
const vnPrintPath = path.resolve('print');
module.exports = new Stylesheet([
`${vnPrintPath}/common/css/spacing.css`,
`${vnPrintPath}/common/css/misc.css`,
`${vnPrintPath}/common/css/layout.css`,
`${vnPrintPath}/common/css/report.css`,
`${__dirname}/style.css`])
.mergeStyles();

View File

@ -0,0 +1,58 @@
html {
height: 100%;
margin-top: -6px;
}
* {
box-sizing: border-box;
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
font-size: 28px;
}
table {
border: 1px solid;
width: 100%;
font-size: inherit;
}
td {
border: 1px solid;
padding: 5px;
width: 100%;
}
#barcode {
text-align: center;
}
span {
font-size: 48px;
font-weight: bold;
}
.lbl {
color: gray;
font-weight: lighter;
font-size: 18px;
display: block;
}
.flex-container {
display: flex;
justify-content: space-between;
}
.flex-item {
flex: 1;
}
.section {
height: 50px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#variant {
width: 314px;
}
#producer {
width: 471px;
}
.cell {
width: 157px;
}
#leftBox {
border-right: 1px solid;
}

View File

@ -0,0 +1,89 @@
<!DOCTYPE html>
<html>
<table v-for="buy in buys" style="break-before: page">
<tbody>
<tr>
<td colspan="2">
<div id="variant" class="section">
<span class="lbl">Variedad:</span>
{{buy.name}}
</div>
</td>
<td>
<div class="cell">
<span class="lbl">Medida:</span>
{{buy.size}}
</div>
</td>
</tr>
<tr>
<td>
<div class="cell">
<span class="lbl">Categoría:</span>
{{buy.category}}
</div>
</td>
<td>
<div class="cell">
<span class="lbl">Color:</span>
{{buy.color}}
</div>
</td>
<td>
<div class="cell">
<span class="lbl">Origen:</span>
{{buy.origin}}
</div>
</td>
</tr>
<tr>
<td>
<div class="cell">
<span class="lbl">Packing:</span>
{{buy.packing}}
</div>
</td>
<td>
<div class="cell">
<span class="lbl">Grouping:</span>
{{buy.grouping}}
</div>
</td>
<td>
<div class="cell">
<span class="lbl">Und. venta:</span>
{{buy.stems}}
</div>
</td>
</tr>
<tr>
<td colspan="3" id="barcode">
<div v-html="getBarcode(buy.id)"></div>
<span>{{buy.id}}</span>
</td>
</tr>
<tr>
<td colspan="3">
<div id="producer" class="section">
<span class="lbl">Productor:</span>
{{buy.producer}}
</div>
</td>
</tr>
<tr>
<td colspan="3">
<div class="flex-container">
<div class="flex-item" id="leftBox">
<span class="lbl">Control:</span>
06/11
</div>
<div class="flex-item">
<span class="lbl">Caja nº:</span>
{{`${buy.labelNum} / ${maxLabelNum}`}}
</div>
</div>
</td>
</tr>
</tbody>
</table>
</html>

View File

@ -0,0 +1,36 @@
const vnReport = require('../../../core/mixins/vn-report.js');
const {DOMImplementation, XMLSerializer} = require('xmldom');
const jsBarcode = require('jsbarcode');
module.exports = {
name: 'entry-label',
mixins: [vnReport],
async serverPrefetch() {
this.buys = await this.rawSqlFromDef('entry', [this.id]);
const maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum));
this.maxLabelNum = maxLabelNum;
},
methods: {
getBarcode(id) {
const xmlSerializer = new XMLSerializer();
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, {
xmlDocument: document,
format: 'code128',
displayValue: false,
width: 3.8,
height: 115,
});
return xmlSerializer.serializeToString(svgNode);
}
},
props: {
id: {
type: Number,
required: true,
description: 'The entry id'
}
}
};

View File

@ -0,0 +1 @@
reportName: Etiqueta

View File

@ -0,0 +1,11 @@
{
"width": "10cm",
"height": "10.3cm",
"margin": {
"top": "0.17cm",
"right": "0.2cm",
"bottom": "0cm",
"left": "0cm"
},
"printBackground": true
}

View File

@ -0,0 +1,17 @@
SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum,
i.name,
i.`size`,
i.category,
ink.id color,
o.code origin,
b.packing,
b.`grouping`,
i.stems,
b.id,
p.name producer
FROM buy b
JOIN item i ON i.id = b.itemFk
LEFT JOIN producer p ON p.id = i.producerFk
LEFT JOIN ink ON ink.id = i.inkFk
LEFT JOIN origin o ON o.id = i.originFk
WHERE b.entryFk = ?