From 9e0ab17d472935629d11689891e5cfe564bdd774 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 16 Oct 2019 08:39:45 +0200 Subject: [PATCH] removed prefetch --- print/lib/reportEngine.js | 21 ++++++++------------- print/report/rpt-receipt/index.js | 17 +++++++++-------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/print/lib/reportEngine.js b/print/lib/reportEngine.js index 8c771c449..c95779592 100644 --- a/print/lib/reportEngine.js +++ b/print/lib/reportEngine.js @@ -2,7 +2,6 @@ const Vue = require('vue'); const VueI18n = require('vue-i18n'); const renderer = require('vue-server-renderer').createRenderer(); const fs = require('fs-extra'); -// const pdf = require('phantom-html2pdf'); const pdf = require('html-pdf'); const juice = require('juice'); @@ -23,25 +22,21 @@ module.exports = { */ async render(name, ctx) { const component = require(`${this.path}/${name}`); - const result = await this.preFetch(component, ctx); + const i18n = new VueI18n({ locale: 'es', fallbackLocale: 'es', silentTranslationWarn: true }); const app = new Vue({i18n, - render: h => h(result.component)}); + render: h => h(component)}); + + Vue.set(component, 'test', 'asd1'); return renderer.renderToString(app); }, - /** - * Prefetch all component data from asyncData method - * - * @param {Object} orgComponent - Component object - * @param {Object} ctx - Request context - */ - async preFetch(orgComponent, ctx) { + /* async preFetch(orgComponent, ctx) { let component = Object.create(orgComponent); let mergedData = {}; let asyncData = {}; @@ -87,9 +82,9 @@ module.exports = { } return {component}; - }, + }, */ - async attachAssets(component) { + /* async attachAssets(component) { const localePath = `${this.path}/${component.name}/locale`; const templatePath = `${this.path}/${component.name}/index.html`; const stylePath = `${this.path}/${component.name}/assets/css/index`; @@ -100,7 +95,7 @@ module.exports = { component.i18n = require(localePath); component.template = juice.inlineContent(template, css, cssOptions); - }, + }, */ async toPdf(name, ctx) { const html = await this.render(name, ctx); diff --git a/print/report/rpt-receipt/index.js b/print/report/rpt-receipt/index.js index 7a173e6ee..a4f04ad34 100755 --- a/print/report/rpt-receipt/index.js +++ b/print/report/rpt-receipt/index.js @@ -4,12 +4,12 @@ const UserException = require(`${appPath}/lib/exceptions/userException`); module.exports = { name: 'rpt-receipt', - /* serverPrefetch() { - console.log(arguments); - return new Promise(accept => { - this.client = this.getReceipt(); - }); - }, */ + serverPrefetch() { + console.log(this.test); + /* return new Promise(accept => { + this.client = this.fetchClient(); + }); */ + }, async asyncData(ctx, params) { Object.assign(this, this.methods); @@ -22,8 +22,8 @@ module.exports = { return {client, receipt}; }, created() { - if (this.client.locale) - this.$i18n.locale = this.client.locale; + /* if (this.client.locale) + this.$i18n.locale = this.client.locale; */ const embeded = []; this.files.map(file => { @@ -68,4 +68,5 @@ module.exports = { 'report-header': require('../report-header'), 'report-footer': require('../report-footer'), }, + template: '
asd
' };