有时候需要对单据类型字段的值进行控制,比如直接给单据类型字段设置指定的值,或者控制单据类型下拉列表的可选数据范围,此需求需要编写单据插件,对字段枚举集合进行一定的处理,如:
public override void BeforeBindData(EventArgs e)
{
判断执行条件,比如下推和选单不执行
if ((this.View.OpenParameter.Status == OperationStatus.ADDNEW && this.View.OpenParameter.CreateFrom == CreateFrom.Push) || this.View.OpenParameter.CreateFrom == CreateFrom.Draw)
{
BillTypeField billTypeField = this.View.Model.BusinessInfo.GetBillTypeField();
ComboFieldEditor editor = this.View.GetFieldEditor<ComboFieldEditor>(billTypeField.Key, 0);
List<EnumItem> items = billTypeField.BuildEnumList();
List<EnumItem> listItems = new List<EnumItem>();
foreach(var item in items)
{
listItems.Add(new EnumItem(new DynamicObject(EnumItem.EnumItemType)) { EnumId = item.EnumId, Value = item.Value, Caption = item.Caption });
}
editor.SetComboItems(listItems);
this.Model.SetValue(billTypeField.Key, "单据类型内码", 0);
}
.............
}
推荐阅读