电脑桌面
添加蚂蚁七词文库到电脑桌面
安装后可以在桌面快捷访问

标签打印的开发过程

来源:金蝶云社区作者:金蝶2024-09-1612

标签打印的开发过程

1. 功能 供应商送货单要根据物料的最小包装数量和送货数量,确定批次,每个批次一个数量,每个批次一个标签。 标签打印的模板来回切换很麻烦,所以在打印或预览的时候,不再选择模板。 1. 逻辑 因为单据有多个套打模板,每次需要来回切换,所以通过通过插件实现打印,插件里调用打印服务,插件里重新构造打印数据。 2. 步骤 套打模板设计好标签; BOS设计器在列表和表单里添加上空按钮; 列表插件和表单插件监听按钮的点击事件; 点击事件调用金蝶的打印服务; 重写OnPrepareNotePrintData事件,重构打印数据; 1. 开发 标签设计:打开套打设计器,没用数据表格,只是用布局表格和对应的文本,文本里绑定的动态字段; ![1672305588692.webp](/download/01009c1d36ba193c4f7ca0deb89af6dcb0fe.webp) 添加按钮:。。。。 监听按钮的点击事件: ```C# public override void BarItemClick(BarItemClickEventArgs e) { base.BarItemClick(e); //if条件判断 if (e.BarItemKey.Equals("ZZY_LabelPreview")) { var formId = View.BusinessInfo.GetForm().Id; var templateId = "cd0f5e24-8102-4530-9c4a-0160990d3c8";//供应商送货单 //这个方法获取当前表单所有的模板id,可以监听获取后,在代码里写死 //var templateIdDic= PrintServiceHelper.GetTemplatesByFormId(this.Context, View.BusinessInfo.GetForm().Id); //获取FID var fId = this.View.Model.DataObject["Id"].ToString(); //fId:打印单据id;templateId:套打模板id;formId:表单id,注意不能是扩展的表单,要是未扩展的表单id,上边有获取方法 var printJobs = Generateprintjobs(fId, templateId, formId); /生成打印job var printJobKey=Guid.NewGuid().ToString(); this.View.Session[printJobKey] = printJobs;//任务放入session NoteTemplateoperation(printJobKey,"Preview"); } } ``` 调用金蝶的打印服务: 这个是参考的大佬的帖子: [跳转过去,给他格赞](https://wenku.my7c.com/article/362702335958459648?productLineId=1&isKnowledge=2) ```C# ///<summary>生成打印任务</summary> /// <param name="billId">单据内码</param> /// <param name="templateId">套打模板标识</param> /// <param name="formId”>业务对象标识</param> private List<PrintJob> Generateprintjobs(string billid, string templateid, string formid) { List<PrintJob> result = new List<PrintJob>(); PrintJob printJob = new PrintJob(); printJob.FormId = formid; printJob.PrintJobItems = new List<PrintJobItem>(); printJob.PrintJobItems.Add(new PrintJobItem(billid, templateid)); result.Add(printJob); return result; } ///<summary> /// 打模板的执行操作 /// </summary> /// <param name="printJobId">打印任务ID</param> /// <param name="printType">打的</param> /// <param name="printer">打打的ID</param> public void NoteTemplateoperation(string printJobid, string printType, object printer = null) { JSONObject jsonobj = new JSONObject(); jsonobj.Put("pageID", this.View.PageId); jsonobj.Put("printJobId", printJobid); jsonobj.Put("action", printType); string action = string.Empty; if (printType == "Preview") { action = JSAction.printPreview; } else { action = JSAction.print; } this.View.AddAction(action, jsonobj); } ``` 重写OnPrepareNotePrintData事件: 每个动态字段要注册一下; ```C# public override void OnPrepareNotePrintData(PreparePrintDataEventArgs e) { var metaData = FormMetaDataCache.GetCachedFormMetaData(this.Context, this.View.BillBusinessInfo.GetForm().Id); if (e.NotePrintTplId == "cd0f5e24-8102-4530-9c4a-0160990d3c58") { DynamicObject billObj = this.Model.DataObject; DynamicObject SupplierIdField = billObj["SupplierId"] as DynamicObject; DynamicObject ConfirmerIdField = billObj["ConfirmerId"] as DynamicObject; //动态字段注册赋值 DynamicObjectType dot = e.DataObjects[0].DynamicObjectType;// metaData.BusinessInfo.GetDynamicObjectType(); #region 注册动态字段 if (!dot.Properties.ContainsKey("QRCode")) { dot.RegisterSimpleProperty( "QRCode", typeof(object) ); } if (!dot.Properties.ContainsKey("GoodsCode")) { dot.RegisterSimpleProperty("GoodsCode", typeof(object)); } if (!dot.Properties.ContainsKey("GoodsName")) { dot.RegisterSimpleProperty("GoodsName", typeof(object)); } if (!dot.Properties.ContainsKey("GoodsStandard")) { dot.RegisterSimpleProperty("GoodsStandard", typeof(object)); } if (!dot.Properties.ContainsKey("SupplyName")) { dot.RegisterSimpleProperty("SupplyName", typeof(object)); } if (!dot.Properties.ContainsKey("BanShu")) { dot.RegisterSimpleProperty("BanShu", typeof(object)); } if (!dot.Properties.ContainsKey("SaleOrderCode")) { dot.RegisterSimpleProperty("SaleOrderCode", typeof(object)); } if (!dot.Properties.ContainsKey("PurOrderCode")) { dot.RegisterSimpleProperty("PurOrderCode", typeof(object)); } if (!dot.Properties.ContainsKey("Qty")) { dot.RegisterSimpleProperty("Qty", typeof(object)); } if (!dot.Properties.ContainsKey("ProductDate")) { dot.RegisterSimpleProperty("ProductDate", typeof(object)); } if (!dot.Properties.ContainsKey("ConfirmDate")) { dot.RegisterSimpleProperty("ConfirmDate", typeof(object)); } if (!dot.Properties.ContainsKey("ConfirmUser")) { dot.RegisterSimpleProperty("ConfirmUser", typeof(object)); } if (!dot.Properties.ContainsKey("ConfirmStatus")) { dot.RegisterSimpleProperty("ConfirmStatus", typeof(object)); } if (!dot.Properties.ContainsKey("BillNo")) { dot.RegisterSimpleProperty("BillNo", typeof(object)); } if (!dot.Properties.ContainsKey("BatchNo")) { dot.RegisterSimpleProperty("

标签打印的开发过程

1. 功能供应商送货单要根据物料的最小包装数量和送货数量,确定批次,每个批次一个数量,每个批次一个标签。标签打印的模板来回切换很麻烦...
点击下载文档文档为doc格式

声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

已经是第一篇
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息
QQ群
  • 答案:my7c点击这里加入QQ群
支持邮箱
微信
  • 微信