套打.二开案例.重复打印多份

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-23浏览:1

套打.二开案例.重复打印多份

【场景】套打重复打印多份 【案例】采购订单,根据输入的打印份数重复打印多份(两个方案) 方案一:完全根据生成的纸张生成多份,不支持节纸 方案二:针对行数据生成多次 ```csharp using Kingdee.BOS.Core.Bill.PlugIn; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Core.NotePrint; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.Util; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DynamicFormPlugIn.NotePrint { [Kingdee.BOS.Util.HotUpdate] [System.ComponentModel.Description("套打 重复份数打印")] public class NotePrintRepearPlugIn : AbstractBillPlugIn { private int RepearVersion = 0; public override void BarItemClick(BarItemClickEventArgs e) { RepearVersion = 0; if (string.Equals(e.BarItemKey, "tb_CustomPreviewV1", StringComparison.OrdinalIgnoreCase)) { RepearVersion = 1; this.View.InvokeFormOperation("PrintPreview"); return; } if (string.Equals(e.BarItemKey, "tb_CustomPreviewV2", StringComparison.OrdinalIgnoreCase)) { RepearVersion = 2; this.View.InvokeFormOperation("PrintPreview"); return; } } /// <summary> /// 方案一:套打打印任务干预事件,复制生成多个打印任务 /// 缺点:打印任务之间不支持合并在一个纸张 /// </summary> /// <param name="e"></param> public override void BeforeNotePrintCommand(BeforeNotePrintEventArgs e) { if (RepearVersion != 1) return; RepearVersion = 0; //重复份数 int repactCount = GetRepeatCnt(); List<PrintJob> newPrintJobs = new List<PrintJob>(); foreach (var oldPrintJob in e.PrintJobs) { if (oldPrintJob == null) continue; if(oldPrintJob.IsEconomizePaper) { //节纸不处理 newPrintJobs.Add(oldPrintJob); continue; } foreach (var oldJobItem in oldPrintJob.PrintJobItems) { if (oldJobItem == null) continue; //对一个单据重复多次打印 PrintJob economizeJob = new PrintJob() { FormId = oldPrintJob.FormId, PrintJobItems = new List<PrintJobItem>(), }; for (int i = 0; i < repactCount; ++i) { economizeJob.PrintJobItems.Add(new PrintJobItem(oldJobItem.BillId, oldJobItem.TemplateId)); } newPrintJobs.Add(economizeJob); } } e.PrintJobs = newPrintJobs; } /// <summary> /// 方案二:套打干预数据包事件,拷贝多份打印 /// 能够支持合并在一个纸张输出,等价于输出1行明细的时候变为输出X行明细,每一行都是一样的 /// 缺点:<1>只支持一个实体的重复 /// <2>合并之后不支持打印子实体了,原因是每一行的内码一样,系统识别为明细没有变化, /// 子实体也就没法处理,只能在这个事件里面把数据也带出来 /// </summary> /// <param name="e"></param> public override void OnPrepareNotePrintData(PreparePrintDataEventArgs e) { if (string.Equals(e.DataSourceId, "FPOOrderEntry", StringComparison.OrdinalIgnoreCase)) { if (RepearVersion != 2) return; RepearVersion = 0; int repeatCnt = GetRepeatCnt(); List<DynamicObject> notePrintObjs = new List<DynamicObject>(); foreach (var rowObj in e.DataObjects) { for (int i = 0; i < repeatCnt; ++i) { //重复加入多次这一行 notePrintObjs.Add(rowObj); } } e.DataObjects = notePrintObjs.ToArray(); } } /// <summary> /// 重复份数 /// </summary> /// <returns></returns> private int GetRepeatCnt() { //return 5; return ObjectUtils.Object2Int(this.View.Model.GetValue("F_BHR_Count")); } } } ``` 【效果】 方案一:生成多份纸张 ![image.webp](/download/0100cfaa7d64d2434c0994618b0c16a30025.webp) ![Image_20230420195443.webp](/download/0100f174c826389a425d9b655fefb30c29fe.webp) 方案二:重复打印实体数据多次 ![image.webp](/download/0100c52cf394d2d14202922cbe7872820cb0.webp) ![image.webp](/download/010081407eb3ef85402d928f6dad82d0e83f.webp)

套打.二开案例.重复打印多份

【场景】套打重复打印多份【案例】采购订单,根据输入的打印份数重复打印多份(两个方案)方案一:完全根据生成的纸张生成多份,不支持节纸...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息