增强多芯线模型和视图的功能与稳定性

在 `MultiCoreWireLecDBModel.cs` 中添加了多个新属性,移除旧属性,并增强了文档说明。
在 `ApplicationExt.cs` 中实现了全局异常处理,提升了应用稳定性。
重构 `MultiCoreWireDataModel.cs`,实现数据绑定通知机制,确保 UI 更新及时。
更新 `MultiCoreWireLayoutHelperWindow.xaml` 的样式和数据模板,增强数据可视化。
在 `MultiCoreWireWindow.xaml` 中添加机构信息的绑定,确保用户输入正确。
在 `MultiCoreWireViewModel.cs` 中添加新属性和方法,改进数据处理和导出功能。
重构 `MultiCoreWireLayoutHelperViewModel.cs` 的数据加载逻辑,确保数据一致性和 UI 更新。
This commit is contained in:
lihanbo 2025-05-06 09:56:10 +08:00
parent 27cd690bc6
commit e40d2ce185
9 changed files with 971 additions and 155 deletions

View File

@ -9,45 +9,42 @@ namespace Sinvo.EplanHpD.Plugin.Service.Model
/*
* 线mm2) 线 线
*/
public int SeqNo { get; set; }
public string Id { get; set; }
public string UniqueKey { get; set; }
public string ProjectName { get; set; }
public string UserId { get; set; }
public int SeqNo { get; set; }
/// <summary>
/// 应用场景
/// </summary>
public string WireKey { get; set; }
public string ApplicationScenario { get; set; }
/// <summary>
/// 线径规格mm2)
/// </summary>
public string WireDiameterSpecification { get; set; }
/// <summary>
/// 是否高柔
/// </summary>
public string IsHighFlexibilityStr { get; set; }
/// <summary>
/// 线芯数
/// </summary>
public string WireCoreCount { get; set; }
/// <summary>
/// 线材型号规格
/// </summary>
public string WireModelSpecification { get; set; }
/// <summary>
/// 线材颜色名
/// </summary>
public string WireColorName { get; set; }
/// <summary>
/// 线材长度
/// </summary>
[SugarColumn(IsNullable = true)]
public string WireLength { get; set; }
/// <summary>
/// 前连接物型号
/// </summary>
public string FrontConnectorModel { get; set; }
/// <summary>
/// 前连接物料号
/// </summary>
public string FrontConnectorMCode { get; set; }
/// <summary>
/// 前连接物数量
/// </summary>
@ -58,16 +55,93 @@ namespace Sinvo.EplanHpD.Plugin.Service.Model
/// 后连接物型号
/// </summary>
public string RearConnectorModel { get; set; }
/// <summary>
/// 后连接物料号
/// </summary>
public string RearConnectorMCode { get; set; }
/// <summary>
/// 后连接物数量
/// </summary>
public int RearConnectorQuantity { get; set; }
/// <summary>
/// 号码管型号
/// </summary>
[SugarColumn(IsNullable = true)]
public string NumberTubeModel { get; set; }
/// <summary>
/// 号码管物料编码
/// </summary>
[SugarColumn(IsNullable = true)]
public string NumberTubeMCode { get; set; }
/// <summary>
/// 号码管长度
/// </summary>
[SugarColumn(IsNullable = true)]
public int NumberTubeLength { get; set; }
[SugarColumn(IsNullable = true)]
public bool FrontConnectorIsPin { get; set; }
[SugarColumn(IsNullable = true)]
public bool RearConnectorIsPin { get; set; }
/// <summary>
/// 透明热缩管型号
/// </summary>
[SugarColumn(IsNullable = true)]
public string TransparentHeatShrinkTubeModel { get; set; }
/// <summary>
/// 透明热缩管标示
/// </summary>
[SugarColumn(IsNullable = true)]
public string TransparentHeatShrinkTubeDesc { get; set; }
/// <summary>
/// 透明热缩管物料编码
/// </summary>
[SugarColumn(IsNullable = true)]
public string TransparentHeatShrinkTubeMCode { get; set; }
/// <summary>
/// 黑色热缩管型号(插头)
/// </summary>
[SugarColumn(IsNullable = true)]
public string BlackHeatShrinkTubeModel { get; set; }
/// <summary>
/// 黑色热缩管物料编码(插头)
/// </summary>
[SugarColumn(IsNullable = true)]
public string BlackHeatShrinkTubeMCode { get; set; }
/// <summary>
/// 黑色热缩管型号(剥线后)
/// </summary>
[SugarColumn(IsNullable = true)]
public string BlackHeatShrinkTubeModelAfterStripping { get; set; }
/// <summary>
/// 黑色热缩管物料编码(剥线后)
/// </summary>
[SugarColumn(IsNullable = true)]
public string BlackHeatShrinkTubeMCodeAfterStripping { get; set; }
/// <summary>
/// 是否已布线
/// 热缩管标识
/// </summary>
public bool Layouted { get; set; } = false;
[SugarColumn(IsNullable = true)]
public string HeatShrinkTubeDesc { get; set; }
/// <summary>
/// 前段子剥线长度
/// </summary>
[SugarColumn(IsNullable = true)]
public int FrontStrippingLength { get; set; }
/// <summary>
/// 后段子剥线长度
/// </summary>
[SugarColumn(IsNullable = true)]
public int RearStrippingLength { get; set; }
public bool Layouted { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using System;

using System;
using System.Windows;
namespace Sinvo.EplanHpD.Plugin.WPFUI.Extension
@ -36,9 +37,16 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Extension
Resources = new ResourceDictionary
{
Source = new Uri("pack://application:,,,/Sinvo.EplanHpD.Plugin.WPFUI;component/Themes/Theme.xaml")
}
},
};
Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
}
}
private static void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
HandyControl.Controls.MessageBox.Show($"{sender.GetType()}: {e.Exception.Message}");
e.Handled = true;
}
}
}

