lu
2025-06-13 05edfed06b8aff908c5b8b3037ea2f3a8f8ba8c6
DevApp/Gs.DevApp/UserControl/UcDictionarySelect.cs
@@ -6,7 +6,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Windows.Forms;
@@ -14,31 +13,31 @@
{
    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)
        {
            InitializeComponent();
            tlMenu.CustomDrawNodeCheckBox += TreeList1_CustomDrawNodeCheckBox;
            getTree();
            tlMenu.OptionsBehavior.Editable = true;
            tlMenu.OptionsSelection.EnableAppearanceFocusedCell = false;
            tlMenu.OptionsSelection.MultiSelect = true;
            tlMenu.OptionsSelection.MultiSelectMode = TreeListMultiSelectMode.CellSelect;
            this.strTitle = _strTitle;
            this.strWhere = _strWhere;
            this.Text = _strTitle;
            getTree();
            tlMenu.CustomDrawNodeCheckBox += TreeList1_CustomDrawNodeCheckBox;
            //  tlMenu.OptionsBehavior.Editable = true;
            tlMenu.OptionsSelection.EnableAppearanceFocusedCell = false;
            //  tlMenu.OptionsSelection.MultiSelect = true;
            // tlMenu.OptionsSelection.MultiSelectMode = TreeListMultiSelectMode.CellSelect;
            btnIn.Click += (s, e) =>
            {
                findOrigin(tlMenu);
                var list = new List<dynamic>();
                foreach (string key in lstCheckedKeyID)
                foreach (dynamic key in lstCheckedKeyID)
                {
                    list.Add(new
                    {
                        //  dicCode = "001",
                        dicTxt = key
                        dicCode = key.dicCode,
                        dicTxt = key.dicTxt
                    });
                };
                UpdateParent?.Invoke(this, new UpdateParentEventArgs { DynamicList = list });
@@ -84,7 +83,8 @@
        /// </summary>
        private void getTree()
        {
            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
            {
@@ -101,6 +101,7 @@
                //  tlMenu.OptionsBehavior.Editable = true;
                tlMenu.OptionsBehavior.AllowRecursiveNodeChecking = false;
                tlMenu.BestFitColumns();
                tlMenu.ExpandAll();
            }
            catch (Exception ex)
            {
@@ -125,20 +126,30 @@
                    if (drv != null)
                    {
                        string KeyFieldName = (string)drv["defectName"];
                        lstCheckedKeyID.Add(KeyFieldName);
                        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;//关键代码,就是不知道是这样获取数据而纠结了很久(鬼知道可以转换为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);