提交 69b1ce5a authored 作者: 彭寒菲's avatar 彭寒菲

树形维护

上级 b2d92b14
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LF.K3.SCM.BusinessPlugin
{
//子项
public class ChirdNode
{
public string parentid { get; set; }
public string Name { get; set; }
public string Number { get; set; }
public string text { get; set; }
}
}
......@@ -38,6 +38,7 @@ using Kingdee.K3.MFG.App;
using Kingdee.K3.MFG.BusinessCommon.BillPlugIn;
using Kingdee.K3.MFG.ServiceHelper;
using Kingdee.K3.MFG.ServiceHelper.ENG;
using LF.K3.SCM.BusinessPlugin;
[Description("BOM树形维护")]
[HotUpdate]
......@@ -344,7 +345,6 @@ public class BomTree : AbstractMFGDynamicFormPlugIn
{
BomTreeDatasMger.ToTreeNodeObject();
//mTreeDatasMger.RootNode.;
string id = BomTreeDatasMger.RootNode.children.First().id;
string txt = BomTreeDatasMger.RootNode.children.First().text;
string sql = $@"/*dialect*/with stepCTE AS (
......@@ -375,17 +375,38 @@ inner join stepCTE cte on cte.子项物料=c.f
select stepCTE.*,
case b.FDOCUMENTSTATUS when 'C' then '已审核' else '未审核' end states,
case b.FFORBIDSTATUS when 'B' then '禁用' else '未禁用' end Disables,
case f.FERPCLSID when '2' then '1' when '3' then '1' else '2' end FERPCLSID from stepCTE
case f.FERPCLSID when '2' then '1' when '3' then '1' else '2' end FERPCLSID,w.FNUMBER,l.FNAME from stepCTE
left join t_BD_MaterialBase f on stepCTE.子项物料=f.FMATERIALID
left join T_ENG_BOM b on stepCTE.父项BOMID=b.FID ";
left join T_ENG_BOM b on stepCTE.父项BOMID=b.FID
left join T_BD_MATERIAL w on stepCTE.子项物料=w.FMATERIALID
left join T_BD_MATERIAL_L l on stepCTE.子项物料=l.FMATERIALID ";
DataTable dt = DBServiceHelper.ExecuteDataSet(this.Context, sql).Tables[0];
Dictionary<string, List<string>> Examine = new Dictionary<string, List<string>>();
Dictionary<string, List<string>> Disable = new Dictionary<string, List<string>>();
Dictionary<string, string> sx = new Dictionary<string, string>();
Dictionary<string, List<ChirdNode>> all = new Dictionary<string, List<ChirdNode>>();//所有
Dictionary<string, List<ChirdNode>> Examine = new Dictionary<string, List<ChirdNode>>();//未审核
Dictionary<string, List<ChirdNode>> Disable = new Dictionary<string, List<ChirdNode>>();//禁用
HashSet<string> hs = new HashSet<string>();//自制
for (int i = 0; i < dt.Rows.Count; i++)
{
//所有数据
if (!all.ContainsKey(dt.Rows[i]["父项名称"].ToString()))
{
List<ChirdNode> list = new List<ChirdNode>();
string ID = dt.Rows[i]["父项物料"].ToString();
DataRow[] dr = dt.Select("父项物料='" + ID + "'");
for (int j = 0; j < dr.Length; j++)
{
ChirdNode node = new ChirdNode();
node.parentid=dr[j]["父项物料"].ToString();
node.Name = dr[j]["FNAME"].ToString();
node.Number = dr[j]["FNUMBER"].ToString();
node.text = dr[j]["子项名称"].ToString();
list.Add(node);
}
if (list.Count > 0)
{
all.Add(dt.Rows[i]["父项名称"].ToString(), list);
}
}
//自制委外
if (dt.Rows[i]["FERPCLSID"].ToString() == "1")
{
......@@ -393,7 +414,7 @@ left join T_ENG_BOM b on stepCTE.父项BOMID=b.FID ";
DataRow[] dr = dt.Select("父项物料='" + ID + "'");
if (dr.Length <= 0)
{
sx.Add(dt.Rows[i]["父项名称"].ToString(), dt.Rows[i]["子项名称"].ToString());
hs.Add(dt.Rows[i]["子项名称"].ToString());
}
}
//未审核
......@@ -403,38 +424,49 @@ left join T_ENG_BOM b on stepCTE.父项BOMID=b.FID ";
{
string ID = dt.Rows[i]["父项物料"].ToString();
DataRow[] dr = dt.Select("父项物料='" + ID + "'");
List<string> list = new List<string>();
List<ChirdNode> list = new List<ChirdNode>();
for (int j = 0; j < dr.Length; j++)
{
list.Add(dr[j]["子项名称"].ToString());
ChirdNode node = new ChirdNode();
node.parentid = dr[j]["父项物料"].ToString();
node.Name = dr[j]["FNAME"].ToString();
node.Number = dr[j]["FNUMBER"].ToString();
node.text = dr[j]["子项名称"].ToString();
list.Add(node);
}
if (list.Count > 0)
{
Examine.Add(dt.Rows[i]["父项名称"].ToString(), list);
}
}
//禁用
if (dt.Rows[i]["Disables"].ToString() == "禁用")
}
//禁用
if (dt.Rows[i]["Disables"].ToString() == "禁用")
{
if (!Disable.ContainsKey(dt.Rows[i]["父项名称"].ToString()))
{
if (!Examine.ContainsKey(dt.Rows[i]["父项名称"].ToString()))
string ID = dt.Rows[i]["父项物料"].ToString();
DataRow[] dr = dt.Select("父项物料='" + ID + "'");
List<ChirdNode> list = new List<ChirdNode>();
for (int j = 0; j < dr.Length; j++)
{
string ID = dt.Rows[i]["父项物料"].ToString();
DataRow[] dr = dt.Select("父项物料='" + ID + "'");
List<string> list = new List<string>();
for (int j = 0; j < dr.Length; j++)
{
list.Add(dr[j]["子项名称"].ToString());
}
if (list.Count > 0)
{
Disable.Add(dt.Rows[i]["父项名称"].ToString(), list);
}
ChirdNode node = new ChirdNode();
node.parentid = dr[j]["父项物料"].ToString();
node.Name = dr[j]["FNAME"].ToString();
node.Number = dr[j]["FNUMBER"].ToString();
node.text = dr[j]["子项名称"].ToString();
list.Add(node);
}
if (list.Count > 0)
{
Disable.Add(dt.Rows[i]["父项名称"].ToString(), list);
}
}
}
}
TreeNode treeNodeLst1 = BomTreeDatasMger.RootNode.children.First();
WalkNode1(treeNodeLst1, all, Examine, Disable, hs);
CurSelNodeData = BomTreeDatasMger.FindBomNodeMode(id);
CurTreeView.SetRootNode(BomTreeDatasMger.RootNode);
......@@ -447,6 +479,55 @@ left join T_ENG_BOM b on stepCTE.父项BOMID=b.FID ";
CurTreeView.InvokeControlMethod("ExpandTree");
}
}
private void WalkNode1(TreeNode treeNodeLst, Dictionary<string, List<ChirdNode>> all, Dictionary<string, List<ChirdNode>> Examine, Dictionary<string, List<ChirdNode>> Disable, HashSet<string> hs)
{
if (Examine.ContainsKey(treeNodeLst.text) )
{
treeNodeLst.Forecolor = "#EE0000";
List<TreeNode> nodes = new List<TreeNode>();
var a = Examine[treeNodeLst.text].Count;
for (int i = 0; i < Examine[treeNodeLst.text].Count; i++)
{
TreeNode treeNode = new TreeNode();
treeNode.Number = Examine[treeNodeLst.text][i].Number;
treeNode.Name= Examine[treeNodeLst.text][i].Name;
treeNode.parentid = Examine[treeNodeLst.text][i].parentid;
treeNode.text = Examine[treeNodeLst.text][i].text;
treeNode.id= Examine[treeNodeLst.text][i].Number;
nodes.Add(treeNode);
}
treeNodeLst.children = nodes;
}
if ( Disable.ContainsKey(treeNodeLst.text))
{
treeNodeLst.Forecolor = "#00008B";
List<TreeNode> nodes = new List<TreeNode>();
var a = Disable[treeNodeLst.text].Count;
for (int i = 0; i < Disable[treeNodeLst.text].Count; i++)
{
TreeNode treeNode = new TreeNode();
treeNode.Number = Disable[treeNodeLst.text][i].Number;
treeNode.Name = Disable[treeNodeLst.text][i].Name;
treeNode.parentid = Disable[treeNodeLst.text][i].parentid;
treeNode.text = Disable[treeNodeLst.text][i].text;
nodes.Add(treeNode);
}
treeNodeLst.children = nodes;
}
if ( hs.Contains(treeNodeLst.text))
{
treeNodeLst.Forecolor = "#FF00FF";
}
if (treeNodeLst.children.Count <= 0)
{
return;
}
foreach (TreeNode child in treeNodeLst.children)
{
CurTreeView.InvokeControlMethod("ExpandNode", child.id);
WalkNode1(child,all,Examine,Disable,hs);
}
}
private void WalkNode(TreeView CurTreeView, TreeNode treeNodeLst)
{
......
......@@ -97,6 +97,7 @@
<Compile Include="BOMPrintPlugin.cs" />
<Compile Include="BomTaskFilter.cs" />
<Compile Include="BOMTaskImportPlugin.cs" />
<Compile Include="ChirdNode.cs" />
<Compile Include="DynamicForm.BomTree.cs" />
<Compile Include="ImportDatePlugin.cs" />
<Compile Include="ImportExcelPlugin.cs" />
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论