View File

@ -1,157 +1,732 @@
using MiniExcelLibs.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
{
public class MultiCoreWireDataModel
public class MultiCoreWireDataModel : CheckedModel,INotifyPropertyChanged
{
private int _seqNo;
public int SeqNo
{
get => _seqNo;
set
{
if (_seqNo != value)
{
_seqNo = value;
OnPropertyChanged();
}
}
}
public int SeqNo { get; set; }
private string _id;
public string Id
{
get => _id;
set
{
if (_id != value)
{
_id = value;
OnPropertyChanged();
}
}
}
public string Id { get; set; }
public string UniqueKey { get; set; }
public string ProjectName { get; set; }
public string UserId { get; set; }
public string WireKey { get; set; }
public string ApplicationScenario { get; set; }
public string WireDiameterSpecification { get; set; }
public string IsHighFlexibilityStr { get; set; }
public string WireCoreCount { get; set; }
private string _uniqueKey;
public string UniqueKey
{
get => _uniqueKey;
set
{
if (_uniqueKey != value)
{
_uniqueKey = value;
OnPropertyChanged();
}
}
}
private string _projectName;
public string ProjectName
{
get => _projectName;
set
{
if (_projectName != value)
{
_projectName = value;
OnPropertyChanged();
}
}
}
private string _userId;
public string UserId
{
get => _userId;
set
{
if (_userId != value)
{
_userId = value;
OnPropertyChanged();
}
}
}
private string _wireKey;
public string WireKey
{
get => _wireKey;
set
{
if (_wireKey != value)
{
_wireKey = value;
OnPropertyChanged();
}
}
}
private string _applicationScenario;
public string ApplicationScenario
{
get => _applicationScenario;
set
{
if (_applicationScenario != value)
{
_applicationScenario = value;
OnPropertyChanged();
}
}
}
private string _wireDiameterSpecification;
public string WireDiameterSpecification
{
get => _wireDiameterSpecification;
set
{
if (_wireDiameterSpecification != value)
{
_wireDiameterSpecification = value;
OnPropertyChanged();
}
}
}
private string _isHighFlexibilityStr;
public string IsHighFlexibilityStr
{
get => _isHighFlexibilityStr;
set
{
if (_isHighFlexibilityStr != value)
{
_isHighFlexibilityStr = value;
OnPropertyChanged();
}
}
}
private string _wireCoreCount;
public string WireCoreCount
{
get => _wireCoreCount;
set
{
if (_wireCoreCount != value)
{
_wireCoreCount = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 引脚编号
/// </summary>
public string PinIndex { get; set; }
private string _pinIndex;
public string PinIndex
{
get => _pinIndex;
set
{
if (_pinIndex != value)
{
_pinIndex = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 线材型号规格
/// </summary>
public string WireModelSpecification { get; set; }
private string _wireModelSpecification;
public string WireModelSpecification
{
get => _wireModelSpecification;
set
{
if (_wireModelSpecification != value)
{
_wireModelSpecification = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 线材颜色名
/// </summary>
public string WireColorName { get; set; }
private string _wireColorName;
public string WireColorName
{
get => _wireColorName;
set
{
if (_wireColorName != value)
{
_wireColorName = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 线材颜色十六进制
/// </summary>
public string WireColorHex { get; set; }
private string _wireColorHex;
public string WireColorHex
{
get => _wireColorHex;
set
{
if (_wireColorHex != value)
{
_wireColorHex = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 线材颜色十六进制 次颜色
/// </summary>
public string WireColorHexSec { get; set; }
private string _wireColorHexSec;
public string WireColorHexSec
{
get => _wireColorHexSec;
set
{
if (_wireColorHexSec != value)
{
_wireColorHexSec = value;
OnPropertyChanged();
}
}
}
public bool IsMultiColor { get; set; }
private bool _isMultiColor;
public bool IsMultiColor
{
get => _isMultiColor;
set
{
if (_isMultiColor != value)
{
_isMultiColor = value;
OnPropertyChanged();
}
}
}
public string WireType { get; set; }
private string _wireType;
public string WireType
{
get => _wireType;
set
{
if (_wireType != value)
{
_wireType = value;
OnPropertyChanged();
}
}
}
private string _wireLength;
public string WireLength
{
get => _wireLength;
set
{
if (_wireLength != value)
{
_wireLength = value;
OnPropertyChanged();
}
}
}
public string WireLength { get; set; }
/// <summary>
/// 是否高柔
/// </summary>
public bool IsHighFlexibility { get; set; }
private bool _isHighFlexibility;
public bool IsHighFlexibility
{
get => _isHighFlexibility;
set
{
if (_isHighFlexibility != value)
{
_isHighFlexibility = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 前连接物型号
/// </summary>
public string FrontConnectorModel { get; set; }
private string _frontConnectorModel;
public string FrontConnectorModel
{
get => _frontConnectorModel;
set
{
if (_frontConnectorModel != value)
{
_frontConnectorModel = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 前连接物料号
/// </summary>
public string FrontConnectorMCode { get; set; }
private string _frontConnectorMCode;
public string FrontConnectorMCode
{
get => _frontConnectorMCode;
set
{
if (_frontConnectorMCode != value)
{
_frontConnectorMCode = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 前连接物数量
/// </summary>
public int FrontConnectorQuantity { get; set; }
private int _frontConnectorQuantity;
public int FrontConnectorQuantity
{
get => _frontConnectorQuantity;
set
{
if (_frontConnectorQuantity != value)
{
_frontConnectorQuantity = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 后连接物型号
/// </summary>
public string RearConnectorModel { get; set; }
private string _rearConnectorModel;
public string RearConnectorModel
{
get => _rearConnectorModel;
set
{
if (_rearConnectorModel != value)
{
_rearConnectorModel = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 后连接物料号
/// </summary>
public string RearConnectorMCode { get; set; }
private string _rearConnectorMCode;
public string RearConnectorMCode
{
get => _rearConnectorMCode;
set
{
if (_rearConnectorMCode != value)
{
_rearConnectorMCode = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 后连接物数量
/// </summary>
public int RearConnectorQuantity { get; set; }
private int _rearConnectorQuantity;
public int RearConnectorQuantity
{
get => _rearConnectorQuantity;
set
{
if (_rearConnectorQuantity != value)
{
_rearConnectorQuantity = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 号码管型号
/// </summary>
public string NumberTubeModel { get; set; }
private string _numberTubeModel;
public string NumberTubeModel
{
get => _numberTubeModel;
set
{
if (_numberTubeModel != value)
{
_numberTubeModel = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 号码管物料编码
/// </summary>
public string NumberTubeMCode { get; set; }
private string _numberTubeMCode;
public string NumberTubeMCode
{
get => _numberTubeMCode;
set
{
if (_numberTubeMCode != value)
{
_numberTubeMCode = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 号码管长度
/// </summary>
public int NumberTubeLength { get; set; }
public bool FrontConnectorIsPin { get; set; }
public bool RearConnectorIsPin { get; set; }
private int _numberTubeLength;
public int NumberTubeLength
{
get => _numberTubeLength;
set
{
if (_numberTubeLength != value)
{
_numberTubeLength = value;
OnPropertyChanged();
}
}
}
private bool _frontConnectorIsPin;
public bool FrontConnectorIsPin
{
get => _frontConnectorIsPin;
set
{
if (_frontConnectorIsPin != value)
{
_frontConnectorIsPin = value;
OnPropertyChanged();
}
}
}
private bool _rearConnectorIsPin;
public bool RearConnectorIsPin
{
get => _rearConnectorIsPin;
set
{
if (_rearConnectorIsPin != value)
{
_rearConnectorIsPin = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 透明热缩管型号
/// </summary>
public string TransparentHeatShrinkTubeModel { get; set; }
private string _transparentHeatShrinkTubeModel;
public string TransparentHeatShrinkTubeModel
{
get => _transparentHeatShrinkTubeModel;
set
{
if (_transparentHeatShrinkTubeModel != value)
{
_transparentHeatShrinkTubeModel = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 透明热缩管标示
/// </summary>
public string TransparentHeatShrinkTubeDesc { get; set; }
private string _transparentHeatShrinkTubeDesc;
public string TransparentHeatShrinkTubeDesc
{
get => _transparentHeatShrinkTubeDesc;
set
{
if (_transparentHeatShrinkTubeDesc != value)
{
_transparentHeatShrinkTubeDesc = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 透明热缩管物料编码
/// </summary>
public string TransparentHeatShrinkTubeMCode { get; set; }
private string _transparentHeatShrinkTubeMCode;
public string TransparentHeatShrinkTubeMCode
{
get => _transparentHeatShrinkTubeMCode;
set
{
if (_transparentHeatShrinkTubeMCode != value)
{
_transparentHeatShrinkTubeMCode = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 黑色热缩管型号(插头)
/// </summary>
public string BlackHeatShrinkTubeModel { get; set; }
private string _blackHeatShrinkTubeModel;
public string BlackHeatShrinkTubeModel
{
get => _blackHeatShrinkTubeModel;
set
{
if (_blackHeatShrinkTubeModel != value)
{
_blackHeatShrinkTubeModel = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 黑色热缩管物料编码(插头)
/// </summary>
public string BlackHeatShrinkTubeMCode { get; set; }
private string _blackHeatShrinkTubeMCode;
public string BlackHeatShrinkTubeMCode
{
get => _blackHeatShrinkTubeMCode;
set
{
if (_blackHeatShrinkTubeMCode != value)
{
_blackHeatShrinkTubeMCode = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 黑色热缩管型号(剥线后)
/// </summary>
public string BlackHeatShrinkTubeModelAfterStripping { get; set; }
private string _blackHeatShrinkTubeModelAfterStripping;
public string BlackHeatShrinkTubeModelAfterStripping
{
get => _blackHeatShrinkTubeModelAfterStripping;
set
{
if (_blackHeatShrinkTubeModelAfterStripping != value)
{
_blackHeatShrinkTubeModelAfterStripping = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 黑色热缩管物料编码(剥线后)
/// </summary>
public string BlackHeatShrinkTubeMCodeAfterStripping { get; set; }
private string _blackHeatShrinkTubeMCodeAfterStripping;
public string BlackHeatShrinkTubeMCodeAfterStripping
{
get => _blackHeatShrinkTubeMCodeAfterStripping;
set
{
if (_blackHeatShrinkTubeMCodeAfterStripping != value)
{
_blackHeatShrinkTubeMCodeAfterStripping = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 热缩管标识
/// </summary>
public string HeatShrinkTubeDesc { get; set; }
private string _heatShrinkTubeDesc;
public string HeatShrinkTubeDesc
{
get => _heatShrinkTubeDesc;
set
{
if (_heatShrinkTubeDesc != value)
{
_heatShrinkTubeDesc = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 前段子剥线长度
/// </summary>
public int FrontStrippingLength { get; set; }
private int _frontStrippingLength;
public int FrontStrippingLength
{
get => _frontStrippingLength;
set
{
if (_frontStrippingLength != value)
{
_frontStrippingLength = value;
OnPropertyChanged();
}
}
}
/// <summary>
/// 后段子剥线长度
/// </summary>
public int RearStrippingLength { get; set; }
public bool Layouted { get;set; }
private int _rearStrippingLength;
public int RearStrippingLength
{
get => _rearStrippingLength;
set
{
if (_rearStrippingLength != value)
{
_rearStrippingLength = value;
OnPropertyChanged();
}
}
}
private bool _layouted;
public bool Layouted
{
get => _layouted;
set
{
if (_layouted != value)
{
_layouted = value;
OnPropertyChanged();
}
}
}
private string _plugModel;
/// <summary>
/// 插头型号
/// </summary>
public string PlugModel
{
get => _plugModel;
set
{
if (_plugModel != value)
{
_plugModel = value;
OnPropertyChanged();
}
}
}
private string _plugMCode;
/// <summary>
/// 插头料号
/// </summary>
public string PlugMCode
{
get => _plugMCode;
set
{
if (_plugMCode != value)
{
_plugMCode = value;
OnPropertyChanged();
}
}
}
private int _plugQty;
/// <summary>
/// 插头数量
/// </summary>
public int PlugQty
{
get => _plugQty;
set
{
if (_plugQty != value)
{
_plugQty = value;
OnPropertyChanged();
}
}
}
private List<MultiCoreWireDataModel> _children = [];
public List<MultiCoreWireDataModel> Children
{
get { return _children; }
set { _children = value; }
get => _children;
set
{
if (_children != value)
{
_children = value;
OnPropertyChanged();
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@ -52,40 +52,79 @@
<ListView
Grid.Row="1"
hc:GridViewAttach.ColumnHeaderHeight="10"
ItemsSource="{Binding LecWires}"
Style="{StaticResource ListView.Small}">
VirtualizingPanel.ScrollUnit="Pixel">
<ListView.ItemContainerStyle>
<Style BasedOn="{StaticResource ListViewItemBaseStyle.Small}" TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Margin" Value="2" />
<Style.Triggers>
<DataTrigger Binding="{Binding Layouted}" Value="True">
<Setter Property="Background" Value="#18a05d" />
<Setter Property="Foreground" Value="White" />
</DataTrigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView>
<GridViewColumn
Width="80"
DisplayMemberBinding="{Binding SeqNo}"
Header="序号" />
<GridViewColumn Width="330" Header="线型号">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox
Width="300"
MaxWidth="300"
GotFocus="TextBox_GotFocus"
IsReadOnly="True"
Text="{Binding WireModelSpecification}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
<ListView.ItemTemplate>
<DataTemplate>
<Grid Margin="5" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBox
Grid.Row="0"
Margin="0,2,0,5"
HorizontalAlignment="Stretch"
GotFocus="TextBox_GotFocus"
IsReadOnly="True"
TextAlignment="Center">
<TextBox.Text>
<MultiBinding StringFormat="{}{0}-{1}">
<Binding Path="ApplicationScenario" />
<Binding Path="WireKey" />
</MultiBinding>
</TextBox.Text>
</TextBox>
<TextBox
Grid.Row="1"
Margin="0,2,0,5"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
GotFocus="TextBox_GotFocus"
IsReadOnly="True"
Text="{Binding WireModelSpecification}" />
<TextBlock
Grid.Row="2"
Margin="0,2"
HorizontalAlignment="Center"
Text="{Binding FrontConnectorModel, StringFormat=前连接:{0}}"
TextAlignment="Center" />
<TextBlock
Grid.Row="3"
Margin="0,2"
HorizontalAlignment="Center"
Text="{Binding RearConnectorModel, StringFormat=后连接:{0}}"
TextAlignment="Center" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
<!-- 添加一个空数据模板 -->
<ListView.Template>
<ControlTemplate>
<hc:ScrollViewer>
<ItemsPresenter />
</hc:ScrollViewer>
</ControlTemplate>
</ListView.Template>
</ListView>
<hc:SimpleStackPanel
Grid.Row="4"
Margin="10"

View File

@ -61,7 +61,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View.MultiCoreWire.LayoutHelper
try
{
Clipboard.SetDataObject(content);
Growl.SuccessGlobal("复制成功!");
Growl.SuccessGlobal($"{content} 复制成功!");
}
catch (Exception ex)
{

View File

@ -40,8 +40,14 @@
<Setter Property="Margin" Value="2" />
</Style>
</hc:SimpleStackPanel.Resources>
<hc:TextBox hc:TitleElement.Title="机构编号" hc:TitleElement.TitlePlacement="Left" />
<hc:TextBox hc:TitleElement.Title="机构名称" hc:TitleElement.TitlePlacement="Left" />
<hc:TextBox
hc:TitleElement.Title="机构编号"
hc:TitleElement.TitlePlacement="Left"
Text="{Binding MechanismNo}" />
<hc:TextBox
hc:TitleElement.Title="机构名称"
hc:TitleElement.TitlePlacement="Left"
Text="{Binding MechanismName}" />
</hc:SimpleStackPanel>
<Button
Margin="10,0"
@ -50,6 +56,7 @@
Style="{StaticResource ButtonSuccess}" />
<Button
Margin="10,0"
Click="ExportBtn_Click"
Content="导出下单表"
Style="{StaticResource ButtonSuccess}" />
</hc:SimpleStackPanel>
@ -273,6 +280,26 @@
ItemsSource="{Binding WireModelSpecifications}"
SelectedValue="{Binding WireModelSpecification}" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel
Margin="2"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock
MinWidth="70"
VerticalAlignment="Center"
Text="线材外皮颜色:" />
<hc:ComboBox
MinWidth="60"
Margin="10,0"
SelectedValue="{Binding WireColorName}"
SelectedValuePath="Tag">
<ComboBoxItem
Content="黑色"
Selector.IsSelected="True"
Tag="BK" />
<ComboBoxItem Content="橙色" Tag="OG" />
</hc:ComboBox>
</hc:SimpleStackPanel>
</hc:SimpleStackPanel>
<DockPanel
Grid.Row="1"
@ -382,18 +409,31 @@
<ListBox.ItemTemplate>
<DataTemplate>
<Border>
<Expander>
<Expander IsExpanded="False">
<Expander.Resources>
<Style BasedOn="{StaticResource ExpanderBaseStyle}" TargetType="Expander">
<Setter Property="Background" Value="#CC002255" />
<Setter Property="Foreground" Value="White" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsError}" Value="True">
<Setter Property="Background" Value="#dc4d41" />
</DataTrigger>
</Style.Triggers>
</Style>
</Expander.Resources>
<Expander.Header>
<hc:SimpleStackPanel Orientation="Horizontal">
<TextBlock
MinWidth="700"
VerticalAlignment="Center"
Foreground="White"
Text="{Binding WireModelSpecification}" />
<TextBlock
Margin="10,0"
VerticalAlignment="Center"
Foreground="White"
Text="{Binding CheckedMsg}" />
</hc:SimpleStackPanel>
</Expander.Header>
<DataGrid
@ -403,7 +443,6 @@
ItemsSource="{Binding Children}">
<DataGrid.Resources>
<localconverter:WireColorConverter x:Key="WireColorConverter" />
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding WireModelSpecification}" Header="线芯名称" />
@ -422,7 +461,7 @@
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="BorderThickness" Value="0,0,0,2" />
<Setter Property="BorderThickness" Value="0,0,0,4" />
<Setter Property="hc:BorderElement.CornerRadius" Value="0" />
<Setter Property="Margin" Value="0" />
</Style>

View File

@ -64,5 +64,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
this.Close();
}
private void ExportBtn_Click(object sender, RoutedEventArgs e)
{
viewModel.ExportLines();
}
}
}

View File

@ -59,6 +59,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
{
_currentFlexDesigner.SelectSet.SelectionChanged += SelectSet_SelectionChanged;
}
LecWires = [];
LoadData();
}
private void SelectSet_SelectionChanged(object sender, EventArgs e)
@ -104,19 +105,26 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
if (linePart != null)
{
var libName = linePart?.LibraryName;
var name = linePart.Name;
// 绝缘层选择上一层的导线来获取信息
if (part is OccCablesInsulatorGraph)
{
libName = (part.Parents?.First() as OccCableForked).LibraryName;
name = (part.Parents?.First() as OccCableForked).Name;
//partLineModel = (part.Parents?.First() as OccCableForked).LibraryName.Split('&')[1];
}
if(LecWires.Any(it =>it.WireModelSpecification == libName))
{
var wire = LecWires.FirstOrDefault(it => it.WireModelSpecification == libName && !it.Layouted);
var wire = LecWires.FirstOrDefault(it =>
it.WireModelSpecification == libName
&& name == $"{it.ApplicationScenario}-{it.WireKey}"
&& !it.Layouted);
if(wire != null)
{
wire.Layouted = true;
_service.UpdateWireIsLayout(wire.Id);
OnPropertyChanged(nameof(LecWires));
OnPropertyChanged("Layouted");
}
}
}
@ -194,6 +202,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
private void UpdatePropNotify()
{
OnPropertyChanged(nameof(LecWires));
OnPropertyChanged(nameof(ApplicationScenario));
OnPropertyChanged(nameof(HasPrev));
OnPropertyChanged(nameof(HasNext));
@ -210,7 +219,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
OnPropertyChanged(nameof(ApplicationScenario));
}
}
private ObservableCollection<MultiCoreWireDataModel> _lecWires = [];
private ObservableCollection<MultiCoreWireDataModel> _lecWires;
public ObservableCollection<MultiCoreWireDataModel> LecWires
{

View File

@ -4,7 +4,9 @@ using EPLAN.Harness.Core.Utils;
using EPLAN.Harness.ProjectCore;
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
using HandyControl.Controls;
using MiniExcelLibs;
using MiniExcelLibs.Attributes;
using MiniExcelLibs.OpenXml;
using Sinvo.EplanHpD.Plugin.Service;
using Sinvo.EplanHpD.Plugin.Service.Model;
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
@ -56,6 +58,34 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
}
private string _mechanismNo;
/// <summary>
/// 机构号
/// </summary>
public string MechanismNo
{
get => _mechanismNo;
set
{
_mechanismNo = value;
OnPropertyChanged(nameof(MechanismNo));
}
}
private string _mechanismName;
/// <summary>
/// 机构名称
/// </summary>
public string MechanismName
{
get => _mechanismName;
set
{
_mechanismName = value;
OnPropertyChanged(nameof(MechanismName));
}
}
private string _applicationScenario;
/// <summary>
/// 应用场景
@ -457,6 +487,21 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
OnPropertyChanged(nameof(RearConnectorCount));
}
}
private string _wireColorName;
/// <summary>
/// 线材外皮颜色
/// </summary>
public string WireColorName
{
get => _wireColorName;
set
{
_wireColorName = value;
OnPropertyChanged(nameof(WireColorName));
}
}
#endregion
@ -485,22 +530,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
{
wiresData.ForEach(wire =>
{
LecWires.Add(new MultiCoreWireDataModel
{
Id = wire.Id,
SeqNo = wire.SeqNo,
ApplicationScenario = wire.ApplicationScenario,
WireKey = Wirekey,
WireDiameterSpecification = wire.WireDiameterSpecification,
IsHighFlexibilityStr = wire.IsHighFlexibilityStr,
WireCoreCount = wire.WireCoreCount,
WireModelSpecification = wire.WireModelSpecification,
FrontConnectorModel = wire.FrontConnectorModel,
RearConnectorModel = wire.RearConnectorModel,
UserId = wire.UserId,
ProjectName = wire.ProjectName,
UniqueKey = wire.UniqueKey
});
var wiredata = MapperUtil.MapFor<MultiCoreWireDataModel, MultiCoreWireLecDBModel>(wire);
LecWires.Add(wiredata);
});
}
}
@ -560,12 +591,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
HighFlexibilitys = [.. datas.Where(it => !string.IsNullOrEmpty(it.IsHighFlexibilityStr)).Select(it => it.IsHighFlexibilityStr).Distinct(), ""];
WireCores = [.. datas.Where(it => !string.IsNullOrEmpty(it.WireCoreCount)).Select(it => it.WireCoreCount).Distinct(), ""];
//if (WireCores.Where(it => !string.IsNullOrEmpty(it)).Count() == 1 && propName != nameof(WireCoreCount))
//{
// WireCoreCount = WireCores.FirstOrDefault();
//}
//FrontConnectorModels = [.. datas.Where(it => !string.IsNullOrEmpty(it.FrontTerminalModel)).Select(it => it.FrontTerminalModel).Distinct(), ""];
//BackConnectorModels = [.. datas.Where(it => !string.IsNullOrEmpty(it.BackTerminalModel)).Select(it => it.BackTerminalModel).Distinct(), ""];
WireModelSpecifications = [.. datas.Where(it => !string.IsNullOrEmpty(it.WireModelSpecification)).Select(it => it.WireModelSpecification).Distinct(), ""];
if (WireModelSpecifications.Where(it => !string.IsNullOrEmpty(it)).Count() == 1 && propName != nameof(WireModelSpecification))
{
@ -585,27 +610,29 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
var des = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(it => it.ID == _docId) ?? throw new Exception("设计器不存在");
var cables = des.GetOrganizerOccurrences(_docId, typeof(OccCableForked));
Wires?.Clear();
cables.Where(it => it.Name?.StartsWith("信号线") ?? false).ForEach(it =>
cables.Where(it => StartWithApplicationScenario(it.Name)).ForEach(it =>
{
var wireData = new MultiCoreWireDataModel
{
WireModelSpecification = $"{it.Name} / {it.LibraryName}"
};
//Debug.WriteLine($"{it.Name} - {it.LibraryName}");
if(LecWires != null && !LecWires.Any(i => $"{i.ApplicationScenario}-{i.WireKey}" == it.Name && i.WireModelSpecification == it.LibraryName))
{
wireData.IsError = true;
wireData.CheckedMsg = "无法匹配选型数据!";
wireData.IsChecked = true;
}
if (it.Children?.Any() ?? false)
{
it.Children.ForEach(c =>
{
//Debug.WriteLine($"\t{c.Name} - {c.LibraryName}");
if (c.Children?.Any() ?? false)
{
c.Children.Where(ccc => ccc is OccWire).ForEach(cc =>
{
if (cc is OccWire wire)
{
//var color = materials.Where(col => col == wire.Color)
//Debug.WriteLine($"\t\t{wire.Name} - {wire.LibraryName} - {FlexColors.GetName(wire.Color.Major)}");
wireData.Children.Add(new MultiCoreWireDataModel
var wireItem = new MultiCoreWireDataModel
{
WireModelSpecification = wire.Name,
WireColorName = FlexColors.GetName(wire.Color.Major) + (FlexColors.GetName(wire.Color.Minor) == "未设置" ? "" : " " + FlexColors.GetName(wire.Color.Minor)),
@ -614,7 +641,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
IsMultiColor = wire.Color.Major.IsValid() && wire.Color.Minor.IsValid(),
FrontConnectorModel = wire.GetEndingPins()?.FirstOrDefault()?.Parents?.FirstOrDefault()?.LibraryName,
RearConnectorModel = wire.GetEndingPins()?.LastOrDefault()?.Parents?.FirstOrDefault()?.LibraryName
});
};
wireData.Children.Add(wireItem);
}
});
}
@ -624,6 +653,18 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
});
return Task.CompletedTask;
}
public bool StartWithApplicationScenario(string wireName)
{
if(ApplicationScenarios != null && ApplicationScenarios.Any())
{
return ApplicationScenarios.Where(it => !string.IsNullOrEmpty(it)).Any(wireName.StartsWith);
}
else
{
return false;
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
@ -641,8 +682,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
WireModelSpecification = "";
FrontConnectorType = "";
RearConnectorType = "";
FrontConnectorModel = "";
RearConnectorModel = "";
LecChanging = false;
Wirekey = "";
WireColorName = "";
OnLecChanged("");
}
@ -664,6 +708,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
HandyControl.Controls.MessageBox.Show("不能两头都是插头!", caption: "提示", icon: MessageBoxImage.Warning);
return;
}
if(RearConnectorCount == 0 || FrontConnectorCount == 0)
{
HandyControl.Controls.MessageBox.Show("连接物数量不能为0", caption: "提示", icon: MessageBoxImage.Warning);
return;
}
if (LecWires.Any(it => it.ApplicationScenario == ApplicationScenario && it.WireModelSpecification == WireModelSpecification
&& it.FrontConnectorModel == FrontConnectorModel && it.RearConnectorModel == RearConnectorModel))
{
@ -700,6 +749,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
RearConnectorMCode = rearConnectorMCode,
RearConnectorIsPin = RearConnectorType == "端子",
WireColorName = WireColorName,
UserId = PluginServices.user.ID,
ProjectName = LectotypeManager.CURRENT_DOC_NAME,
UniqueKey = $"{LectotypeManager.CURRENT_DOC_NAME}_{PluginServices.user.ID}"
@ -723,7 +774,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
if (!wire.RearConnectorIsPin)
{
// 获取插头信息
// 获取插头信息
var connectorInfo = MultiCoreWireExcelHelper.Instance.GetConnectorHeatShrinkMappingDatas(wire.RearConnectorModel);
if (connectorInfo != null)
@ -764,6 +814,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
}
}).ContinueWith(x =>
{
// TODO Save line data
//_service.SaveData(new MultiCoreWireLecDBModel
//{
// Id = wire.Id,
@ -784,9 +835,12 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
// RearConnectorQuantity = wire.RearConnectorQuantity
//});
var wireData = MapperUtil.MapFor<MultiCoreWireLecDBModel, MultiCoreWireDataModel>(wire);
Application.Current.Dispatcher.BeginInvoke(() =>
{
_service.SaveData(wireData);
LecWires.Add(wire);
ClearLecData();
OnPropertyChanged(nameof(LecWires));
});
});
@ -802,6 +856,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
{
try
{
var result = HandyControl.Controls.MessageBox.Show($"是否清除数据?", "提示", button: MessageBoxButton.YesNo);
if (result != MessageBoxResult.Yes)
{
return;
}
LecWires.Clear();
_service.ClearSelf(CurrUniqueKey);
}
@ -830,8 +889,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
}
}
//ReOrderLecWires();
}
}
@ -862,15 +919,26 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
OnFrontConnectorTypeModels(FrontConnectorType);
OnRearConnectorTypeChange(RearConnectorType);
}
//private void ReOrderLecWires()
//{
// int seq = 1;
// LecWires.OrderBy(it => it.SeqNo).ForEach(it =>
// {
// it.SeqNo = seq;
// seq++;
// });
// OnPropertyChanged(nameof(LecWires));
//}
public void ExportLines()
{
if(string.IsNullOrEmpty(MechanismNo) || string.IsNullOrEmpty(MechanismName))
{
HandyControl.Controls.MessageBox.Show("机构号或机构名称不能为空!", caption: "提示", icon: MessageBoxImage.Warning);
return;
}
MiniExcel.SaveAsByTemplate("D:\\Desktop\\123.xlsx", "D:\\Desktop\\EPLAN\\多芯线\\副本多芯线下单模板_测试.xlsx", new
{
data = new List<dynamic> {
new { MechanismNo, MechanismName, WireModelStr= '1' },
new { MechanismNo, MechanismName, WireModelStr= '2' },
new { MechanismNo, MechanismName, WireModelStr= '3' }
}
},new OpenXmlConfiguration
{
FillMergedCells = true
});
}
}
}