账表.二开案例.单据联查报表

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

账表.二开案例.单据联查报表

【场景】单据联查报表,在单据界面打开账表,并使用当前单据数据进行过滤 【案例】 场景一: 报表是自定义报表,能够修改代码;或者能够接收传入参数过滤 (1)账表逻辑,能够接收自定义参数的指定字段,修改过滤参数 ![image.webp](/download/0100fa6fd565f47c48109f0b3bb8957a80a8.webp) (2)表单插件逻辑:写入指定字段的值到过滤参数中(也就是对应字段是过滤见面的一个可设置字段) ```csharp SysReportShowParameter rptShowParam = new SysReportShowParameter { FormId = "k6c0443d5529e41079e83a1038d75d6c4", IsShowFilter = false, }; rptShowParam.OpenStyle.ShowType = Kingdee.BOS.Core.DynamicForm.ShowType.MainNewTabPage; rptShowParam.CustomParams["AcctSystemID"] = "100"; this.View.ShowForm(rptShowParam); ``` 不显示过滤界面,传入参数AcctSystemID到服务插件处理 场景二: 报表是非自定义报表,无法直接追加代码,没有接收自定义参数过滤的逻辑, (1)账表逻辑,继承原有报表服务插件生成临时表,先生成原临时表,生成后根据自定义参数再进行过滤 ![Image_20230414201159.webp](/download/010013cb6a45223f480f8f5a30e3da5f3df4.webp) (2)表单插件逻辑:传入自定义的过滤条件 ```csharp using Kingdee.BOS.App.Data; using Kingdee.BOS.Core.Bill.PlugIn; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Core.Report; using System; using System.Collections.Generic; using System.Text; namespace DynamicFormPlugIn.Report { [Kingdee.BOS.Util.HotUpdate] [System.ComponentModel.Description("扩展报表增加自定义过滤")] public class SimpleReportDemoServicePlugIn_Extend : SimpleReportDemoServicePlugIn { public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName) { string filterString = string.Empty; //<0>获取表单打开参数的自定义条件 if (filter.CustomParams != null) { var openParam = filter.CustomParams["OpenParameter"] as Dictionary<string, object>; if (openParam != null && openParam.ContainsKey("Custom_Filter")) { filterString = Convert.ToString(openParam["Custom_Filter"]); } } //<1>没有过滤条件时按照原逻辑处理 if (string.IsNullOrEmpty(filterString)) { base.BuilderReportSqlAndTempTable(filter, tableName); return; } string tmpTableName = null; try { // <2>得到标准报表的数据 tmpTableName = Kingdee.BOS.ServiceHelper.DBServiceHelper.CreateTemporaryTableName(this.Context); base.BuilderReportSqlAndTempTable(filter, tmpTableName); // <3>加入自定义过滤,得到新的报表数据 StringBuilder rptSql = new StringBuilder(); rptSql.AppendLine("/*dialect*/ SELECT billid, FBillNo, FMaterialFNumber,FQty"); rptSql.AppendLine(string.Format(" , {0} INTO {1} FROM {2} WHERE {3}", base.KSQL_SEQ, tableName, tmpTableName, filterString)); DBUtils.Execute(this.Context, rptSql.ToString()); } finally { if (tmpTableName != null) { Kingdee.BOS.ServiceHelper.DBServiceHelper.DeleteTemporaryTableName(this.Context, new string[] { tmpTableName }); } } } } [Kingdee.BOS.Util.HotUpdate] [System.ComponentModel.Description("表单插件,联查这个单据的报表")] public class BillPlugIn_ShowRpt : AbstractBillPlugIn { public string Key_BillNo = "FBillNo"; public override void BarItemClick(BarItemClickEventArgs e) { if (string.Equals(e.BarItemKey, "FShowRpt")) { string billNo = this.View.Model.GetValue(Key_BillNo).ToString(); string filter = string.Format(" FBillNo = '{0}'", billNo); SysReportShowParameter rptShowParam = new SysReportShowParameter { FormId = "k6c0443d5529e41079e83a1038d75d6c4", IsShowFilter = false, }; rptShowParam.OpenStyle.ShowType = Kingdee.BOS.Core.DynamicForm.ShowType.MainNewTabPage; rptShowParam.CustomParams["Custom_Filter"] = filter; this.View.ShowForm(rptShowParam); } } } } ``` 【效果】实现按照传入自定义参数过滤,从单据界面查看与当前单据过滤的报表数据 (1)默认查询全部 ![Image_20230414201342.webp](/download/0100ffebc5ddd3d34231b093e2ebb083fdfe.webp) (2)接收传入参数过滤查询本单 ![image.webp](/download/0100a4a305af92c041c5bffc67de0f14333b.webp) ![image.webp](/download/010090852b8687f64e62a87ecc2e06c7b0da.webp)

账表.二开案例.单据联查报表

【场景】单据联查报表,在单据界面打开账表,并使用当前单据数据进行过滤【案例】场景一: 报表是自定义报表,能够修改代码;或者能够接收...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息