diff --git a/插件库/Lskj.ProductSched/FrmProductSched.Designer.cs b/插件库/Lskj.ProductSched/FrmProductSched.Designer.cs index 5587f6f..6348077 100644 --- a/插件库/Lskj.ProductSched/FrmProductSched.Designer.cs +++ b/插件库/Lskj.ProductSched/FrmProductSched.Designer.cs @@ -33,8 +33,8 @@ namespace Lskj.ProductiSched this.splitMainControl = new DevExpress.XtraEditors.SplitContainerControl(); this.splitLeftControl = new DevExpress.XtraEditors.SplitContainerControl(); this.pltopmain = new DevExpress.XtraEditors.PanelControl(); - this.treebandGcTop = new Lskj.Control.TreeBandedGridControlEx(); this.bandGcTop = new Lskj.Control.BandedGridControlEx(); + this.treebandGcTop = new Lskj.Control.TreeBandedGridControlEx(); this.pl_mainSearch = new DevExpress.XtraEditors.PanelControl(); this.pl_search = new DevExpress.XtraEditors.PanelControl(); this.flowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); @@ -111,17 +111,6 @@ namespace Lskj.ProductiSched this.pltopmain.Size = new System.Drawing.Size(997, 320); this.pltopmain.TabIndex = 22; // - // treebandGcTop - // - this.treebandGcTop.AdapterObj = null; - this.treebandGcTop.Dock = System.Windows.Forms.DockStyle.Fill; - this.treebandGcTop.Location = new System.Drawing.Point(0, 0); - this.treebandGcTop.Margin = new System.Windows.Forms.Padding(4); - this.treebandGcTop.Name = "treebandGcTop"; - this.treebandGcTop.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; - this.treebandGcTop.Size = new System.Drawing.Size(997, 320); - this.treebandGcTop.TabIndex = 19; - // // bandGcTop // this.bandGcTop.AdapterObj = null; @@ -133,6 +122,17 @@ namespace Lskj.ProductiSched this.bandGcTop.Size = new System.Drawing.Size(997, 320); this.bandGcTop.TabIndex = 17; // + // treebandGcTop + // + this.treebandGcTop.AdapterObj = null; + this.treebandGcTop.Dock = System.Windows.Forms.DockStyle.Fill; + this.treebandGcTop.Location = new System.Drawing.Point(0, 0); + this.treebandGcTop.Margin = new System.Windows.Forms.Padding(4); + this.treebandGcTop.Name = "treebandGcTop"; + this.treebandGcTop.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.treebandGcTop.Size = new System.Drawing.Size(997, 320); + this.treebandGcTop.TabIndex = 19; + // // pl_mainSearch // this.pl_mainSearch.Appearance.BackColor = System.Drawing.Color.Transparent; diff --git a/插件库/Lskj.ProductSched/FrmProductSched.cs b/插件库/Lskj.ProductSched/FrmProductSched.cs index e2b35a3..58ca011 100644 --- a/插件库/Lskj.ProductSched/FrmProductSched.cs +++ b/插件库/Lskj.ProductSched/FrmProductSched.cs @@ -140,6 +140,7 @@ namespace Lskj.ProductiSched //构建树表格 if (TreeMultiHeader)//若为多表头树表格模式 { + treebandGcTop.Expansion = "3"; treebandGcTop.Model = DataModel.TopSysModel; treebandGcTop.moduleModel = DataModel.TopModuleModel; treebandGcTop.SetEditColumns(DataModel.TopGridColumns, GridCustomColumnStruct.BaseMainGridView + DataModel.TopModuleModel.FormKey); @@ -282,25 +283,33 @@ namespace Lskj.ProductiSched private void OnTreeListShowingEditor(object sender, CancelEventArgs e) { TreeList treeList = sender as TreeList; + string bj_tig = treeList.FocusedNode.GetValue("bj_tig")?.ToString() ?? ""; if (treeList == null || treeList.FocusedNode == null) return; - - string billDocumentId = treeList.FocusedNode.GetValue(DataModel.TopModuleModel.ParmaryKey)?.ToString() ?? ""; - DateTime date; - if (DataModel.columnDateMapping.TryGetValue(treeList.FocusedColumn, out date)) + if (bj_tig == "0") { - string columnName = date.ToString("yyyy-MM-dd"); - // 检查该行的 billdocument_id 是否在字典中 - if (DataModel.nonEditableCells.ContainsKey(billDocumentId)) + e.Cancel = true; // 取消编辑,单元格变灰 + } + else + { + string billDocumentId = treeList.FocusedNode.GetValue(DataModel.TopModuleModel.ParmaryKey)?.ToString() ?? ""; + DateTime date; + if (DataModel.columnDateMapping.TryGetValue(treeList.FocusedColumn, out date)) { - HashSet showDays = DataModel.nonEditableCells[billDocumentId]; - - // 如果列名(日期)在 showday_list 里,则禁用编辑 - if (showDays.Contains(columnName)) + string columnName = date.ToString("yyyy-MM-dd"); + // 检查该行的 billdocument_id 是否在字典中 + if (DataModel.nonEditableCells.ContainsKey(billDocumentId)) { - e.Cancel = true; // 取消编辑,单元格变灰 + HashSet showDays = DataModel.nonEditableCells[billDocumentId]; + + // 如果列名(日期)在 showday_list 里,则禁用编辑 + if (showDays.Contains(columnName)) + { + e.Cancel = true; // 取消编辑,单元格变灰 + } } } } + } /// @@ -310,12 +319,13 @@ namespace Lskj.ProductiSched /// private void OnBtnSaveClick(object sender, EventArgs e) { - if (SaveGridRecord()) + if (!string.IsNullOrEmpty(DataModel.TopModuleModel.MenuTable)) { - if (SaveDatePlanRecord()) - { - DataModel.TopSearchObj.ButtonObj.PerformClick(); - } + SaveGridRecord(); + } + if (SaveDatePlanRecord()) + { + DataModel.TopSearchObj.ButtonObj.PerformClick(); } } /// @@ -642,7 +652,7 @@ namespace Lskj.ProductiSched DateTime dateTime = labelDateEdit.TextEdit.DateTime; DataRow focusedRow = bandGcTop.BandedView.GetFocusedDataRow(); DataTable dataDayPlan = gcRight.GridControl.DataSourceTable().Copy(); - UpdateRowWithDayPlan(focusedRow, dataDayPlan, dateTime); + if (DataModel.TopModuleModel.HasReport)UpdateRowWithDayPlan(focusedRow, dataDayPlan, dateTime); } } } @@ -694,7 +704,7 @@ namespace Lskj.ProductiSched // 更新行数据逻辑 DateTime dateTime = labelDateEdit.TextEdit.DateTime; DataTable dataDayPlan = gcRight.GridControl.DataSourceTable().Copy(); - UpdateRowWithDayPlan(rowItem, dataDayPlan, dateTime); + if (DataModel.TopModuleModel.HasReport) UpdateRowWithDayPlan(rowItem, dataDayPlan, dateTime); } } } @@ -773,7 +783,7 @@ namespace Lskj.ProductiSched { foreach (TreeListColumn treeListColumn in band.Columns) { - allWidth += treeListColumn.Width; + if(treeListColumn.Visible) allWidth += treeListColumn.Width; } } @@ -842,7 +852,30 @@ namespace Lskj.ProductiSched } } } - + /// + /// 记录展开的节点 + /// + public void GetTreeExpanded() + { + DataModel.treeListNodes.Clear(); + foreach (TreeListNode n in this.treebandGcTop.TreeListObj.Nodes) + { + setRecursive(n); + } + } + /// + /// 递归进行遍历节点 + /// + /// + public void setRecursive(TreeListNode treeNode) + { + if (treeNode.Expanded) DataModel.treeListNodes.Add(treeNode); + // Visit each node recursively. + foreach (TreeListNode tn in treeNode.Nodes) + { + setRecursive(tn); + } + } /// /// 搜索条件绑定完成后 /// @@ -915,7 +948,7 @@ namespace Lskj.ProductiSched { dataMain = treebandGcTop.GetGridViewDataSource().Copy(); dataDetail = treebandGcTop.GetGridViewDataSource().Copy(); - treebandGcTop.TreeListObj.DataSource = null; + //treebandGcTop.TreeListObj.DataSource = null; } else { @@ -933,15 +966,15 @@ namespace Lskj.ProductiSched DataTable bottomTab = BuildCTable(dataDetail, dataDayPlan, dateTime, 93); bandGcBottom.BandedView.GridControl.DataSource = bottomTab; } + MergeMainDataWithDayPlan(dataMain, dataDayPlan, dateTime, typeDate); if (!TreeMultiHeader) { - MergeMainDataWithDayPlan(dataMain, dataDayPlan, dateTime, typeDate); bandGcTop.SetGridViewDataSource(dataMain); OnBandedViewRowCellClick(bandGcTop.BandedView, null); } - else - { + else { treebandGcTop.SetGridViewDataSource(dataMain); + //treebandGcTop.TreeListObj.DataSource = dataMain; } } string query = @" @@ -2031,24 +2064,30 @@ namespace Lskj.ProductiSched if (e.KeyCode == Keys.F7) { - TreeListColumn column = treeList.FocusedColumn; - if (column != null && column.OptionsColumn.AllowEdit && treeList.AllNodesCount > 0) - { - // 获取当前聚焦单元格的值 - object focusedValue = treeList.FocusedNode?.GetValue(column); + // 使用你框架中定义的精准方法来获取选中的单元格集合 + List selectedCells = treeList.GetSelectedCells(); - if (focusedValue != null && MessageUtil.Show("是否替换所选单元格值?", MessageBoxButtons.YesNo) == DialogResult.Yes) + if (selectedCells != null && selectedCells.Count > 0) + { + // 以第一个选中单元格作为赋值基准值 + TreeListCell firstCell = selectedCells[0]; + object valueToSet = firstCell.Node.GetValue(firstCell.Column); + + if (valueToSet != null && MessageUtil.Show("是否替换所选单元格值?", MessageBoxButtons.YesNo) == DialogResult.Yes) { WaitForm.ShowForm("数据填充中"); - foreach (TreeListNode node in treeList.Selection) + foreach (TreeListCell cell in selectedCells) { - DateTime dateTime; - if (DataModel.columnDateMapping.TryGetValue(column, out dateTime)) + if (cell.Column.OptionsColumn.AllowEdit) { - if (dateTime.Date >= DateTime.Now.Date) + if (DataModel.columnDateMapping.TryGetValue(cell.Column, out DateTime dateTime)) { - node.SetValue(column, focusedValue); + // 日期必须大于等于今天才允许赋值 + if (dateTime.Date >= DateTime.Now.Date) + { + cell.Node.SetValue(cell.Column, valueToSet); + } } } } @@ -2060,7 +2099,6 @@ namespace Lskj.ProductiSched } } } - /// /// 构建下方数据 /// diff --git a/插件库/Lskj.ProductSched/ProductDataModel.cs b/插件库/Lskj.ProductSched/ProductDataModel.cs index fdd35c9..3123489 100644 --- a/插件库/Lskj.ProductSched/ProductDataModel.cs +++ b/插件库/Lskj.ProductSched/ProductDataModel.cs @@ -1,4 +1,5 @@ using DevExpress.XtraTreeList.Columns; +using DevExpress.XtraTreeList.Nodes; using Lskj.Control.Model; using Lskj.Model; using System; @@ -11,5 +12,7 @@ namespace Lskj.ProductiSched { public class ProductDataModel { + //treeList树展开的节点块 + public List treeListNodes = new List(); // 在你的类内部定义此字典(一次定义,长期复用) public Dictionary columnDateMapping = new Dictionar \ No newline at end of file