找回密码
 立即注册

QQ登录

只需一步,快速开始

Lenka.Guo 讲师达人认证 悬赏达人认证
超级版主   /  发表于:2020-6-18 14:02  /   查看:2382  /  回复:0
批量打印无论是在 Web端还是桌面端系统都是非常常见的需求,桌面端可以直接访问打印机系统,可以设置免预览,在后台直接批量打印多个文档。

Web端本身因为安全性设置,无法直接访问本地资源,都需要浏览器的打印预览窗口才可以。
但是有很多客户,尤其是生产制造类或医疗行业,需要大量的报表打印工作。尤其是期望一键打印,如图,每一行数据都是对应的一个报表文件,希望点击一次按钮,就可以实现所有的报表文件打印。

ARJS 提供了无预览打印,但是一次只能打印一个报表,如果要同时打印多个报表,就必须考虑拼接成一个文件了。


实现方法:
使用子报表控件,将多个报表文件拼接成一个主报表, ARJS 提供的子报表,可以在一个报表嵌入其他报表,且可同时使用多个子报表文件。

代码:
  1. <script>
  2.     function load()
  3.     {
  4.             var subreports = ['/reports/SubReport1.rdlx-json', '/reports/SubReport2.rdlx-json', '/reports/SubReport3.rdlx-json'];
  5.             var reportItems = [];
  6.             var subreportTemplate = {
  7.                 "ZIndex": 1,
  8.                 "Type": "subreport",
  9.                 "Top": "",
  10.                 "Width": "6.5in",
  11.                 "Height": "2in",
  12.                 "ReportName": "",
  13.                 "Name": "Subreport"
  14.             };

  15.             //default top position of subreport. Can be any position by default. Also heigh/width can be modified too if necessary
  16.             var topPosition = 0;
  17.             var defaultHeight = 2;

  18.             subreports.forEach((subreport, index) => {
  19.                 var subreportItem = {...subreportTemplate};

  20.                 subreportItem.ReportName = subreport;
  21.                 subreportItem.Name = "Subreport" + index;
  22.                 subreportItem.Top = topPosition + "in";

  23.                 reportItems.push(subreportItem);

  24.                 topPosition = topPosition + defaultHeight;
  25.             });
  26.             
  27.             //fetch doesn't work in IE
  28.             fetch('/reports/MainReport.rdlx-json').then(response => response.json()).then(reportDefinition => {
  29.                 //in case if report is empty at all
  30.                 if(!reportDefinition.Body.ReportItems) reportDefinition.Body.ReportItems = [];
  31.                 reportDefinition.Body.ReportItems.push(...reportItems);
  32.                 const viewer = new ActiveReports.Viewer('#ARJSviewerDiv');
  33.                 viewer.open(reportDefinition);
  34.                 console.log(reportDefinition);
  35.             });
  36.         }
  37.    
  38. </script>
复制代码
项目代码如附件



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

评分

参与人数 1满意度 +5 收起 理由
huozige666 + 5 活字格7.0的报表也是这样吗?

查看全部评分

0 个回复

您需要登录后才可以回帖 登录 | 立即注册
返回顶部