This commit is contained in:
parent
6e5728eead
commit
96becec9d3
|
@ -0,0 +1,9 @@
|
||||||
|
module.exports = class NotFoundError extends Error {
|
||||||
|
constructor(message = 'Not found', code = 'NOT_FOUND', ...translateArgs) {
|
||||||
|
super(message);
|
||||||
|
this.name = 'NotFoundError';
|
||||||
|
this.statusCode = 404;
|
||||||
|
this.code = code;
|
||||||
|
this.translateArgs = translateArgs;
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,22 @@
|
||||||
|
const Component = require(`vn-print/core/component`);
|
||||||
|
const reportHeader = new Component('report-header');
|
||||||
|
const reportFooter = new Component('report-footer');
|
||||||
|
const reportBody = new Component('report-body');
|
||||||
|
const NotFoundError = require('vn-loopback/util/not-found-error');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
components: {
|
||||||
|
'report-body': reportBody.build(),
|
||||||
|
'report-header': reportHeader.build(),
|
||||||
|
'report-footer': reportFooter.build()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
checkMainEntity: function(entity) {
|
||||||
|
if (entity == null)
|
||||||
|
throw new NotFoundError();
|
||||||
|
},
|
||||||
|
dated: function(filters, date, format) {
|
||||||
|
return filters.date(date, format);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
|
@ -23,7 +23,6 @@ class Report extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
async toPdfStream() {
|
async toPdfStream() {
|
||||||
try {
|
|
||||||
const template = await this.render();
|
const template = await this.render();
|
||||||
const defaultOptions = Object.assign({}, config.pdf);
|
const defaultOptions = Object.assign({}, config.pdf);
|
||||||
|
|
||||||
|
@ -57,9 +56,6 @@ class Report extends Component {
|
||||||
resolve(stream);
|
resolve(stream);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch (e) {
|
|
||||||
console.log('ERROR CATCHED:', e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue