本方法主要实现检验单上二开增加下拉列表绑定使用决策枚举值时,如何与使用决策表体使用决策可选择项一致,即根据业务类型来区分,本例以在检验项目表体增加下拉列表为例:
1、检验单检验项目表体增加下拉列表类型字段,绑定使用决策枚举;
2、二开表单插件继承BaseControlEdit,挂在检验单表单插件列表的最后;
3、二开示例代码如下:
using Kingdee.BOS.Core.Metadata.FieldElement;
using Kingdee.BOS.Core.SqlBuilder;
using Kingdee.K3.Core.MFG;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.ServiceHelper;
using Kingdee.K3.Core.MFG.EntityHelper;
using Kingdee.BOS;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
namespace Kingdee.K3.MFG.QM.Business.PlugIn.Bill
{
public class test : BaseControlEdit
{
public override void EntityRowClick(BOS.Core.DynamicForm.PlugIn.Args.EntityRowClickEventArgs e)
{
base.EntityRowClick(e);
switch (e.Key.ToUpperInvariant())
{
case "FITEMDETAIL"://此处为增加的二开下拉列表字段所在的单据体标识大写形式
string businessType = this.View.Model.GetValue<string>(CONST_QM_InspectBill.CONST_FBillHead.KEY_FBusinessType);
this.setOtherPolicyItemsByBusType(businessType,e.Row);
break;
}
}
/// <summary>
/// 根据业务类型获取使用决策
/// </summary>
/// <param name="businessTypeId"></param>
private void setOtherPolicyItemsByBusType(string businessTypeId, int row)
{
//使用策略处理
ComboField useItemField = this.View.BusinessInfo.GetField("FTestPolicy") as ComboField;//此处为二开增加的枚举下拉列表字段的标识
DynamicObject useItemFieldObj = useItemField.EnumObject;
IEnumerable<DynamicObject> items = useItemFieldObj.GetDynamicValue<DynamicObjectCollection>("Items") .OrderBy(g => g.GetDynamicValue<int>("Seq")).ToList();
List<DynamicObject> useItems = new List<DynamicObject>();
//获取汇总模型预插
QueryBuilderParemeter param = new QueryBuilderParemeter();
param.FormId = MFGFormIdConst.SubSys_QM.PolicyQtySumModel;
param.SelectItems = SelectorItemInfo.CreateItems(
CONST_QM_PolicyQtySumModel.CONST_FBillHead.KEY_FQCBusinessType,
CONST_QM_PolicyQtySumModel.CONST_FEntity.KEY_FUsePolicy);
DynamicObjectCollection policyObjs = QueryServiceHelper.GetDynamicObjectCollection(this.View.Context, param);
List<string> otherBTIds = policyObjs .Where(w => w.GetDynamicValue<string>(CONST_QM_PolicyQtySumModel.CONST_FBillHead.KEY_FQCBusinessType) == businessTypeId)
.Select(s => s.GetDynamicValue<string>(CONST_QM_PolicyQtySumModel.CONST_FEntity.KEY_FUsePolicy)).Distinct().ToList();
useItems = items.Where(w => otherBTIds.Contains(w.GetDynamicValue<string>("Value"))).ToList();
List<EnumItem> matchPolicys = new List<EnumItem>();
foreach (DynamicObject item in useItems)
{
matchPolicys.Add(new EnumItem
{
Value = item.GetDynamicValue<string>("Value"),
Caption = item.GetDynamicValue<LocaleValue>("Caption"),
Seq = item.GetDynamicValue<int>("Seq")
});
}
//获取字段编辑器,设置新的下拉列表
ComboFieldEditor cfe = this.View.GetFieldEditor<ComboFieldEditor>("FTestPolicy", row);//此处为二开增加的枚举下拉列表字段的标识
cfe.SetComboItems(matchPolicys);
}
public override void AfterCreateNewEntryRow(BOS.Core.DynamicForm.PlugIn.Args.CreateNewEntryEventArgs e)
{
base.AfterCreateNewEntryRow(e);
switch (e.Entity.Key)
{
case "FItemDetail"://此处为增加的二开下拉列表字段所在的单据体标识
string businessType = this.View.Model.GetValue<string>(CONST_QM_InspectBill.CONST_FBillHead.KEY_FBusinessType);
this.setOtherPolicyItemsByBusType(businessType,e.Row);
break;
}
}
}
}
推荐阅读