添加 IsComplete 属性,更新注释和方法逻辑

在 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 方法。
This commit is contained in:
lihanbo 2025-02-08 09:41:20 +08:00
parent ab5345b1b8
commit d5c03a1248
7 changed files with 67 additions and 25 deletions

View File

@ -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<LectotypeLine> SubLines { get; set; }
}

View File

@ -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<LectotypeLine>()
.Where(mt => mt.MotorUniqueFlag == motorUniqueFlag && mt.LectotypeLineId == lineId)
.SetColumns(it => it.IsChecked == true)
.SetColumns(it => it.IsComplete == true)
.ExecuteCommand();
db.CommitTran();

View File

@ -327,7 +327,7 @@
<CheckBox
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsChecked="{Binding IsComplete, UpdateSourceTrigger=PropertyChanged}"
IsChecked="{Binding IsComplete}"
IsEnabled="False" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
@ -368,6 +368,18 @@
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!--<GridViewColumn Header="是否布线完成">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsChecked="{Binding IsChecked, UpdateSourceTrigger=PropertyChanged}"
IsEnabled="False" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>-->
</GridView>
</ListView.View>
</ListView>

View File

@ -407,6 +407,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
}
}
/// <summary>
/// 跳转到布线助手
/// </summary>
private void ToLayout()
{
ViewModel.ClearNotSavedLectotypeList();
@ -419,6 +422,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
window.Show();
this.Close();
}
/// <summary>
/// 窗口关闭中事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if(ViewModel.GetNotSavedLectotypeList() != null && ViewModel.GetNotSavedLectotypeList().Any())

View File

@ -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());

View File

@ -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
{

View File

@ -617,7 +617,11 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
Motors = motorsData;
return Task.CompletedTask;
}
/// <summary>
/// 获取电机品牌
/// </summary>
/// <param name="motorName"></param>
/// <returns></returns>
private string GetMotorBrand(string motorName)
{
switch (motorName)
@ -630,6 +634,11 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
return Brands.UNKNOWN;
}
}
/// <summary>
/// 去除电机型号中的多余信息
/// </summary>
/// <param name="motorName"></param>
/// <returns></returns>
private string UnStuffMotorName(string motorName)
{
if (motorName.Contains("&"))
@ -649,6 +658,9 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
return motorName;
}
}
/// <summary>
/// 选中线时
/// </summary>
private void OnSelectedItemChange()
{
if (this.SelectedItem != null)
@ -674,7 +686,11 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
DetailsShowMode = DataGridRowDetailsVisibilityMode.Collapsed;
}
}
/// <summary>
/// 获取BOM
/// </summary>
/// <param name="cableModel"></param>
/// <returns></returns>
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;
}
}
/// <summary>
/// 导出BOM清单
/// </summary>
/// <param name="targetPath"></param>
/// <param name="cableModel"></param>
public void ExportBomList(string targetPath, string cableModel)
{
MotorExcelHelper.Instance.SaveBomListToExcel(targetPath, LineBoms, cableModel);
}
/// <summary>
/// 导出线材清单
/// </summary>
/// <param name="targetPath"></param>
public void ExportLines(string targetPath)
{
int seq = 1;
@ -732,21 +756,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
public void RemoveNotSavedLectotype(Dictionary<string, string> value)
{
value.ForEach(it => NotSavedLectotypeList.Remove(it.Key));
}
internal async Task<bool> CheckSaved()
{
if(NotSavedLectotypeList != null && NotSavedLectotypeList.Any())
{
var isContinue = false;
return isContinue;
}
else
{
return false;
}
}
}
internal Dictionary<string, string> GetNotSavedLectotypeList()
{