36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
define([
|
|
'knockout',
|
|
'viewmodels/report',
|
|
'templates/views/report-templates/export-pdf-report.htm'
|
|
], function(ko, ReportViewModel, exportPdfReportTemplate) {
|
|
return ko.components.register('export-pdf-report', {
|
|
viewModel: function(params) {
|
|
params.configKeys = [];
|
|
var self = this;
|
|
|
|
ReportViewModel.apply(this, [params]);
|
|
|
|
//console.log('Params:', params);
|
|
this.anexarUbic = ko.observable(false);
|
|
this.anexarImagenes = ko.observable(false);
|
|
this.anexarPdfs = ko.observable(false);
|
|
const boolToStr = (bool) => bool ? "1" : "0";
|
|
|
|
self.resourceId = ko.observable(
|
|
params.report?.report_json?.resourceinstanceid || null
|
|
);
|
|
|
|
self.exportPDF = function() {
|
|
var id = self.resourceId();
|
|
if (id) {
|
|
var url = '/export/pdf/' + id + '/' + boolToStr(self.anexarUbic()) + '/' + boolToStr(self.anexarImagenes()) + '/' + boolToStr(self.anexarPdfs()) + '/';
|
|
window.open(url, '_blank');
|
|
} else {
|
|
alert('No se encontró el ID del recurso.');
|
|
}
|
|
};
|
|
},
|
|
template: exportPdfReportTemplate,
|
|
});
|
|
});
|