2022-09-22 06:48:29 +00:00
|
|
|
const Component = require(`vn-print/core/component`);
|
2022-11-10 06:48:24 +00:00
|
|
|
const reportBody = new Component('report-body');
|
2019-11-27 15:00:42 +00:00
|
|
|
const reportFooter = new Component('report-footer');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
name: 'campaign-metrics',
|
|
|
|
async serverPrefetch() {
|
2022-09-22 06:48:29 +00:00
|
|
|
this.client = await this.fetchClient(this.id);
|
|
|
|
this.sales = await this.fetchSales(this.id, this.from, this.to);
|
2019-11-27 15:00:42 +00:00
|
|
|
|
|
|
|
if (!this.client)
|
|
|
|
throw new Error('Something went wrong');
|
|
|
|
},
|
|
|
|
methods: {
|
2022-09-22 06:48:29 +00:00
|
|
|
fetchClient(id) {
|
|
|
|
return this.findOneFromDef('client', [id]);
|
2019-11-27 15:00:42 +00:00
|
|
|
},
|
2022-09-22 06:48:29 +00:00
|
|
|
fetchSales(id, from, to) {
|
|
|
|
return this.rawSqlFromDef('sales', [id, from, to]);
|
2019-11-27 15:00:42 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
components: {
|
2022-11-10 06:48:24 +00:00
|
|
|
'report-body': reportBody.build(),
|
2019-11-27 15:00:42 +00:00
|
|
|
'report-footer': reportFooter.build()
|
|
|
|
},
|
|
|
|
props: {
|
2022-09-22 06:48:29 +00:00
|
|
|
id: {
|
2022-10-28 13:53:57 +00:00
|
|
|
type: Number,
|
2022-09-26 11:33:27 +00:00
|
|
|
required: true,
|
|
|
|
description: 'The client id'
|
2019-11-27 15:00:42 +00:00
|
|
|
},
|
|
|
|
from: {
|
2020-06-12 07:18:19 +00:00
|
|
|
required: true
|
2019-11-27 15:00:42 +00:00
|
|
|
},
|
|
|
|
to: {
|
2020-06-12 07:18:19 +00:00
|
|
|
required: true
|
2019-11-27 15:00:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|