From 659c4106306d760c22070f3d61426f098cb56a29 Mon Sep 17 00:00:00 2001 From: tdx Date: Wed, 3 Sep 2025 03:49:55 +0000 Subject: [PATCH] SVN r961 SVN-Revision: r961 --- 插件库/Lskj.PubBill/BillModule.cs | 45 ++++++++++++++++++------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/插件库/Lskj.PubBill/BillModule.cs b/插件库/Lskj.PubBill/BillModule.cs index eb125f8..be9aec7 100644 --- a/插件库/Lskj.PubBill/BillModule.cs +++ b/插件库/Lskj.PubBill/BillModule.cs @@ -1211,7 +1211,10 @@ namespace Lskj.PubBill } } } - #region 滚动条稳定-字段与去抖 + #region 滚动条稳定-整套实现(防重入/去抖/批处理/禁止 DataSource=null) + + // ===================== 滚动条稳定-字段与去抖 ===================== + // 只固定“最初存在的静态列”(一般是左侧来源等);动态日期/合计列永不固定 private HashSet _baselineFixedFields; @@ -1220,9 +1223,11 @@ namespace Lskj.PubBill private int _mainRebindScheduled = 0; private DateTime _lastRebindAt = DateTime.MinValue; private readonly TimeSpan _rebindDebounce = TimeSpan.FromMilliseconds(25); - #endregion - #region 数据文件刷新回调(列更新 + 请求重绑)——替换你原来的 OnDataFileRefrshFile + + // ===================== 数据文件刷新回调(列更新 + 请求重绑) ===================== + // —— 替换你原来的 OnDataFileRefrshFile —— + // 只做列构建与视觉层更新;真正的数据重绑放到 RequestRebindPivot(异步执行) private void OnDataFileRefrshFile(object sender, EventArgs e) { var gv = gcMain.GridView; @@ -1231,7 +1236,7 @@ namespace Lskj.PubBill { AddDataColumns(); // 只固定“基线静态列”,动态日期/合计列不固定 UpdateDynamicColumns(); // 日期列 FieldName/Caption/Tag - UpdateSummaryData(); // 你的汇总渲染逻辑 + UpdateSummaryData(); // 你的汇总渲染逻辑(不改数据源) } finally { @@ -1241,9 +1246,9 @@ namespace Lskj.PubBill // 不要在回调栈里直接改数据源;改为“请求重绑”,异步排队执行 RequestRebindPivot(); } - #endregion - #region 只固定基线静态列的列构建——替换你的 AddDataColumns() + + // ===================== 只固定基线静态列的列构建 —— 替换你的 AddDataColumns() ===================== private void AddDataColumns() { var gv = gcMain.GridView; @@ -1355,9 +1360,9 @@ namespace Lskj.PubBill gv.EndUpdate(); } } - #endregion - #region 根据日期修改列状态(确保日期列不固定)——替换你的 UpdateDynamicColumns() + + // ===================== 根据日期修改列状态(确保日期列不固定) —— 替换你的 UpdateDynamicColumns() ===================== private void UpdateDynamicColumns() { DateTime currentDate = DateTime.Now; @@ -1401,9 +1406,9 @@ namespace Lskj.PubBill gv.EndUpdate(); } } - #endregion - #region 汇总更新(可保持你原实现,这里给出整洁版)——可选替换你的 UpdateSummaryData() + + // ===================== 汇总更新(可保持你原实现,这里给出整洁版) —— 可选替换你的 UpdateSummaryData() ===================== private void UpdateSummaryData(DataTable table = null) { DataTable dataTable = table; @@ -1435,9 +1440,9 @@ namespace Lskj.PubBill gcMain.AddHeadquarters(); } } - #endregion - #region 数据源变化(外部真实变化时响应)——替换你的 OnGcMainDataSourceChanged + + // ===================== 数据源变化(外部真实变化时响应) —— 替换你的 OnGcMainDataSourceChanged ===================== private void OnGcMainDataSourceChanged(object sender, EventArgs e) { var grid = this.gcMain?.GridControl; @@ -1462,9 +1467,9 @@ namespace Lskj.PubBill System.Threading.Interlocked.Exchange(ref _mainRebindScheduled, 1); this.BeginInvoke((Action)(() => SafeRebindPivot(grid, view, src, dateTime))); } - #endregion - #region 统一请求重绑入口(供内部自发刷新使用)——新增 + + // ===================== 统一请求重绑入口(供内部自发刷新使用)—— 新增 ===================== private void RequestRebindPivot() { var grid = this.gcMain?.GridControl; @@ -1487,9 +1492,9 @@ namespace Lskj.PubBill System.Threading.Interlocked.Exchange(ref _mainRebindScheduled, 1); this.BeginInvoke((Action)(() => SafeRebindPivot(grid, view, src, dateTime))); } - #endregion - #region 重绑实现(批处理 + 不清空数据源 + 稳定滚动条)——替换/加入你的 SafeRebindPivot + + // ===================== 重绑实现(批处理 + 不清空数据源 + 稳定滚动条) —— 替换/加入你的 SafeRebindPivot ===================== private void SafeRebindPivot(DevExpress.XtraGrid.GridControl grid, DevExpress.XtraGrid.Views.Base.ColumnView view, DataTable currentSource, @@ -1533,7 +1538,7 @@ namespace Lskj.PubBill // 复制成新表再加工(不要在当前绑定表上原地改) DataTable result = src.Copy(); - MergeMainDataWithDayPlan(result, dataNoPlanFile, dateTime); // 你自有实现 + MergeMainDataWithDayPlan(result, dataNoPlanFile, dateTime); // 你自有实现:在 result 上做行转列/合并 // 绑定“新表”(严禁 DataSource=null 再赋值) grid.DataSource = result; @@ -1545,6 +1550,7 @@ namespace Lskj.PubBill { gv.OptionsView.ColumnAutoWidth = false; gv.HorzScrollVisibility = DevExpress.XtraGrid.Views.Base.ScrollVisibility.Always; + // 如需避免首次列宽为 0,可按需:gv.BestFitColumns(); } // 渲染“计划合计”(绑定之后) @@ -1601,10 +1607,12 @@ namespace Lskj.PubBill } } } + #endregion + /// /// 说明:表格编辑时,判断是否是否编辑 /// 创建人:王一帆 @@ -9343,4 +9351,5 @@ namespace Lskj.PubBill } else { - \ No newline at end of file + //刷新返回的单据号 + thi \ No newline at end of file