多选基础资料字段不支持基础资料属性,因此无法像基础资料一样查看多选基础资料字段的属性值。
需求:在物料清单正查套打BOM版本的基础资料属性,但是由于BOM版本是多选基础资料,目前无法打印;
变通方案:通过通过DataChanged事件,携带多选基础资料的首项到基础资料上,再利用基础资料字段配置基础资料属性;
配置部分(配置一个同类型基础资料):
表单插件:C#
public class SamplePlugIn : AbstractDynamicFormPlugIn
{
private const string SrcMulBaseDataFieldKey = "FBomVersion";
private const string TgtBaseDataFieldKey = "FPrintBase";
public override void DataChanged(DataChangedEventArgs e)
{
if (e.Field == null)
return;
if (e.Field.Key.EqualsIgnoreCase(SrcMulBaseDataFieldKey))
{
var objCol = this.View.Model.GetValue(SrcMulBaseDataFieldKey) as DynamicObjectCollection;
if (objCol == null || objCol.Count == 0 || objCol[0] == null)
{
this.View.Model.SetValue(TgtBaseDataFieldKey, null);
this.View.UpdateView(TgtBaseDataFieldKey);
return;
}
string propKey = objCol[0].DynamicObjectType.Name + "_Id";
if (objCol[0].DynamicObjectType.Properties.ContainsKey(propKey))
{
object pkVal = objCol[0][propKey];
this.View.Model.SetValue(TgtBaseDataFieldKey, pkVal);
}
else
{
this.View.Model.SetValue(TgtBaseDataFieldKey, null);
}
this.View.UpdateView(TgtBaseDataFieldKey);
}
}
}
python插件:
import clr
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.App')
clr.AddReference('Kingdee.BOS.DataEntity')
from Kingdee.BOS import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
from System import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.App.Data import *
def DataChanged(e):
if e.Field == None:
return;
srcFieldKey = 'FBomVersion';
tgtFieldKey = 'FPrintBase';
if not e.Field.Key.Equals(srcFieldKey,StringComparison.OrdinalIgnoreCase):
return;
objCol = this.View.Model.GetValue(srcFieldKey);
if objCol == None or objCol.Count == 0 or objCol[0] == None:
this.View.Model.SetValue(tgtFieldKey,None);
this.View.UpdateView(tgtFieldKey);
return;
propKey = objCol[0].DynamicObjectType.Name+'_Id';
if objCol[0].DynamicObjectType.Properties.ContainsKey(propKey):
pkVal = objCol[0][propKey];
this.View.Model.SetValue(tgtFieldKey,pkVal);
else:
this.View.Model.SetValue(tgtFieldKey,null);
this.View.UpdateView(tgtFieldKey);
推荐阅读