closes 4732 etiquetas con QR para previa y item #1163

Merged
pau merged 35 commits from 4732-previa-label into dev 2023-01-18 08:26:11 +00:00
15 changed files with 243 additions and 3590 deletions

View File

@ -0,0 +1,49 @@
const {Report} = require('vn-print');
module.exports = Self => {
Self.remoteMethodCtx('previousLabel', {
description: 'Returns the previa label pdf',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The item 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/previousLabel',
verb: 'GET'
}
});
Self.previousLabel = async(ctx, id) => {
const args = Object.assign({}, ctx.args);
const params = {lang: ctx.req.getLocale()};
delete args.ctx;
for (const param in args)
params[param] = args[param];
const report = new Report('previa-label', params);
const stream = await report.toPdfStream();
return [stream, 'application/pdf', `filename="previa-${id}.pdf"`];
};
};

View File

@ -3,4 +3,5 @@ module.exports = Self => {
require('../methods/collection/newCollection')(Self); require('../methods/collection/newCollection')(Self);
require('../methods/collection/getSectors')(Self); require('../methods/collection/getSectors')(Self);
require('../methods/collection/setSaleQuantity')(Self); require('../methods/collection/setSaleQuantity')(Self);
require('../methods/collection/previousLabel')(Self);
}; };

View File

@ -0,0 +1,3 @@
UPDATE `vn`.`collection`
SET sectorFk=1
WHERE id=1;

View File

