二开 列表颜色标识-后台加载所需的关键条件字段
**列表颜色格式化要起效果,关键(条件)字段一定要手工勾选,显示列表界面,很不理想,下为插件自动加载相关关键(条件)字段的示例,供需要的人员参考:**
==***1. Python:***==
```language
#【列表插件】列表条件格式化-根据业务状态进行颜色标识
import clr
clr.AddReference('mscorlib')
from System import *
def AfterCreateSqlBuilderParameter(e):
if e.sqlBuilderParameter.SelectedFieldKeys.Contains("FStatus") != True:
e.sqlBuilderParameter.SelectedFieldKeys.Add("FStatus");
def OnFormatRowConditions(args):
try:
fStatus=args.DataRow.DynamicObject["FStatus"];
fcStatus = FormatCondition()
if fStatus=='1' :#计划
fcStatus.BackColor = "#FF00FF"
if fStatus=='2':# 计划确认
fcStatus.BackColor = "#FAFAD2"
if fStatus=='3' :#下达
fcStatus.BackColor = "#00FFFF"
if fStatus=='4' :#开工
fcStatus.BackColor = "#EEE8AA"
if fStatus=='5' :#完工
fcStatus.BackColor = "#E0FFFF"
if fStatus=='6' or fStatus=='7':#结案/结算
fcStatus.BackColor = "#DCDCDC"
if fStatus=='1' :
fcStatus.Key='FStatus' #添加下句时,表示只格式化指定的字段,无此句或空时则格式化整行
else:
fcStatus.Key='';
args.FormatConditions.Add(fcStatus);
except:
pass
```
***==2. C#:==***
```language
using Kingdee.BOS;
using Kingdee.BOS.Core.List.PlugIn;
using Kingdee.BOS.Core.List.PlugIn.Args;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Util;
using System.ComponentModel;
using System.Drawing;
namespace Hjt.Kingdee.PlugIn
{
[HotUpdate]//不重启iis进行调试
[Description("【列表插件】列表颜色格式化-基础资料\单据列表通用")]
public class BasicInformationFormatRow : AbstractListPlugIn
{
public override void AfterCreateSqlBuilderParameter(SqlBuilderParameterArgs e)
{
base.AfterCreateSqlBuilderParameter(e);
dynamic billElements = this.ListModel.BillBusinessInfo.Elements;//取所有元素数据包
//循环元素实体数据包业务冻结
foreach (var element in billElements)
{
string name = element.Name.ToString();//
if (name.Contains("数据状态") || name.Contains("禁用状态") || name.Contains("单据状态") || name.Contains("作废状态") || name.Contains("终止状态") || name.Contains("关闭状态") || name.Contains("业务冻结"))
{
try{
if (e.sqlBuilderParameter.SelectedFieldKeys.Contains(element.Key) != true)//元素字段列表中无此字段时,进行添加
{
e.sqlBuilderParameter.SelectedFieldKeys.Add(element.Key);
}
}
catch{
}
}
}
}
//格式化
public override void OnFormatRowConditions(ListFormatConditionArgs args)
{
//必备基础
base.OnFormatRowConditions(args);
try
{
var dataRow = ((DynamicObjectDataRow)args.DataRow).DynamicObject;//防止无此字段出错
string formName = this.View.BillBusinessInfo.GetForm().Name;
if (dataRow.DynamicObjectType.Properties.ContainsKey("FDOCUMENTSTATUS"))//防止无此字段出错
{
string zd = args.DataRow["FDOCUMENTSTATUS"].ToString();
if (zd != "C" || zd !="2")
{
FormatCondition fSocumentStatus = new FormatCondition();
switch (zd)
{
case "B"://审核中 蓝字
fSocumentStatus.ForeColor = ColorTranslator.ToHtml(System.Drawing.Color.Blue);//
break;
case "Z"://暂存 黄字(模糊看不清且刺眼,以提醒操作员及时处理)
case "0":
fSocumentStatus.ForeColor = ColorTranslator.ToHtml(System.Drawing.Color.Yellow);
break;
case "A"://创建 红字
case "1":
case "D"://重新审核
fSocumentStatus.ForeColor = ColorTranslator.ToHtml(System.Drawing.Color.Red);
break;
}
fSocumentStatus.ApplayRow = false;
args.FormatConditions.Add(fSocumentStatus);
}
}
// 冻结状态
if (dataRow.DynamicObjectType.Properties.ContainsKey("FMrpFreezeStatus"))//防止无此字段出错
{
if (args.DataRow["FMrpFreezeStatus"].ToString() == "B")//业务冻结
{
FormatCondition fMrpFreezeStatus = new FormatCondition();
fMrpFreezeStatus.BackColor = ColorTranslator.ToHtml(System.Drawing.Color.Orange);
fMrpFreezeStatus.ApplayRow = false;
args.FormatConditions.Add(fMrpFreezeStatus);
}
}
// 禁用状态 --单据 A否B是
if (dataRow.DynamicObjectType.Properties.ContainsKey("FFORBIDSTATUS"))//防止无此字段出错
{
//禁用状态(整行)
if (args.DataRow["FFORBIDSTATUS"].ToString() == "B")
{
var fForbidStatus = new FormatCondition();
fForbidStatus.BackColor = ColorTranslator.ToHtml(System.Drawing.Color.Gainsboro);
fForbidStatus.ApplayRow = false;
args.FormatConditions.Add(fForbidStatus);
}
}
// 作废/终止状态
if (dataRow.DynamicObjectType.Properties.ContainsKey("FCANCELSTATUS") )//防止无此字段出错
{
if (args.DataRow["FCANCELSTATUS"].ToString() != "A" || args.DataRow["FCANCELSTATUS"].ToString() == "1" )
{
FormatCondition fCancelStatus = new FormatCondition();
fCancelStatus.BackColor = ColorTranslator.ToHtml(System.Drawing.Color.Gainsboro);
fCancelStatus.ApplayRow = false;
args.FormatConditions.Add(fCancelStatus);
}
}
// 终止状态
if ( dataRow.DynamicObjectType.Properties.ContainsKey("FMRPTERMINATESTATUS"))//防止无此字段出错
{
if ( args.DataRow["FMRPTERMINATESTATUS"].ToString() != "A")
{
FormatCondition fMrpTerminateStatus = new FormatCondition();
fMrpTerminateStatus.BackColor = ColorTranslator.ToHtml(System.Drawing.Color.Gainsboro);
fMrpTerminateStatus.ApplayRow = false;// true为格式化整行
args.FormatConditions.Add(fMrpTerminateStatus);
}
}
//关闭状态
if (dataRow.DynamicObjectType.Properties.ContainsKey("FCLOSESTATUS") )//防止无此字段出错
{
if (args.DataRow["FCLOSESTATUS"].ToString() == "B" )
{
FormatCondition fCloseStatus = new FormatCondition();
fCloseStatus.BackColor = ColorTranslator.ToHtml(System.Drawing.Color.LightCyan);
fCloseStatus.ApplayRow = false;
args.FormatConditions.Add(fCloseStatus);
}
}
//关闭状态
if ( dataRow.DynamicObjectType.Properties.ContainsKey("FMRPCLOSESTATUS"))//防止无此字段出错
{
if ( args.DataRow["FMRPCLOSESTATUS"].ToString() == "B")
{
FormatCondition fMrpCloseStatus = new FormatCondition();
fMrpCloseStatus.BackColor = ColorTranslator.ToHtml(System.Drawing.Color.LightCyan);
fMrpCloseStatus.ApplayRow = false;
args.FormatConditions.Add(fMrpCloseStatus);
}
}
}
catch
{
}
}
}
}
```
二开 列表颜色标识-后台加载所需的关键条件字段
**列表颜色格式化要起效果,关键(条件)字段一定要手工勾选,显示列表界面,很不理想,下为插件自动加载相关关键(条件)字段的示例,供需要...
点击下载文档
本文2024-09-16 18:31:03发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-22655.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章