From 33cc4a3325a9ae10de122bce143c87873db8387f Mon Sep 17 00:00:00 2001 From: luoxingjian <1010378449@qq.com> Date: Tue, 7 Jan 2025 17:25:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=AE=B3=E7=B1=BB=E5=9E=8B=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8A=A0=E7=AD=9B=E9=80=89=E5=A4=8D=E9=80=89=E6=A1=86?= =?UTF-8?q?=EF=BC=8C=E7=AD=9B=E9=80=89=E6=9C=89=E9=A1=B9=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=AE=B3=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PEIS/Model/ReportModel.cs | 1 + PEIS/Model/Setting/HazardTypeModel.cs | 5 ++ PEIS/View/Setting/HazardTypeForm.Designer.cs | 55 +++++++++++--- PEIS/View/Setting/HazardTypeForm.cs | 77 +++++++++++++++++++- PEIS/View/Setting/HazardTypeForm.resx | 3 - 5 files changed, 125 insertions(+), 16 deletions(-) diff --git a/PEIS/Model/ReportModel.cs b/PEIS/Model/ReportModel.cs index 921620f..547027d 100644 --- a/PEIS/Model/ReportModel.cs +++ b/PEIS/Model/ReportModel.cs @@ -60,6 +60,7 @@ namespace PEIS.Model a.Contactor1, a.Contactor2, a.Address1, + a.JobStatus, a.Tel1, a.CardNo, COALESCE(a.OrgName, a.Company) AS OrgName, diff --git a/PEIS/Model/Setting/HazardTypeModel.cs b/PEIS/Model/Setting/HazardTypeModel.cs index 992ae1a..4c0c972 100644 --- a/PEIS/Model/Setting/HazardTypeModel.cs +++ b/PEIS/Model/Setting/HazardTypeModel.cs @@ -17,6 +17,11 @@ namespace PEIS.Model.Setting { return DAOHelp.GetDataBySQL("Select * From vi_FeeItem"); } + public List GetAlredlyHFItem() + { + var result = DAOHelp.GetDataBySQL($@"SELECT HID AS ID FROM Dict_HTypeFItem group by HID"); + return result == null ? new List() : result; + } public List GetHTypeFItem(Int64 hId) { return DAOHelp.GetDataBySQL($@"SELECT diff --git a/PEIS/View/Setting/HazardTypeForm.Designer.cs b/PEIS/View/Setting/HazardTypeForm.Designer.cs index 412ab37..6953b9c 100644 --- a/PEIS/View/Setting/HazardTypeForm.Designer.cs +++ b/PEIS/View/Setting/HazardTypeForm.Designer.cs @@ -37,6 +37,8 @@ this.trSort = new DevExpress.XtraTreeList.Columns.TreeListColumn(); this.trStandard = new DevExpress.XtraTreeList.Columns.TreeListColumn(); this.trDescribe = new DevExpress.XtraTreeList.Columns.TreeListColumn(); + this.panel5 = new System.Windows.Forms.Panel(); + this.chBoxHaveItem = new System.Windows.Forms.CheckBox(); this.panel2 = new System.Windows.Forms.Panel(); this.opMenuHdType = new PEIS.View.UControl.OpMenu(); this.label2 = new System.Windows.Forms.Label(); @@ -82,6 +84,7 @@ this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.treeList1)).BeginInit(); + this.panel5.SuspendLayout(); this.panel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.gCHFeelItem)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.gVHFeelItem)).BeginInit(); @@ -103,6 +106,7 @@ // this.splitContainer1.Panel1.AutoScroll = true; this.splitContainer1.Panel1.Controls.Add(this.treeList1); + this.splitContainer1.Panel1.Controls.Add(this.panel5); this.splitContainer1.Panel1.Controls.Add(this.panel2); // // splitContainer1.Panel2 @@ -124,11 +128,11 @@ this.trStandard, this.trDescribe}); this.treeList1.Dock = System.Windows.Forms.DockStyle.Fill; - this.treeList1.Location = new System.Drawing.Point(0, 46); + this.treeList1.Location = new System.Drawing.Point(0, 72); this.treeList1.Name = "treeList1"; this.treeList1.OptionsMenu.EnableColumnMenu = false; this.treeList1.OptionsView.AutoWidth = false; - this.treeList1.Size = new System.Drawing.Size(266, 697); + this.treeList1.Size = new System.Drawing.Size(266, 671); this.treeList1.TabIndex = 1; // // trID @@ -225,6 +229,30 @@ this.trDescribe.VisibleIndex = 3; this.trDescribe.Width = 200; // + // panel5 + // + this.panel5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel5.Controls.Add(this.chBoxHaveItem); + this.panel5.Dock = System.Windows.Forms.DockStyle.Top; + this.panel5.Location = new System.Drawing.Point(0, 46); + this.panel5.Name = "panel5"; + this.panel5.Size = new System.Drawing.Size(266, 26); + this.panel5.TabIndex = 2; + // + // chBoxHaveItem + // + this.chBoxHaveItem.AutoSize = true; + this.chBoxHaveItem.Dock = System.Windows.Forms.DockStyle.Left; + this.chBoxHaveItem.Location = new System.Drawing.Point(0, 0); + this.chBoxHaveItem.Margin = new System.Windows.Forms.Padding(0); + this.chBoxHaveItem.Name = "chBoxHaveItem"; + this.chBoxHaveItem.Padding = new System.Windows.Forms.Padding(15, 0, 0, 0); + this.chBoxHaveItem.Size = new System.Drawing.Size(138, 24); + this.chBoxHaveItem.TabIndex = 0; + this.chBoxHaveItem.Text = "仅显示配置有项目"; + this.chBoxHaveItem.UseVisualStyleBackColor = true; + this.chBoxHaveItem.CheckedChanged += new System.EventHandler(this.chBoxHaveItem_CheckedChanged); + // // panel2 // this.panel2.Controls.Add(this.opMenuHdType); @@ -289,10 +317,12 @@ this.gVHFeelItem.GridControl = this.gCHFeelItem; this.gVHFeelItem.Name = "gVHFeelItem"; this.gVHFeelItem.OptionsMenu.EnableColumnMenu = false; + this.gVHFeelItem.OptionsView.ColumnAutoWidth = false; this.gVHFeelItem.OptionsView.ShowGroupPanel = false; this.gVHFeelItem.OptionsView.ShowPreviewRowLines = DevExpress.Utils.DefaultBoolean.False; this.gVHFeelItem.OptionsView.ShowVerticalLines = DevExpress.Utils.DefaultBoolean.False; - this.gVHFeelItem.ViewCaption = "关联项目"; + this.gVHFeelItem.OptionsView.ShowViewCaption = true; + this.gVHFeelItem.ViewCaption = "项目"; // // gridColumn1 // @@ -351,7 +381,7 @@ this.FeeItemName2.OptionsFilter.AllowFilter = false; this.FeeItemName2.Visible = true; this.FeeItemName2.VisibleIndex = 0; - this.FeeItemName2.Width = 174; + this.FeeItemName2.Width = 150; // // FeeItemCode2 // @@ -365,6 +395,7 @@ this.FeeItemCode2.OptionsFilter.AllowFilter = false; this.FeeItemCode2.Visible = true; this.FeeItemCode2.VisibleIndex = 1; + this.FeeItemCode2.Width = 64; // // ItemClass2 // @@ -378,7 +409,7 @@ this.ItemClass2.OptionsFilter.AllowFilter = false; this.ItemClass2.Visible = true; this.ItemClass2.VisibleIndex = 2; - this.ItemClass2.Width = 46; + this.ItemClass2.Width = 60; // // SettlePrice2 // @@ -392,7 +423,7 @@ this.SettlePrice2.OptionsFilter.AllowFilter = false; this.SettlePrice2.Visible = true; this.SettlePrice2.VisibleIndex = 3; - this.SettlePrice2.Width = 46; + this.SettlePrice2.Width = 56; // // Price2 // @@ -406,7 +437,7 @@ this.Price2.OptionsFilter.AllowFilter = false; this.Price2.Visible = true; this.Price2.VisibleIndex = 4; - this.Price2.Width = 46; + this.Price2.Width = 40; // // Unit2 // @@ -420,7 +451,7 @@ this.Unit2.OptionsFilter.AllowFilter = false; this.Unit2.Visible = true; this.Unit2.VisibleIndex = 5; - this.Unit2.Width = 46; + this.Unit2.Width = 40; // // UnitName2 // @@ -434,7 +465,7 @@ this.UnitName2.OptionsFilter.AllowFilter = false; this.UnitName2.Visible = true; this.UnitName2.VisibleIndex = 6; - this.UnitName2.Width = 46; + this.UnitName2.Width = 40; // // DeptName2 // @@ -448,7 +479,7 @@ this.DeptName2.OptionsFilter.AllowFilter = false; this.DeptName2.Visible = true; this.DeptName2.VisibleIndex = 7; - this.DeptName2.Width = 63; + this.DeptName2.Width = 400; // // panel3 // @@ -754,6 +785,8 @@ ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); this.splitContainer1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.treeList1)).EndInit(); + this.panel5.ResumeLayout(false); + this.panel5.PerformLayout(); this.panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.gCHFeelItem)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.gVHFeelItem)).EndInit(); @@ -818,5 +851,7 @@ private DevExpress.XtraTreeList.Columns.TreeListColumn trStandard; private DevExpress.XtraTreeList.Columns.TreeListColumn trDescribe; private FastReport.DevComponents.DotNetBar.ContextMenuBar contextMenuBar1; + private System.Windows.Forms.Panel panel5; + private System.Windows.Forms.CheckBox chBoxHaveItem; } } \ No newline at end of file diff --git a/PEIS/View/Setting/HazardTypeForm.cs b/PEIS/View/Setting/HazardTypeForm.cs index 02defef..a13899e 100644 --- a/PEIS/View/Setting/HazardTypeForm.cs +++ b/PEIS/View/Setting/HazardTypeForm.cs @@ -4,6 +4,7 @@ using DevExpress.XtraTreeList.Nodes; using PEIS.Base; using PEIS.Entity; using PEIS.Event; +using PEIS.Model.Setting; using PEIS.Presenter; using PEIS.Utils; using System; @@ -71,6 +72,7 @@ namespace PEIS.View.Setting }); } #region 接害类型 + public bool haveItem_CheckBox = false; private void TreeList1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) @@ -120,8 +122,6 @@ namespace PEIS.View.Setting LoadHazardType(); } } - - public void LoadHazardType() { GetHazardTypeItem?.Invoke(this,new Args()); @@ -129,7 +129,70 @@ namespace PEIS.View.Setting public event EventHandler> GetHazardTypeItem; public void ShowHazardTypeItem(List hazardTypes) { - Invoke(new Action(() => { treeList1.DataSource = null; treeList1.DataSource = hazardTypes;})); + if (haveItem_CheckBox) + { + var alredlyHFItem = new HazardTypeModel().GetAlredlyHFItem(); + if (alredlyHFItem.Count > 0 && hazardTypes != null && hazardTypes.Count > 0) + { + var pHazardType = new List();//父 + GethazardTypeParent(hazardTypes, null, ref pHazardType); + + var alredlyIds = alredlyHFItem.Select(p => p.ID).ToList(); + var alredlyItems = hazardTypes.Where(p => alredlyIds.Contains(p.ID)).ToList(); + var alredlyPid = hazardTypes.Select(p => p.ParentID).ToList(); + + var sHazardType = new List(); + GethazardTypeParent2(pHazardType, alredlyItems, ref sHazardType); + sHazardType.AddRange(alredlyItems); + Invoke(new Action(() => { treeList1.DataSource = null; treeList1.DataSource = sHazardType; })); + } + else { + Invoke(new Action(() => { treeList1.DataSource = null;})); + } + } + else { + Invoke(new Action(() => { treeList1.DataSource = null; treeList1.DataSource = hazardTypes;})); + } + } + + public void GethazardTypeParent2(List source, List dicts, ref List pList) + { + foreach (var item in dicts) + { + var p= source.Where(o => o.ID == item.ParentID).ToList(); + if (p != null && p.Count > 0) + { + var one = p.FirstOrDefault(); + if (pList.Where(s => s.ID == one.ID).FirstOrDefault() == null) + { + pList.Add(one); + } + GethazardTypeParent2(source, p, ref pList); + } + } + } + + public void GethazardTypeParent(List source, Int64? id,ref List pList) + { + var nodes=source.Where(p => p.ParentID == id).ToList(); + if (nodes.Count>0) + { + if (id == null) + { + pList.AddRange(nodes); + } + else { + var parent = source.Where(p => p.ID == id).FirstOrDefault(); + if (pList.Where(p=>p.ID== parent.ID).FirstOrDefault()==null) + { + pList.Add(parent); + } + } + foreach (var item in nodes) + { + GethazardTypeParent(source, item.ID,ref pList); + } + } } private void TstbKey_TextChanged(object sender, EventArgs e) { @@ -151,6 +214,12 @@ namespace PEIS.View.Setting { LoadHTypeFItem(); } + private void chBoxHaveItem_CheckedChanged(object sender, EventArgs e) + { + var checkBox = sender as CheckBox; + haveItem_CheckBox = checkBox.Checked; + LoadHazardType(); + } #endregion #region 检查项目 //FeeItemModel @@ -266,5 +335,7 @@ namespace PEIS.View.Setting { return new HazardTypePresenter(this); } + + } } diff --git a/PEIS/View/Setting/HazardTypeForm.resx b/PEIS/View/Setting/HazardTypeForm.resx index 11cedf8..1af7de1 100644 --- a/PEIS/View/Setting/HazardTypeForm.resx +++ b/PEIS/View/Setting/HazardTypeForm.resx @@ -117,7 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - \ No newline at end of file