@ -1215,7 +1215,7 @@ INSERT INTO `vn`.`tag`(`id`, `code`, `name`, `isFree`, `isQuantitatif`, `sourceT
(7, NULL, 'Ancho de la base', 1, 1, NULL, 'mm',NULL, NULL), (7, NULL, 'Ancho de la base', 1, 1, NULL, 'mm',NULL, NULL),
(23, 'stems', 'Tallos', 1, 1, NULL, NULL, NULL, 'stems'), (23, 'stems', 'Tallos', 1, 1, NULL, NULL, NULL, 'stems'),
(27, NULL, 'Longitud(cm)', 1, 1, NULL, 'cm', NULL, NULL), (27, NULL, 'Longitud(cm)', 1, 1, NULL, 'cm', NULL, NULL),
(36, NULL, 'Proveedor', 1, 0, NULL, NULL, NULL, NULL), (36, 'producer', 'Proveedor', 1, 0, NULL, NULL, NULL, 'producer'),
(56, NULL, 'Genero', 1, 0, NULL, NULL, NULL, NULL), (56, NULL, 'Genero', 1, 0, NULL, NULL, NULL, NULL),
(58, NULL, 'Variedad', 1, 0, NULL, NULL, NULL, NULL), (58, NULL, 'Variedad', 1, 0, NULL, NULL, NULL, NULL),
(67, 'category', 'Categoria', 1, 0, NULL, NULL, NULL, NULL), (67, 'category', 'Categoria', 1, 0, NULL, NULL, NULL, NULL),

3588
print/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,9 +3,12 @@ SELECT
i.name, i.name,
i.stems, i.stems,
i.size, i.size,
b.packing b.packing,
p.name as 'producer'
FROM vn.item i FROM vn.item i
JOIN cache.last_buy clb ON clb.item_id = i.id JOIN cache.last_buy clb ON clb.item_id = i.id
JOIN vn.buy b ON b.id = clb.buy_id JOIN vn.buy b ON b.id = clb.buy_id
JOIN vn.entry e ON e.id = b.entryFk JOIN vn.entry e ON e.id = b.entryFk
JOIN vn.producer p ON p.id = i.producerFk
WHERE i.id = ? AND clb.warehouse_id = ? WHERE i.id = ? AND clb.warehouse_id = ?

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,85 @@
* {
box-sizing: border-box;
padding-right: 1%;
}
.label {
font-size: 1.2em;
font-family: Arial, Helvetica, sans-serif;
}
.barcode {
pau marked this conversation as resolved
Review

Yo quitaría los saltos de línea entre etiquetas, de forma que quede el código más compacto.

Ejemplo:

label {
    font-size: 1.2em;
    font-family: Arial, Helvetica, sans-serif;
}
label2 {
    font-size: 1.2em;
    font-family: Arial, Helvetica, sans-serif;
}
label3 {
    font-size: 1.2em;
    font-family: Arial, Helvetica, sans-serif;
}
Yo quitaría los saltos de línea entre etiquetas, de forma que quede el código más compacto. *Ejemplo*: ``` label { font-size: 1.2em; font-family: Arial, Helvetica, sans-serif; } label2 { font-size: 1.2em; font-family: Arial, Helvetica, sans-serif; } label3 { font-size: 1.2em; font-family: Arial, Helvetica, sans-serif; } ```
float: left;
width: 40%;
}
.barcode h1 {
text-align: center;
font-size: 1.8em;
margin: 0 0 10px 0
}
.barcode .image {
text-align: center
}
.barcode .image img {
width: 170px
}
.data {
float: left;
width: 60%;
}
.data .header {
background-color: #000;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
margin-bottom: 25px;
text-align: right;
font-size: 1.2em;
padding: 0.2em;
color: #FFF
}
.data .sector,
.data .producer {
text-transform: uppercase;
text-align: right;
font-size: 1.5em;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.data .sector-sm {
text-transform: uppercase;
text-align: right;
font-size: 1.2em;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.data .producer {
text-justify: inter-character;
}
.data .details {
border-top: 4px solid #000;
padding-top: 2px;
}
.data .details .package {
padding-right: 5px;
float: left;
width: 50%;
}
.package .packing,
.package .dated,
.package .labelNumber {
text-align: right
}
.package .packing {
font-size: 1.8em;
font-weight: 400
}
.data .details .size {
background-color: #000;
text-align: center;
font-size: 3em;
padding: 0.2em 0;
float: left;
width: 50%;
color: #FFF
}

View File

@ -0,0 +1,2 @@
previous: PREVIOUS
report: Report

View File

@ -0,0 +1,2 @@
previous: PREVIA
report: Ticket

View File

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

View File

@ -0,0 +1,26 @@
<DOCTYPE html>
<body>
<div class="label">
<div class="barcode">
<h1>{{previa.saleGroupFk}}</h1>
<div class="image">
<img v-bind:src="barcode" />
</div>
</div>
<div class="data">
<div class="header">{{ $t('previous') }}</div>
<div v-if="sector.description.length > 16" class="sector-sm">
{{sector.description}}
pau marked this conversation as resolved Outdated
Outdated
Review

Previous, añadir traducción

Previous, añadir traducción
</div>
<div v-else class="sector">{{sector.description}}</div>
<div class="producer">{{ $t('report') }}#{{previa.ticketFk}}</div>
<div class="details">
<div class="package">
<div class="packing">{{previa.itemPackingTypeFk}}</div>
<div class="dated">{{previa.shippingHour}}:{{previa.shippingMinute}}</div>
</div>
<div class="size">{{previa.items}}</div>
</div>
</div>
</div>
</body>

View File

@ -0,0 +1,42 @@
const Component = require(`vn-print/core/component`);
const reportBody = new Component('report-body');
const qrcode = require('qrcode');
const UserError = require('vn-loopback/util/user-error');
module.exports = {
name: 'previa-label',
async serverPrefetch() {
this.previa = await this.fetchPrevia(this.id);
this.sector = await this.fetchSector(this.id);
this.barcode = await this.getBarcodeBase64(this.id);
if (this.previa)
this.previa = this.previa[0];
pau marked this conversation as resolved Outdated
Outdated
Review

Utilizar UserError tal como se acordó en la reunión

Utilizar UserError tal como se acordó en la reunión
if (!this.sector)
pau marked this conversation as resolved
Review

Debería ser solo necesario manejar la entidad principal y el informe ser capaz de funcionar sin el sector

Debería ser solo necesario manejar la entidad principal y el informe ser capaz de funcionar sin el sector
throw new UserError('Something went wrong - no sector found');
},
methods: {
fetchPrevia(id) {
return this.findOneFromDef('previa', [id]);
},
getBarcodeBase64(id) {
const data = String(id);
return qrcode.toDataURL(data, {margin: 0});
},
fetchSector(id) {
return this.findOneFromDef('sector', [id]);
}
},
components: {
'report-body': reportBody.build()
},
props: {
id: {
type: Number,
required: true,
description: 'The saleGroupFk id'
},
}
};

View File

@ -0,0 +1 @@
CALL vn.previousSticker_get(?)

View File

@ -0,0 +1,4 @@
SELECT s.description
FROM vn.saleGroup sg
pau marked this conversation as resolved Outdated

Aquí formatearía bien el SQL, ya que no cumple con los estándares acordados, aquí tienes la página de la wiki: https://wiki.verdnatura.es/index.php/Convenciones_SQL

Aquí formatearía bien el SQL, ya que no cumple con los estándares acordados, aquí tienes la página de la wiki: https://wiki.verdnatura.es/index.php/Convenciones_SQL
JOIN vn.sector s ON sg.sectorFk = s.id
pau marked this conversation as resolved Outdated

Aun sigue estando mal, sería de la siguiente forma:

SELECT s.description
	FROM vn.saleGroup sg
		JOIN vn.sector s ON s.id = sg.sectorFk
	WHERE sg.id = ?
Aun sigue estando mal, sería de la siguiente forma: ``` SELECT s.description FROM vn.saleGroup sg JOIN vn.sector s ON s.id = sg.sectorFk WHERE sg.id = ? ```
WHERE sg.id = ?