Angular 10的JSReport新功能



我正在使用Angular 10,并希望将JSReport集成到我的程序中以打印报告(pdf(。对于JSReport,我已经设置了服务器,创建了一个示例报告,并使用"poster"对其进行了测试,一切正常。Angular已经下载(npm安装jsreport浏览器客户端dist(然后出现以下代码:

grdInvoiceMToolbarPrint() {
this.ProSvr.GetRpInvoice(this.AuthSvr.branchID, "INV5000000050").subscribe((rMsg: ResponseMessage) => {
this.rpInvoice = [];
this.rpInvoice = (rMsg.data as RpInvoice[]);
const request = {
'template': { "name": "invoice" },
'data': JSON.stringify(this.rpInvoice)
};

//this.jsreport.serverUrl = this.ProSvr.urlReport;
//this.jsreport.headers['Authorization'] = 'Basic ' + btoa('admin:password');

// this.jsreport.renderAsync(request).then(function(res) {
//   const html = '<html>' +
//           '<style>html,body {padding:0;margin:0;} iframe {width:100%;height:100%;border:0}</style>' +
//           '<body>' +
//           '<iframe type="application/pdf" src="' +  res.toDataURI() + '"></iframe>' +
//           '</body></html>';
//   const a = window.open('about:blank', 'Report');
//   a.document.write(html);
//   a.document.close();
// });

console.log(JSON.stringify(this.rpInvoice));
});
}

我已经看过文件了https://jsreport.net/learn/browser-client,但不要提及任何内容。到目前为止,由于没有定义"this.jsreport",我无法继续,请帮助!

import * as jsReport from 'jsreport-browser-client-dist';
...
...
grdInvoiceMToolbarPrint() {
this.Svr.GetRpInvoice(this.AuthSvr.branchID, "INV5000000050").subscribe((rMsg: ResponseMessage) => {
this.rpInvoice = [];
this.rpInvoice = (rMsg.data as RpInvoice[]);
const request = {
'template': { "name": "invoice" },
'data': JSON.stringify(this.rpInvoice)
};
jsReport.serverUrl = this.Svr.urlReport;
jsReport.renderAsync(request).then(function(res) {
window.open(res.toDataURI())
});
});

}

***导入*为jsReport XXXXXXX可以更改为导入*为abcXyz XXXXXXXX

最新更新