由于客户物料编码对应表在系统是一个下发的基础资料,而且其内部使用的客户和物料两个基础资料默认是分配型的基础资料,是受组织隔离的基础资料,所以在单据上面携带使用就相对来说不能简单的配置携带就能使用,需要插件处理部分功能,此功能在供应链是个公共的函数处理。贴出相关代码供使用参考。
客户物料对应表在自定义单据上应用,添加自定义客户物料对应编码和名称字段后,后续相关功能的处理:
1.录入客户物料编码,携带对应物料、辅助属性
2.录入物料,携带对应的客户物料编码和名称
3.客户物料对应表的F7结果查询应用单据相关已录入字段的相关的过滤
public override void DataChanged(BOS.Core.DynamicForm.PlugIn.Args.DataChangedEventArgs e)
{
switch (e.Field.Key.ToUpper())
{
case "FMAPID"://客户物料编码
CustomerMaterialMappingArgs args = new CustomerMaterialMappingArgs();
DynamicObject dyCustMatId = this.View.Model.GetValue("FMapId", e.Row) as DynamicObject;
args.CustMatId = dyCustMatId == null ? "" : dyCustMatId["Id"].ToString();
dyMainOrgId = this.View.Model.GetValue("FSaleOrgId") as DynamicObject;
args.MainOrgId = (dyMainOrgId == null ? 0 : Convert.ToInt64(dyMainOrgId["Id"]));
args.NeedOrgCtrl = _baseDataOrgCtl[Kingdee.K3.Core.BD.FormKeyConst.BD_MATERIAL];
args.MaterialIdKey = "FMaterialId";
args.AuxpropIdKey = "FAuxpropId";
args.Row = e.Row;
Common.SetMaterialIdAndAuxpropIdByCustMatId(this, args);
break;
case "FMATERIALID"://物料
DynamicObject dyCustId = this.View.Model.GetValue("FCustId") as DynamicObject;
dySaleOrgId = this.View.Model.GetValue("FSaleOrgId") as DynamicObject;
DynamicObject dyMaterialId = this.View.Model.GetValue("FMaterialId", e.Row) as DynamicObject;
long customerId = (dyCustId == null ? 0 : Convert.ToInt64(dyCustId["Id"]));
saleOrgId = (dySaleOrgId == null ? 0 : Convert.ToInt64(dySaleOrgId["Id"]));
long materialId = (dyMaterialId == null ? 0 : Convert.ToInt64(dyMaterialId["Id"]));
//启用客户物料表参数,则设置客户物料编码信息
if (this.para_UseCustMatMapping)
{
Common.SetRelativeCodeByMaterialId(this, "FMapId", materialId, customerId, saleOrgId, e.Row);
}
break;
}
}
关于其中几个参数变量: _baseDataOrgCtl :基础资料控制类型
public override void OnInitialize(BOS.Core.DynamicForm.PlugIn.Args.InitializeEventArgs e)
{
_baseDataOrgCtl = Common.GetSalBaseDataCtrolType(this.View.Context);
}
///
/// 取启用客户物料对应表参数(按主业务组织)
///
private void GetUseCustMatMappingParamater()
{
DynamicObject mainOrg = this.View.Model.GetValue("FSaleOrgId") as DynamicObject;
if (mainOrg != null)
{
long mainOrgId = Convert.ToInt64(mainOrg["Id"]);
object objUseCustMatMapping = CommonServiceHelper.GetSystemProfile(this.Context, mainOrgId, Kingdee.K3.Core.SCM.SCMFormIdConst.SAL_SystemParameter, Kingdee.K3.Core.SCM.SCMConst.PARAM_USECUSTMATMAPPING, false);
para_UseCustMatMapping = objUseCustMatMapping == null ? false : Convert.ToBoolean(objUseCustMatMapping);
}
}
过滤的处理:
public override void BeforeF7Select(BOS.Core.DynamicForm.PlugIn.Args.BeforeF7SelectEventArgs e)
{
string filter;
switch (e.FieldKey.ToUpperInvariant())
{
case "FMAPID":
saleorg = this.View.Model.GetValue("FSaleOrgId") as DynamicObject;
long orgId = saleorg == null ? 0 : Convert.ToInt64(saleorg["Id"]);
customer = this.View.Model.GetValue("FCustId") as DynamicObject;
custId = customer == null ? 0 : Convert.ToInt64(customer["Id"]);
material = this.View.Model.GetValue("FMaterialId", row) as DynamicObject;
long materialId = material == null ? 0 : Convert.ToInt64(material["Id"]);
filter = Common.GetMapIdFilter(orgId, custId, materialId, _baseDataOrgCtl);
break;
}
}
推荐阅读