From 70332ced875cd4afaad7c31dc83f863eb1bd1a9f Mon Sep 17 00:00:00 2001
From: lu <123456>
Date: 星期三, 22 十月 2025 09:58:49 +0800
Subject: [PATCH] 排产工单搜索
---
DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs | 133 ++++++++++++++++++++++++++++++-------------
1 files changed, 92 insertions(+), 41 deletions(-)
diff --git a/DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs b/DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs
index e0aefaa..87cea74 100644
--- a/DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs
+++ b/DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs
@@ -6,7 +6,8 @@
using System;
using System.Collections.Generic;
using System.Data;
-using System.Text;
+using System.Drawing;
+using System.Threading.Tasks;
using System.Windows.Forms;
@@ -14,37 +15,16 @@
{
public partial class UcDictionarySelect : DevExpress.XtraEditors.XtraForm
{
- private List<string> lstCheckedKeyID = new List<string>();//閫夋嫨灞�ID闆嗗悎
+ private List<dynamic> lstCheckedKeyID = new List<dynamic>();//閫夋嫨闆嗗悎
string strTitle = "";
string strWhere = "";
- public UcDictionarySelect(string _strTitle, string _strWhere)
+ public UcDictionarySelect(string _strTitle, string _strWhere, string _strMsg = "")
{
InitializeComponent();
- tlMenu.CustomDrawNodeCheckBox += TreeList1_CustomDrawNodeCheckBox;
- getTree();
- tlMenu.OptionsBehavior.Editable = true;
- tlMenu.OptionsSelection.EnableAppearanceFocusedCell = false;
- tlMenu.OptionsSelection.MultiSelect = true;
- tlMenu.OptionsSelection.MultiSelectMode = TreeListMultiSelectMode.CellSelect;
+ lbMsg.Text = _strMsg;
this.strTitle = _strTitle;
this.strWhere = _strWhere;
this.Text = _strTitle;
- btnIn.Click += (s, e) =>
- {
- findOrigin(tlMenu);
- var list = new List<dynamic>();
- foreach (string key in lstCheckedKeyID)
- {
- list.Add(new
- {
- // dicCode = "001",
- dicTxt = key
- });
- };
- UpdateParent?.Invoke(this,
- new UpdateParentEventArgs { DynamicList = list });
- Close();
- };
tlMenu.IndicatorWidth = 50;
tlMenu.CustomDrawNodeIndicator += (s, ee) =>
{
@@ -52,6 +32,64 @@
{
var index = ee.Node.TreeList.GetVisibleIndexByNode(ee.Node);
ee.Info.DisplayText = (index + 1).ToString();
+ }
+ };
+ getTreeAsync();
+ tlMenu.MouseDown += (s, e) =>
+ {
+ TreeListHitInfo hitInfo = tlMenu.CalcHitInfo(new Point(e.X, e.Y));
+ if (hitInfo.HitInfoType == HitInfoType.Cell)
+ {
+ TreeListNode node = hitInfo.Node;
+ if (node != null)
+ {
+ if (node.HasChildren) // 鍙湁褰撹妭鐐规湁瀛愯妭鐐规椂鎵嶈�冭檻灞曞紑鎴栨姌鍙�
+ {
+ if (node.Expanded)
+ {
+ node.Collapse();
+ btnOpen.Text = "鍏ㄩ儴灞曞紑";
+ }
+ else
+ {
+ node.Expand();
+ btnOpen.Text = "鍏ㄩ儴鏀舵嫝";
+ }
+ }
+ }
+ }
+ };
+ tlMenu.CustomDrawNodeCheckBox += TreeList1_CustomDrawNodeCheckBox;
+ btnIn.Click += (s, e) =>
+ {
+ findOrigin(tlMenu);
+ var list = new List<dynamic>();
+ foreach (dynamic key in lstCheckedKeyID)
+ {
+ list.Add(new
+ {
+ dicCode = key.dicCode,
+ dicTxt = key.dicTxt
+ });
+ }
+ ;
+ UpdateParent?.Invoke(this, new UpdateParentEventArgs { DynamicList = list });
+ Close();
+ };
+ btnOpen.Click += (s, e) => {
+
+ if (btnOpen.Text == "鍏ㄩ儴灞曞紑")
+ {
+ tlMenu.ExpandAll();
+ btnOpen.Text = "鍏ㄩ儴鏀舵嫝";
+ return;
+ }
+
+ if (btnOpen.Text == "鍏ㄩ儴鏀舵嫝")
+ {
+ tlMenu.CollapseAll();
+ btnOpen.Text = "鍏ㄩ儴灞曞紑";
+ return;
}
};
}
@@ -73,19 +111,13 @@
e.Handled = true;
}
}
-
- // 鍙�夛細澶勭悊鑺傜偣灞曞紑浜嬩欢锛岀‘淇濆姩鎬佸姞杞界殑瀛愯妭鐐圭敓鏁�
- private void treeList1_BeforeExpand(object sender, BeforeExpandEventArgs e)
- {
- // 鑻ュ瓙鑺傜偣鏄姩鎬佸姞杞界殑锛屽湪姝ゅ鍔犺浇鏁版嵁
- // LoadChildNodes(e.Node);
- }
/// <summary>
/// 璇诲彇鍒楄〃
/// </summary>
- private void getTree()
+ private async Task getTreeAsync()
{
- var pgq = new PageQueryModel(1, 999999, "a.defect_name");
+ string _where = " and 1=1 and a.type1=1 and " + this.strWhere;
+ var pgq = new PageQueryModel(1, 999999, "a.defect_name", "asc", "", _where);
var json = JsonConvert.SerializeObject(pgq);
try
{
@@ -98,17 +130,17 @@
tlMenu.ParentFieldName = "pid";
tlMenu.Tag = "defectName";
tlMenu.EndUpdate();
- this.tlMenu.CollapseAll();
- // tlMenu.OptionsBehavior.Editable = true;
tlMenu.OptionsBehavior.AllowRecursiveNodeChecking = false;
tlMenu.BestFitColumns();
+ tlMenu.CollapseAll();
}
catch (Exception ex)
{
MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
}
+ await Task.Delay(500); // 绛夊緟1000姣锛�1绉掞級
+ tlMenu.CollapseAll();
}
-
#region MyRegion
@@ -120,17 +152,36 @@
{
if (parentNode.Nodes.Count == 0)
{
+ if (parentNode.CheckState == CheckState.Checked)
+ {
+ DataRowView drv = tlMenu.GetDataRecordByNode(parentNode) as DataRowView;//鍏抽敭浠g爜锛屽氨鏄笉鐭ラ亾鏄繖鏍疯幏鍙栨暟鎹�岀籂缁撲簡寰堜箙(楝肩煡閬撳彲浠ヨ浆鎹负DataRowView鍟�)
+ if (drv != null)
+ {
+ string KeyFieldName = (string)drv["defectName"];
+ string dicCode = (string)drv["defectCode"];
+ lstCheckedKeyID.Add(new
+ {
+ dicCode = dicCode,
+ dicTxt = KeyFieldName
+ });
+ }
+ }
return;//閫掑綊缁堟
}
foreach (TreeListNode node in parentNode.Nodes)
{
- if (node.CheckState == CheckState.Checked)
+ if (node.CheckState == CheckState.Checked && parentNode.Nodes.Count == 0)
{
DataRowView drv = tlMenu.GetDataRecordByNode(node) as DataRowView;//鍏抽敭浠g爜锛屽氨鏄笉鐭ラ亾鏄繖鏍疯幏鍙栨暟鎹�岀籂缁撲簡寰堜箙(楝肩煡閬撳彲浠ヨ浆鎹负DataRowView鍟�)
if (drv != null)
{
string KeyFieldName = (string)drv["defectName"];
- lstCheckedKeyID.Add(KeyFieldName);
+ string dicCode = (string)drv["defectCode"];
+ lstCheckedKeyID.Add(new
+ {
+ dicCode = dicCode,
+ dicTxt = KeyFieldName
+ });
}
}
GetCheckedKeyID(node);
@@ -143,7 +194,6 @@
private void findOrigin(DevExpress.XtraTreeList.TreeList tree)
{
this.lstCheckedKeyID.Clear();
-
if (tree.Nodes.Count > 0)
{
foreach (TreeListNode root in tree.Nodes)
@@ -152,7 +202,8 @@
}
}
}
-
#endregion
+
+
}
}
\ No newline at end of file
--
Gitblit v1.9.3