原始反馈:制单人凭证录入的时候金额为负值时显示是红色,但是其他用户查询这张凭证的时候点击凭证后,不显示红色。
这个问题可以参照了论坛的相关帖子:
Python脚本实现单据体背景色及字段前景色设置【分享】
实现效果:
Python代码:
[code]clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.DataEntity')
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
from Kingdee.BOS.Orm.DataEntity import *
def AfterBindData(e):
entity = this.View.BillBusinessInfo.GetEntity('FEntity');
objCollection =this.View.Model.GetEntityDataObject(entity);
grid =this.View.GetControl('FEntity');
for index in range(len(objCollection)):
obj = objCollection[index];
valDebit = obj["Debit"];
valCredit = obj['FCredit'];
if valDebit is not None and valDebit <0:
grid.SetForecolor("FDebit","#FF0000", index);#需要设置字段标识Key
if valCredit is not None and valCredit <0:
grid.SetForecolor("FCredit","#FF0000", index);#需要设置字段标识Key[/code]C#插件代码(C#插件这里用的是采购订单,不过大同小异):
[code] public override void AfterBindData(EventArgs e)
{
base.AfterBindData(e);
Entity entityPOOrder = this.View.BillBusinessInfo.GetEntity("FPOOrderEntry");
DynamicObjectCollection objCollection = this.View.Model.GetEntityDataObject(entityPOOrder);
var grid = this.View.GetControl
for (int i = 0; i < objCollection.Count; i++)
{
if (objCollection[i]["Qty"] != null)
{
object objQty = objCollection[i]["Qty"];
decimal decimalQty;
if (decimal.TryParse(objQty.ToString(), out decimalQty))
{
if (decimalQty > 50)
{
grid.SetForecolor("FQty", "#FF0000", i);
}
else
{
grid.SetForecolor("FQty", "#000000", i);
}
}
}
}
}[/code]
推荐阅读