单据行背景色设置Python实现原创
金蝶云社区-邱育华
邱育华
14人赞赏了该文章 2508次浏览 未经作者许可,禁止转载编辑于2022年10月12日 09:52:19

单据行背景色设置Python实现


BOS中可以针对单据行某一列的值判断,设置分录行颜色标记,具体参考文章

【单据列表设置满足条件的行带颜色显示】


但是该方法有一个局限,只能设置一个条件,如果需要一个明细行同时满足多个条件,则只能通过二开插件去设置了


下面以采购订单为例,订单状态为未关闭,且累计入库数量小于采购数量(未入库完) 的分录行有颜色标记


# 表单插件: PythonEntrySetColor 行背景色设置
import clr 
clr.AddReference("System")
clr.AddReference("Kingdee.BOS.Core")
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
def AfterBindData(e):
    grid = this.View.GetControl[EntryGrid]("FPOOrderEntry")
    closeStatus = this.View.Model.GetValue("FCloseStatus")
    entity = this.View.BusinessInfo.GetEntity("FPOOrderEntry")
    rowCount = this.Model.GetEntryRowCount("FPOOrderEntry")
    for i in range (0, rowCount):
        dyRow = this.Model.GetEntityDataObject(entity, i)
        fQty = dyRow["Qty"]
        fStockInQty = dyRow["StockInQty"]
        if fQty > fStockInQty and closeStatus == 'A':
            grid.SetRowBackcolor("#FFFF00", i) #设置整行背景颜色


表单设置背景色.jpg


# 列表插件:PythonListetColor
import clr 
clr.AddReference("System")
clr.AddReference("Kingdee.BOS.Core")
from Kingdee.BOS.Core.List.PlugIn.Args import *
from Kingdee.BOS.Core.Metadata import *
def OnFormatRowConditions(e):
    if e.DataRow.ColumnContains("FQty") and e.DataRow.ColumnContains("FStockInQty") and e.DataRow.ColumnContains("FCloseStatus"):
        fc = FormatCondition()
        fQty = e.DataRow["FQty"]
        fStockInQty = e.DataRow["FStockInQty"]
        if e.DataRow["FCloseStatus"] == "A" and fQty > fStockInQty:
            fc.BackColor = "#FFFF00"
            fc.ApplayRow = True  # 应用于整行
            e.FormatConditions.Add(fc)


列表设置背景色.jpg


赞 14