From d5c03a1248f90e2f01e704d9bab759df72c49ecf Mon Sep 17 00:00:00 2001 From: lihanbo Date: Sat, 8 Feb 2025 09:41:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20IsComplete=20=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=EF=BC=8C=E6=9B=B4=E6=96=B0=E6=B3=A8=E9=87=8A=E5=92=8C?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 LectotypeLine.cs 中添加 IsComplete 属性并标记为可空。 在 MotorLectotypeService.cs 中更新映射和 SetColumns 方法。 在 CableLectotypeUserControl.xaml 中修改 CheckBox 绑定和注释 GridViewColumn。 在 LectotypeWindow.xaml.cs 中添加 ToLayout 和 Window_Closing 方法的注释。 在 CableLectotypeViewModel.cs 中更新映射和 LectotypeLineModel。 在 LayoutHelperViewModel.cs 中修改 SetSubLineAndSave 方法逻辑。 在 LectotypeViewModel.cs 中添加多个方法的注释,删除 CheckSaved 方法。 --- .../Model/LectotypeLine.cs | 3 ++ .../Service/MotorLectotypeService.cs | 6 ++- .../View/CableLectotypeUserControl.xaml | 14 +++++- .../View/LectotypeWindow.xaml.cs | 8 ++++ .../ViewModel/CableLectotypeViewModel.cs | 7 ++- .../ViewModel/LayoutHelperViewModel.cs | 8 +++- .../ViewModel/LectotypeViewModel.cs | 46 +++++++++++-------- 7 files changed, 67 insertions(+), 25 deletions(-) diff --git a/Sinvo.EplanHpD.Plugin.Service/Model/LectotypeLine.cs b/Sinvo.EplanHpD.Plugin.Service/Model/LectotypeLine.cs index b5808c1..d8b82de 100644 --- a/Sinvo.EplanHpD.Plugin.Service/Model/LectotypeLine.cs +++ b/Sinvo.EplanHpD.Plugin.Service/Model/LectotypeLine.cs @@ -58,6 +58,9 @@ namespace Sinvo.EplanHpD.Plugin.Service.Model [SugarColumn(IsNullable = true)] public bool IsChecked { get; set; } + [SugarColumn(IsNullable = true)] + public bool IsComplete { get; set; } + [SugarColumn(IsIgnore = true)] public virtual ICollection SubLines { get; set; } } diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs index e17f4bd..091f060 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs @@ -110,6 +110,7 @@ namespace Sinvo.EplanHpD.Plugin.Service IsLectotype = line.IsLectotype, CableModel = line.CableModel, IsChecked = line.IsChecked, + IsComplete = line.IsComplete, SubLines = GetSubLines(line.LectotypeLineId) }).OrderBy(it => it.CurrentLine).ToList(); return viewModel; @@ -127,7 +128,8 @@ namespace Sinvo.EplanHpD.Plugin.Service SeqNo = subLine.SeqNo, CableModel = subLine.CableModel, CableType = subLine.CableType, - IsChecked = subLine.IsChecked + IsChecked = subLine.IsChecked, + LectotypeLineId = subLine.LectotypeLineId }).ToList(); } @@ -264,7 +266,7 @@ namespace Sinvo.EplanHpD.Plugin.Service int changeCount = db.Updateable() .Where(mt => mt.MotorUniqueFlag == motorUniqueFlag && mt.LectotypeLineId == lineId) - .SetColumns(it => it.IsChecked == true) + .SetColumns(it => it.IsComplete == true) .ExecuteCommand(); db.CommitTran(); diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml b/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml index e7c1582..5ba4c47 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml +++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml @@ -327,7 +327,7 @@ @@ -368,6 +368,18 @@ + + diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/LectotypeWindow.xaml.cs b/Sinvo.EplanHpD.Plugin.WPFUI/View/LectotypeWindow.xaml.cs index b4f6645..0a9211a 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/View/LectotypeWindow.xaml.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/LectotypeWindow.xaml.cs @@ -407,6 +407,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI } } + /// + /// 跳转到布线助手 + /// private void ToLayout() { ViewModel.ClearNotSavedLectotypeList(); @@ -419,6 +422,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI window.Show(); this.Close(); } + /// + /// 窗口关闭中事件 + /// + /// + /// private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if(ViewModel.GetNotSavedLectotypeList() != null && ViewModel.GetNotSavedLectotypeList().Any()) diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/CableLectotypeViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/CableLectotypeViewModel.cs index 90d6b58..79a0b46 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/CableLectotypeViewModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/CableLectotypeViewModel.cs @@ -455,12 +455,15 @@ public class CableLectotypeViewModel : INotifyPropertyChanged LineCount = line.LineCount, CurrentLine = line.CurrentLine, Motor = line.Motor, - IsLectotype = line.IsLectotype, + IsLectotype = line.IsLectotype, + IsComplete = line.IsComplete, SubLines = line.SubLines.Select(subLine => new LectotypeLineModel { SeqNo = subLine.SeqNo, CableModel = subLine.CableModel, - CableType = subLine.CableType + CableType = subLine.CableType, + IsChecked = subLine.IsChecked, + LectotypeLineId = subLine.LectotypeLineId }).ToList() }).ToList()); diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LayoutHelperViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LayoutHelperViewModel.cs index 922af0a..cb806b5 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LayoutHelperViewModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LayoutHelperViewModel.cs @@ -329,8 +329,12 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel { subLine.IsChecked = true; //cableLectotypeViewModel.SaveToDb(); - SetSubLineAndSave(subLine.LectotypeLineId); - return SubLines.All(it => it.IsChecked); + bool allDone = SubLines.All(it => it.IsChecked); + if (allDone) + { + SetSubLineAndSave(SelectedLine.LectotypeLineId); + } + return allDone; } else { diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs index 5f55752..a863077 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs @@ -617,7 +617,11 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged Motors = motorsData; return Task.CompletedTask; } - + /// + /// 获取电机品牌 + /// + /// + /// private string GetMotorBrand(string motorName) { switch (motorName) @@ -630,6 +634,11 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged return Brands.UNKNOWN; } } + /// + /// 去除电机型号中的多余信息 + /// + /// + /// private string UnStuffMotorName(string motorName) { if (motorName.Contains("&")) @@ -649,6 +658,9 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged return motorName; } } + /// + /// 选中线时 + /// private void OnSelectedItemChange() { if (this.SelectedItem != null) @@ -674,7 +686,11 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged DetailsShowMode = DataGridRowDetailsVisibilityMode.Collapsed; } } - + /// + /// 获取BOM + /// + /// + /// public bool GetBom(string cableModel) { var line = Wires.FirstOrDefault(it => it.CableModelNo == cableModel); @@ -709,11 +725,19 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged return false; } } + /// + /// 导出BOM清单 + /// + /// + /// public void ExportBomList(string targetPath, string cableModel) { MotorExcelHelper.Instance.SaveBomListToExcel(targetPath, LineBoms, cableModel); } - + /// + /// 导出线材清单 + /// + /// public void ExportLines(string targetPath) { int seq = 1; @@ -732,21 +756,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged public void RemoveNotSavedLectotype(Dictionary value) { value.ForEach(it => NotSavedLectotypeList.Remove(it.Key)); - } - - internal async Task CheckSaved() - { - if(NotSavedLectotypeList != null && NotSavedLectotypeList.Any()) - { - var isContinue = false; - - return isContinue; - } - else - { - return false; - } - } + } internal Dictionary GetNotSavedLectotypeList() {