feat: refs #7280 refs 7280 First commit #3347

Open
guillermo wants to merge 3 commits from 7280-scanPalletLabel into dev
9 changed files with 241 additions and 0 deletions

View File

@ -0,0 +1,36 @@
module.exports = Self => {
Self.remoteMethodCtx('scanExpeditionPalletLabel', {
description: 'Returns the scan expedition pallet label',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The pallet 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/scan-expedition-pallet-label',
verb: 'GET'
}
});
Self.expeditionPalletLabel = (ctx, id) => Self.printReport(ctx, id, 'scan-expedition-pallet-label');
};

View File

@ -17,4 +17,5 @@ module.exports = Self => {
require('../methods/route/getExpeditionSummary')(Self); require('../methods/route/getExpeditionSummary')(Self);
require('../methods/route/getByWorker')(Self); require('../methods/route/getByWorker')(Self);
require('../methods/route/optimizePriority')(Self); require('../methods/route/optimizePriority')(Self);
require('../methods/route/scanExpeditionPalletLabel')(Self);
}; };

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,92 @@
html {
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
margin-top: -7px;
margin-left: -3px;
}
.leftTable {
width: 47%;
font-size: 12px;
float: left;
text-align: center;
}
.leftTable img {
margin-top: 3px;
width: 110px;
}
.rightTable {
width: 53%;
font-size: 14px;
float: right;
}
.rightTable td {
border: 3px solid white;
}
.center {
text-align: center;
}
.cursive {
font-style: italic;
}
.bold {
font-weight: bold;
}
.black-bg {
background-color: black;
color: white;
}
.sm-txt {
font-size: 18px;
}
.md-txt {
font-size: 20px;
}
.xl-txt {
font-size: 36px;
}
.cell {
border: 2px solid black;
box-sizing: content-box;
width: 100%;
height: 30px;
display: flex;
justify-content: center;
align-items: center;
}
.padding {
padding: 7px;
}
.md-height {
height: 68px;
max-height: 68px;
}
.xs-width {
width: 60px;
max-width: 60px;
}
.sm-width {
width: 130px;
max-width: 130px;
}
.md-width {
width: 190px;
max-width: 190px;
}
.lg-width {
width: 240px;
max-width: 240px;
}
.overflow-multiline {
max-height: inherit;
display: -webkit-box;
overflow: hidden;
word-wrap: break-word;
line-clamp: 2;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.overflow-line {
width: inherit;
max-width: inherit;
overflow: hidden;
white-space: nowrap;
}

View File

@ -0,0 +1 @@
reportName: Etiqueta de un pallet escaneado

View File

@ -0,0 +1,11 @@
{
"width": "10.4cm",
"height": "4.9cm",
"margin": {
"top": "0.17cm",
"right": "0.3cm",
"bottom": "0cm",
"left": "0cm"
},
"printBackground": true
}

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<body v-for="x in xs" style="break-before: page">
<table>
<tbody>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</body>
</html>

View File

@ -0,0 +1,25 @@
const UserError = require('vn-loopback/util/user-error');
const moment = require('moment');
module.exports = {
name: 'scan-expedition-pallet-label',
async serverPrefetch() {
this.date = Date.vnNew();
this.buys = await this.rawSqlFromDef('buy', [this.copies || 1, this.id]);
if (!this.buys.length) throw new UserError(`Empty data source`);
this.qr = await this.getQr(this.buys[0].buyFk);
this.date = moment(this.date).format('WW/DD');
},
methods: {
formatNumber(number) {
return new Intl.NumberFormat('es-ES', {maximumFractionDigits: 0}).format(number);
}
},
props: {
id: {
type: Number,
required: true,
description: 'The expedition pallet id'
}
}
};

View File

@ -0,0 +1,38 @@
WITH RECURSIVE numbers AS (
SELECT 1 n
UNION ALL
SELECT n + 1
FROM numbers
WHERE n < ?
)
SELECT ROW_NUMBER() OVER() labelNum,
b.itemFk,
i.name item,
b.id buyFk,
b.quantity,
b.packing,
b.entryFk,
o.code origin,
p.`name` producerName,
p.id producerFk,
i.`size`,
i.category,
i.stems,
i.inkFk,
ig.longName,
ig.subName,
i.comment,
w.code buyerName,
i.isLaid,
c.code company
FROM vn.buy b
JOIN vn.item i ON i.id = b.itemFk
LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk
JOIN vn.origin o ON o.id = i.originFk
LEFT JOIN vn.producer p ON p.id = i.producerFk
JOIN vn.itemType it ON it.id = i.typeFk
JOIN vn.worker w ON w.id = it.workerFk
JOIN vn.entry e ON e.id = b.entryFk
JOIN vn.company c ON c.id = e.companyFk
JOIN numbers num
WHERE b.id = ?