From 9be9ba4e159969fb5e32648c2c34e912ccc3ae6d Mon Sep 17 00:00:00 2001 From: duheng <2286773002@qq.com> Date: 星期五, 28 三月 2025 14:22:42 +0800 Subject: [PATCH] 优化细节问题 --- WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/09-hydrant/HydroHydrantListCtrl.cs | 90 +++++++++++++++++++++++++++++++++++--------- 1 files changed, 71 insertions(+), 19 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/09-hydrant/HydroHydrantListCtrl.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/09-hydrant/HydroHydrantListCtrl.cs index 688f53e..8421fe5 100644 --- a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/09-hydrant/HydroHydrantListCtrl.cs +++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/06-visual/09-hydrant/HydroHydrantListCtrl.cs @@ -1,4 +1,6 @@ -锘縰sing Yw.Model; +锘縰sing DevExpress.XtraGrid.Views.Grid; +using DevExpress.XtraPrinting; +using Yw.Model; namespace Yw.WinFrmUI { @@ -31,10 +33,6 @@ /// 姘村姏鏀瑰彉瑙嗗浘浜嬩欢 /// </summary> public event Action<List<HydroVisualViewModel>> HydroChangedViewEvent; - /// <summary> - /// 鏋勪欢鏀瑰彉浜嬩欢 - /// </summary> - public event Action<HydroParterInfo, eChangeType> ParterChangedEvent; /// <summary> /// 鏄惁鎷ユ湁姘村姏鍒楄〃 @@ -44,34 +42,54 @@ get { return _allList != null && _allList.Count > 0; } } - //鎵�鏈夊垪琛� - private List<HydroHydrantViewModel> _allList = null; - //鎵�鏈夌粦瀹氬垪琛� - private List<HydroHydrantViewModel> _allBindingList = null; + + private List<HydroHydrantViewModel> _allList = null;//鎵�鏈夊垪琛� + private List<HydroHydrantViewModel> _allBindingList = null;//鎵�鏈夌粦瀹氬垪琛� + private HydroChangeHelper _changeHelper = null;//鏀瑰彉杈呭姪绫� + private HydroPropStatusHelper _propStatusHelper = null;//灞炴�х姸鎬佽緟鍔╃被 /// <summary> /// 缁戝畾鏁版嵁 /// </summary> - public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo) + public void SetBindingData + ( + Yw.Model.HydroModelInfo hydroInfo, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { - SetBindingData(hydroInfo, allCalcuResultVisualDict: null); + SetBindingData(hydroInfo, allCalcuResultVisualDict: null, changeHelper, propStatusHelper); } /// <summary> /// 缁戝畾鏁版嵁 /// </summary> - public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuVisualResult> allCalcuResultList) + public void SetBindingData + ( + Yw.Model.HydroModelInfo hydroInfo, + List<HydroCalcuVisualResult> allCalcuResultList, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { var allCalcuResultVisualDict = allCalcuResultList?.ToDictionary(x => x.Code); - SetBindingData(hydroInfo, allCalcuResultVisualDict); + SetBindingData(hydroInfo, allCalcuResultVisualDict, changeHelper, propStatusHelper); } /// <summary> /// 缁戝畾鏁版嵁 /// </summary> - public void SetBindingData(HydroModelInfo hydroInfo, Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict) + public void SetBindingData + ( + HydroModelInfo hydroInfo, + Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { _allList = new List<HydroHydrantViewModel>(); + _changeHelper = changeHelper; + _propStatusHelper = propStatusHelper; if (hydroInfo != null && hydroInfo.Hydrants != null && hydroInfo.Hydrants.Count > 0) { foreach (var visual in hydroInfo.Hydrants) @@ -91,9 +109,16 @@ /// <summary> /// 缁戝畾鏁版嵁 /// </summary> - public void SetBindingData(List<HydroVisualViewModel> allVisualViewModelList) + public void SetBindingData + ( + List<HydroVisualViewModel> allVisualViewModelList, + HydroChangeHelper changeHelper = null, + HydroPropStatusHelper propStatusHelper = null + ) { _allList = new List<HydroHydrantViewModel>(); + _changeHelper = changeHelper; + _propStatusHelper = propStatusHelper; allVisualViewModelList?.ForEach(x => { if (x.Vmo.Catalog == Yw.Hydro.ParterCatalog.Hydrant) @@ -248,7 +273,7 @@ return; } var dlg = new SetHydroHydrantDlg(); - dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList()); + dlg.SetBindingData(_allBindingList.Select(x => x.Vmo).ToList(), _changeHelper, _propStatusHelper); dlg.ReloadDataEvent += (list) => { if (list == null || list.Count < 1) @@ -261,7 +286,6 @@ this.HydroChangedViewEvent?.Invoke(allVisualViewModelList); var allVisualInfoList = allVisualViewModelList.Select(x => x.Vmo).ToList(); this.HydroChangedInfoEvent?.Invoke(allVisualInfoList); - list.ForEach(x => this.ParterChangedEvent?.Invoke(x, eChangeType.Update)); }; dlg.ShowDialog(); } @@ -277,7 +301,7 @@ if (e.Column == this.colSet) { var dlg = new SetHydroHydrantDlg(); - dlg.SetBindingData(row.Vmo); + dlg.SetBindingData(row.Vmo, _changeHelper, _propStatusHelper); dlg.ReloadDataEvent += (list) => { if (list == null || list.Count < 1) @@ -288,7 +312,6 @@ this.gridView1.RefreshRow(e.RowHandle); this.HydroChangedViewEvent?.Invoke(new List<HydroVisualViewModel>() { row }); this.HydroChangedInfoEvent?.Invoke(new List<HydroVisualInfo>() { row.Vmo }); - this.ParterChangedEvent?.Invoke(row.Vmo, eChangeType.Update); }; dlg.ShowDialog(); } @@ -409,5 +432,34 @@ this.colCalcuDemand.Visible = true; this.colSet.Visible = false; } + + /// <summary> + /// + /// </summary> + public GridView GetGridView() + { + return this.gridView1; + } + + /// <summary> + /// + /// </summary> + public void ExportToXlsx() + { + var filePath = FileDialogHelper.SaveFile("瀵煎嚭Excel鏂囦欢", "Excel鏂囦欢|*.xlsx"); + if (string.IsNullOrEmpty(filePath)) + { + return; + } + var options = new XlsxExportOptions + { + ExportMode = XlsxExportMode.SingleFile, // 瀵煎嚭妯″紡 + ShowGridLines = true, // 鏄剧ず缃戞牸绾� + TextExportMode = TextExportMode.Value, // 瀵煎嚭鏂囨湰妯″紡 + SheetName = "娑堢伀鏍�" // 宸ヤ綔琛ㄥ悕绉� + }; + this.gridView1.ExportToXlsx(filePath, options); + } + } } -- Gitblit v1.9.3