简单账表快速开发
如果您对开发简单账表步骤还有疑惑,请查看这篇帖子:简单账表开发笔记 (kingdee.com)
思维灵感来自于多个报表需求都是重复的,于是声明了一个实体类,记载了账表上的字段,代码如下:
public class ReportBuildData
{
/// <summary>
/// 序号
/// </summary>
public int ColIndex { get; set; }
/// <summary>
/// 标识
/// </summary>
public string Identity { get; set; }
/// <summary>
/// 字段名称
/// </summary>
public string IdentityName { get; set; }
/// <summary>
/// 是否需要汇总(只有字段类型为String和Int的才汇总)
/// </summary>
public bool IstSummary { get; set; }
/// <summary>
/// 字段类型
/// </summary>
public SqlStorageType FieldType { get; set; }
/// <summary>
/// 可见性
/// </summary>
public bool Visible { get; set; } = true;
}
public List<ReportBuildData> GetReportBuildData()
{
List<ReportBuildData> NewReportData = new List<ReportBuildData>();
int i = 0;
NewReportData.Add(new ReportBuildData() { ColIndex = i++, FieldType = SqlStorageType.SqlInt, Identity = "FIDENTITYID", IdentityName = "序号", IstSummary = false, Visible = false });
NewReportData.Add(new ReportBuildData() { ColIndex = i++, FieldType = SqlStorageType.Sqlnvarchar, Identity = "FSupplier", IdentityName = "供应商单位", IstSummary = false });
NewReportData.Add(new ReportBuildData() { ColIndex = i++, FieldType = SqlStorageType.Sqlnvarchar, Identity = "FPeriod", IdentityName = "期间", IstSummary = false });
NewReportData.Add(new ReportBuildData() { ColIndex = i++, FieldType = SqlStorageType.SqlDecimal, Identity = "FMembranesDeposit", IdentityName = "模具订金", IstSummary = false });
NewReportData.Add(new ReportBuildData() { ColIndex = i++, FieldType = SqlStorageType.SqlDecimal,
NewReportData.Add(new ReportBuildData() { ColIndex = i++, FieldType = SqlStorageType.SqlInt, Identity = "FBillPeriodDays", IdentityName = "账期天数", IstSummary = true });
return NewReportData;
}
那么在GetReportHeaders,GetSummaryColumnInfo方法都不需要再写具体的字段标识,直接调用GetReportBuildData方法即可。
代码如下:
public override ReportHeader GetReportHeaders(IRptParams filter)
{
ReportHeader header = new ReportHeader();
foreach (var item in GetReportBuildData())
{
var Identity = header.AddChild(item.Identity, new LocaleValue(item.IdentityName), item.FieldType);
Identity.ColIndex = item.ColIndex;
Identity.Visible = item.Visible;
}
return header;
}
public override List<SummaryField> GetSummaryColumnInfo(IRptParams filter)
{
var result = base.GetSummaryColumnInfo(filter);
foreach (var item in GetReportBuildData())
{
if (item.IstSummary) result.Add(new SummaryField(item.Identity, Kingdee.BOS.Core.Enums.BOSEnums.Enu_SummaryType.SUM));
}
return result;
}
那么一个简单账表你需求修改的,只有GetReportTitles,BuilderReportSqlAndTempTable方法里的内部逻辑。
同时,如果你采用的是临时表赋值的方式的话,可以采用给row赋值的形式,直接避免了直接写死标识,需要修改的只有 GetReportBuildData方法内你自己的字段标识,即可快速完成一个账表。
row[ReportTitleData[i++].Identity] = "";
row[ReportTitleData[i++].Identity] = "";
注:过滤框的显示隐藏列,需要自己手工添加。
简单账表快速开发
本文2024-09-16 18:31:43发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-22729.html