8144-devToTest_2448 #3216

Merged
alexm merged 256 commits from 8144-devToTest_2448 into test 2024-11-19 07:36:04 +00:00
15 changed files with 157 additions and 46 deletions
Showing only changes of commit c43bdb5021 - Show all commits

View File

@ -0,0 +1,48 @@
module.exports = Self => {
Self.remoteMethodCtx('labelBarcodePdf', {
description: 'Returns the item label pdf with barcode',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The item id',
http: {source: 'path'}
}, {
arg: 'packing',
type: 'number',
required: false
}, {
arg: 'copies',
type: 'number',
required: false
}
],
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/label-barcode-pdf',
verb: 'GET'
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.labelBarcodePdf = (ctx, id) => {
ctx.args.typeId = 'buy';
return Self.printReport(ctx, id, 'item-label-barcode');
};
};

View File

@ -0,0 +1,49 @@
module.exports = Self => {
Self.remoteMethodCtx('labelQrPdf', {
description: 'Returns the item label pdf with qr',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The item id',
http: {source: 'path'}
}, {
arg: 'packing',
type: 'number',
required: false
}, {
arg: 'copies',
type: 'number',
required: false
}
],
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/label-qr-pdf',
verb: 'GET'
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.labelQrPdf = (ctx, id) => {
ctx.args.userId = ctx.req.accessToken.userId;
ctx.args.typeId = 'buy';
return Self.printReport(ctx, id, 'item-label-qr');
};
};

View File

@ -2,4 +2,6 @@ module.exports = Self => {
require('../methods/entry/editLatestBuys')(Self);
require('../methods/entry/latestBuysFilter')(Self);
require('../methods/entry/deleteBuys')(Self);
require('../methods/entry/labelBarcodePdf')(Self);
require('../methods/entry/labelQrPdf')(Self);
};

View File

@ -21,12 +21,6 @@ module.exports = Self => {
arg: 'copies',
type: 'number',
required: false
}, {
arg: 'userId',
type: 'number',
description: 'The user id from accessToken',
http: ctx => ctx.req.accessToken.userId,
required: true
}
],
returns: [
@ -51,5 +45,8 @@ module.exports = Self => {
accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.labelBarcodePdf = (ctx, id) => Self.printReport(ctx, id, 'item-label-barcode');
Self.labelBarcodePdf = (ctx, id) => {
ctx.args.typeId = 'item';
return Self.printReport(ctx, id, 'item-label-barcode');
};
};

View File

@ -21,12 +21,6 @@ module.exports = Self => {
arg: 'copies',
type: 'number',
required: false
}, {
arg: 'userId',
type: 'number',
description: 'The user id from accessToken',
http: ctx => ctx.req.accessToken.userId,
required: true
}
],
returns: [
@ -51,5 +45,9 @@ module.exports = Self => {
accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.labelQrPdf = (ctx, id) => Self.printReport(ctx, id, 'item-label-qr');
Self.labelQrPdf = (ctx, id) => {
ctx.args.userId = ctx.req.accessToken.userId;
ctx.args.typeId = 'item';
return Self.printReport(ctx, id, 'item-label-qr');
};
};

View File

@ -1,7 +1,7 @@
html {
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
margin-top: -9px;
margin-left: -6px;
margin-left: -3px;
}
table {
width: 100%;
@ -52,8 +52,8 @@ td {
max-height: 50px;
}
.md-height {
height: 75px;
max-height: 75px;
height: 70px;
max-height: 70px;
}
.sm-width {
width: 60px;

View File

@ -52,7 +52,10 @@
<div v-html="getBarcode(item.buyFk)"></div>
</td>
<td colspan="2" class="center md-width xs-height xs-txt">
<div class="overflow-line">
<div v-if="item.isLaid && typeId === 'buy'" class="overflow-line black-bg bold">
{{'LAID'}}
</div>
<div v-else class="overflow-line">
{{item.entryFk}}
</div>
</td>

View File

@ -6,17 +6,18 @@ const jsbarcode = require('jsbarcode');
module.exports = {
name: 'item-label-barcode',
async serverPrefetch() {
this.company = await this.findOneFromDef('company', [this.warehouseId]);
if (!this.company)
throw new UserError(`There is no company associated with that warehouse`);
this.date = Date.vnNew();
this.lastBuy = await this.findOneFromDef('lastBuy', [
this.id,
this.warehouseId,
this.date
]);
this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy.id]);
if (this.typeId === 'item') {
this.company = await this.findOneFromDef('company', [this.warehouseId]);
if (!this.company)
throw new UserError(`There is no company associated with that warehouse`);
this.lastBuy = await this.findOneFromDef('lastBuy', [
this.id,
this.warehouseId,
this.date
]);
}
this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy?.id || this.id]);
if (!this.items.length) throw new UserError(`Empty data source`);
this.date = moment(this.date).format('WW/E');
},
@ -51,8 +52,8 @@ module.exports = {
copies: {
type: Number
},
userId: {
type: Number
typeId: {
type: String
}
}
};

