8004-liliumStyleRemake #3257
|
@ -1,6 +1,6 @@
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('print', {
|
Self.remoteMethodCtx('labelSupplier', {
|
||||||
description: 'Print stickers of all entries',
|
description: 'Print stickers of all entries',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [
|
accepts: [
|
||||||
|
@ -28,13 +28,13 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
http: {
|
http: {
|
||||||
path: '/:id/print',
|
path: '/:id/labelSupplier',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
accessScopes: ['DEFAULT', 'read:multimedia']
|
accessScopes: ['DEFAULT', 'read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.print = async function(ctx, id, options) {
|
Self.labelSupplier = async function(ctx, id, options) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
|
@ -48,7 +48,8 @@ module.exports = Self => {
|
||||||
for (const buy of buys) {
|
for (const buy of buys) {
|
||||||
if (buy.stickers < 1) continue;
|
if (buy.stickers < 1) continue;
|
||||||
ctx.args.id = buy.id;
|
ctx.args.id = buy.id;
|
||||||
const pdfBuffer = await models.Entry.buyLabel(ctx, myOptions);
|
ctx.args.copies = buy.stickers;
|
||||||
|
const pdfBuffer = await models.Entry.buyLabelSupplier(ctx, myOptions);
|
||||||
await merger.add(new Uint8Array(pdfBuffer[0]));
|
await merger.add(new Uint8Array(pdfBuffer[0]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,8 @@ module.exports = Self => {
|
||||||
require('../methods/entry/addFromPackaging')(Self);
|
require('../methods/entry/addFromPackaging')(Self);
|
||||||
require('../methods/entry/addFromBuy')(Self);
|
require('../methods/entry/addFromBuy')(Self);
|
||||||
require('../methods/entry/buyLabel')(Self);
|
require('../methods/entry/buyLabel')(Self);
|
||||||
require('../methods/entry/print')(Self);
|
require('../methods/entry/labelSupplier')(Self);
|
||||||
|
require('../methods/entry/buyLabelSupplier')(Self);
|
||||||
|
|
||||||
Self.observe('before save', async function(ctx, options) {
|
Self.observe('before save', async function(ctx, options) {
|
||||||
if (ctx.isNewInstance) return;
|
if (ctx.isNewInstance) return;
|
||||||
|
|
Loading…
Reference in New Issue