二开案例.简单账表.多级表头
**【应用场景】**
在简单账表设置多级表头。
**【案例演示】**
<1>编写账表服务器插件,代码如下。
``` csharp
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Contracts.Report;
using Kingdee.BOS.Core.Report;
using Kingdee.BOS.Util;
using System.Collections.Generic;
using System.ComponentModel;
namespace Kingdee.BOS.PlugInTest
{
/// <summary>
/// 【账表服务器插件】简单账表
/// </summary>
[Description("【账表服务器插件】简单账表多级表头"), HotUpdate]
public class EasyReportPlugIn : SysReportBaseService
{
/// <summary>
/// 插件初始化
/// </summary>
public override void Initialize()
{
base.Initialize();
// 简单账表类型:普通、树形、分页
this.ReportProperty.ReportType = ReportType.REPORTTYPE_NORMAL;
// 报表名称
this.ReportProperty.ReportName = new LocaleValue("简单账表测试", base.Context.UserLocale.LCID);
// 是否由插件创建临时表
this.IsCreateTempTableByPlugin = true;
// 报表列是否通过UI设计
this.ReportProperty.IsUIDesignerColumns = false;
// 报表是否支持分组汇总
this.ReportProperty.IsGroupSummary = true;
// 是否锁定表格列
this.ReportProperty.SimpleAllCols = false;
// 单据主键:两行FID相同,则为同一单的两条分录,单据编号可以不重复显示
this.ReportProperty.PrimaryKeyFieldName = "FID";
// 报表是否默认只现实合计和明细数据
this.ReportProperty.IsDefaultOnlyDspSumAndDetailData = true;
// 设置精度控制
List<DecimalControlField> list = new List<DecimalControlField>();
// 数量
list.Add(new DecimalControlField
{
ByDecimalControlFieldName = "FQty",
DecimalControlFieldName = "FUnitPrecision"
});
// 单价
list.Add(new DecimalControlField
{
ByDecimalControlFieldName = "FTAXPRICE",
DecimalControlFieldName = "FPRICEDIGITS"
});
// 金额
list.Add(new DecimalControlField
{
ByDecimalControlFieldName = "FALLAMOUNT",
DecimalControlFieldName = "FAMOUNTDIGITS"
});
this.ReportProperty.DecimalControlFieldList = list;
}
/// <summary>
/// 获取报表列头
/// </summary>
/// <param name="filter"></param>
/// <returns></returns>
public override ReportHeader GetReportHeaders(IRptParams filter)
{
ReportHeader header = base.GetReportHeaders(filter);
var header1 = header.AddChild("F1", new LocaleValue("一级表头1"));
// 单据编号
var billNo = header1.AddChild("FBillNo", new LocaleValue("单据编号"));
billNo.ColIndex = 0;
// 状态
var status = header1.AddChild("FDocumentStatus", new LocaleValue("状态"));
status.ColIndex = 1;
// 物料
var material = header1.AddChild("FMaterialName", new LocaleValue("物料"));
material.ColIndex = 2;
var header2 = header.AddChild("F1", new LocaleValue("一级表头2"));
// 数量
var qty = header2.AddChild("FQty", new LocaleValue("数量"), SqlStorageType.SqlDecimal);
qty.ColIndex = 3;
// 单位
var unit = header2.AddChild("FUnitName", new LocaleValue("单位"));
unit.ColIndex = 4;
// 含税价
var price = header2.AddChild("FTAXPRICE", new LocaleValue("含税价"), SqlStorageType.SqlDecimal);
price.ColIndex = 5;
// 价税合计
var amount = header2.AddChild("FALLAMOUNT", new LocaleValue("价税合计"), SqlStorageType.SqlDecimal);
amount.ColIndex = 6;
amount.Visible = true;
return header;
}
/// <summary>
/// 构建报表SQL和临时表
/// </summary>
/// <param name="filter"></param>
/// <param name="tableName"></param>
public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
{
base.BuilderReportSqlAndTempTable(filter, tableName);
// 拼接过滤条件 : filter
// 略
// 默认排序字段:需要从filter中取用户设置的排序字段
string seqFld = string.Format(base.KSQL_SEQ, " t0.FID ");
// 取数SQL
// FID, FEntryId, 编号、状态、物料、数量、单位、单位精度、单价、价税合计
string sql = string.Format(@"/*dialect*/
select t0.FID, t1.FENTRYID
,t0.FBILLNO
,t0.FDate
,t0.FDOCUMENTSTATUS
,t2.FLOCALCURRID
,ISNULL(t20.FPRICEDIGITS,4) AS FPRICEDIGITS
,ISNULL(t20.FAMOUNTDIGITS,2) AS FAMOUNTDIGITS
,t1.FMATERIALID
,t1M_L.FNAME as FMaterialName
,t1.FQTY
,t1u.FPRECISION as FUnitPrecision
,t1U_L.FNAME as FUnitName
,t1f.FTAXPRICE
,t1f.FALLAMOUNT
,{0}
into {1}
from T_PUR_POORDER t0
inner join T_PUR_POORDERFIN t2 on (t0.FID = t2.FID)
left join T_BD_CURRENCY t20 on (t2.FLOCALCURRID = t20.FCURRENCYID)
inner join T_PUR_POORDERENTRY t1 on (t0.FID = t1.FID)
left join T_BD_MATERIAL_L t1M_L on (t1.FMATERIALID = t1m_l.FMATERIALID and t1M_L.FLOCALEID = 2052)
inner join T_PUR_POORDERENTRY_F t1F on (t1.FENTRYID = t1f.FENTRYID)
left join T_BD_UNIT t1U on (t1f.FPRICEUNITID = t1u.FUNITID)
left join T_BD_UNIT_L t1U_L on (t1U.FUNITID = t1U_L.FUNITID and t1U_L.FLOCALEID = 2052) ",
seqFld,
tableName);
DBUtils.ExecuteDynamicObject(this.Context, sql);
}
}
}
```
<2>拷贝插件组件到应用站点的WebSite\Bin目录下,重启IIS。
<3>注册插件。
![注册插件.webp](/download/0100528ce799adad45e69ee7c7618d15a182.webp)
<4>现在可以登业务站点,验证一下结果。
![结果.webp](/download/010093c1819967ff41d2902c83f969a78d6d.webp)
二开案例.简单账表.多级表头
**【应用场景】**在简单账表设置多级表头。**【案例演示】**<1>编写账表服务器插件,代码如下。``` csharpusing Kingdee.BOS.App.Data;us...
点击下载文档
本文2024-09-16 18:10:21发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-20412.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章