View File

@ -3,7 +3,7 @@
"height": "4.9cm",
"margin": {
"top": "0.17cm",
"right": "0.745cm",
"right": "0.37cm",
"bottom": "0cm",
"left": "0cm"
},

View File

@ -22,7 +22,8 @@ SELECT ROW_NUMBER() OVER() labelNum,
ig.longName,
ig.subName,
i.comment,
w.code buyerName
w.code buyerName,
i.isLaid
FROM vn.buy b
JOIN vn.item i ON i.id = b.itemFk
LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk

View File

@ -1,7 +1,7 @@
html {
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
margin-top: -7px;
margin-left: -6px;
margin-left: -3px;
}
.leftTable {
width: 47%;

View File

@ -74,7 +74,14 @@
<i>Productor:</i> {{item.producerName || item.producerFk}}
</div>
</td>
<td></td>
<td class="center xs-width xs-txt">
<div v-if="item.isLaid && typeId === 'buy'" class="overflow-line black-bg bold">
{{'LAID'}}
</div>
<div v-else class="overflow-line">
{{item.entryFk}}
</div>
</td>
</tr>
<tr>
<td class="sm-width">

View File

@ -5,17 +5,18 @@ const qrcode = require('qrcode');
module.exports = {
name: 'item-label-qr',
async serverPrefetch() {
this.company = await this.findOneFromDef('company', [this.warehouseId]);
if (!this.company)
throw new UserError(`There is no company associated with that warehouse`);
this.date = Date.vnNew();
this.lastBuy = await this.findOneFromDef('lastBuy', [
this.id,
this.warehouseId,
this.date
]);
this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy.id]);
if (this.typeId === 'item') {
this.company = await this.findOneFromDef('company', [this.warehouseId]);
if (!this.company)
throw new UserError(`There is no company associated with that warehouse`);
this.lastBuy = await this.findOneFromDef('lastBuy', [
this.id,
this.warehouseId,
this.date
]);
}
this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy?.id || this.id]);
if (!this.items.length) throw new UserError(`Empty data source`);
this.qr = await this.getQr(this.items[0].buyFk);
this.date = moment(this.date).format('WW/E');
@ -52,6 +53,9 @@ module.exports = {
},
userId: {
type: Number
},
typeId: {
type: String
}
}
};

View File

@ -3,7 +3,7 @@
"height": "4.9cm",
"margin": {
"top": "0.17cm",
"right": "0.6cm",
"right": "0.3cm",
"bottom": "0cm",
"left": "0cm"
},

View File

@ -22,7 +22,8 @@ SELECT ROW_NUMBER() OVER() labelNum,
ig.longName,
ig.subName,
i.comment,
w.code buyerName
w.code buyerName,
i.isLaid
FROM vn.buy b
JOIN vn.item i ON i.id = b.itemFk
LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk