@@ -7,6 +7,7 @@ | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" /> | |||
<PackageReference Include="SqlSugarCore" Version="5.1.4.84" /> | |||
</ItemGroup> | |||
@@ -1,5 +1,6 @@ | |||
using BPA.Message.Enum; | |||
using BPASmartClient.Device; | |||
using BPASmartClient.MorkCL.Model.Json; | |||
using BPASmartClient.MorkCL.Server; | |||
using SqlSugar; | |||
using System; | |||
@@ -48,6 +49,11 @@ namespace BPASmartClient.MorkCL | |||
devices[EDeviceType.机器人].Init(ConnectPar.RobotIP); | |||
devices[EDeviceType.压力锅].Init(ConnectPar.PressureCookerIP); | |||
devices[EDeviceType.外部设备].Init(ConnectPar.PPortName); | |||
#region 读取本地文件数据 | |||
Json<RecipesInfo>.Read(); | |||
Json<MaterialsInfo>.Read(); | |||
#endregion | |||
} | |||
public override void MainTask() | |||
@@ -13,7 +13,16 @@ namespace BPASmartClient.MorkCL.HelpClass | |||
public class FuncSet | |||
{ | |||
public int Step { get; set; } | |||
public string FuncName { get; set; } | |||
private string _FuncName; | |||
public string FuncName | |||
{ | |||
get { return _FuncName; } | |||
set { _FuncName = value; | |||
FuncPars = InitData.FunParInit[(EFunc)Enum.Parse(typeof(EFunc),value)]?.ToList(); | |||
} | |||
} | |||
public List<FuncPar> FuncPars { get; set; } | |||
} | |||
} |
@@ -0,0 +1,25 @@ | |||
using BPASmartClient.MorkCL.Model.DataInfo; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.MorkCL.Model.Json | |||
{ | |||
public class MaterialsInfo | |||
{ | |||
/// <summary> | |||
/// 辅料信息集合 | |||
/// </summary> | |||
public ObservableCollection<AccessoriesInfo> Accessories { get; set; }=new ObservableCollection<AccessoriesInfo>(); | |||
/// <summary> | |||
/// 主料信息集合 | |||
/// </summary> | |||
public ObservableCollection<IngredientsInfo> Ingredients { get; set; }=new ObservableCollection<IngredientsInfo>(); | |||
/// <summary> | |||
/// 调料信息集合 | |||
/// </summary> | |||
public ObservableCollection<SeasoningInfo> Seasonings { get; set; }=new ObservableCollection<SeasoningInfo>(); | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
using BPASmartClient.MorkCL.Model.Recipe; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.MorkCL.Model.Json | |||
{ | |||
public class RecipesInfo | |||
{ | |||
public ObservableCollection<TempRecipeData> LocalRecipes { get; set; }=new ObservableCollection<TempRecipeData>(); | |||
} | |||
} |
@@ -0,0 +1,43 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.MorkCL.Model.Recipe | |||
{ | |||
public class TempRecipeData:NotifyBase | |||
{ | |||
private string _Name; | |||
public string Name | |||
{ | |||
get { return _Name; } | |||
set { _Name = value; OnPropertyChanged(); } | |||
} | |||
private string _ID; | |||
public string ID | |||
{ | |||
get { return _ID; } | |||
set { _ID = value; OnPropertyChanged(); } | |||
} | |||
private string _Remark; | |||
public string Remark | |||
{ | |||
get { return _Remark; } | |||
set { _Remark = value; OnPropertyChanged(); } | |||
} | |||
private Dictionary<EFunc, FuncPar[]> _Functions; | |||
public Dictionary<EFunc, FuncPar[]> Functions | |||
{ | |||
get { return _Functions; } | |||
set { _Functions = value; OnPropertyChanged(); } | |||
} | |||
} | |||
} |
@@ -48,12 +48,12 @@ | |||
<Button | |||
Margin="30,0" | |||
Content="新增辅料数据" | |||
DockPanel.Dock="Right" /> | |||
DockPanel.Dock="Right" Command="{Binding AddMaterialCommand}" CommandParameter="辅料"/> | |||
<Button | |||
Margin="30,0" | |||
Content="保存数据" | |||
DockPanel.Dock="Right" /> | |||
DockPanel.Dock="Right" Command="{Binding SaveMaterialInfoCommand}" CommandParameter="辅料"/> | |||
</DockPanel> | |||
<!--#region 表格标题栏设置--> | |||
<Grid | |||
@@ -130,7 +130,7 @@ | |||
<TextBox | |||
Style="{StaticResource DataShowTextBoxStyle}" | |||
Text="{Binding Name}" | |||
TextAlignment="Center" /> | |||
TextAlignment="Center" MinWidth="100"/> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
@@ -196,12 +196,12 @@ | |||
<Button | |||
Margin="30,0" | |||
Content="新增调料数据" | |||
DockPanel.Dock="Right" /> | |||
DockPanel.Dock="Right" Command="{Binding AddMaterialCommand}" CommandParameter="调料"/> | |||
<Button | |||
Margin="30,0" | |||
Content="保存数据" | |||
DockPanel.Dock="Right" /> | |||
DockPanel.Dock="Right" Command="{Binding SaveMaterialInfoCommand}" CommandParameter="调料"/> | |||
</DockPanel> | |||
<!--#region 表格标题栏设置--> | |||
<Grid | |||
@@ -275,7 +275,7 @@ | |||
<TextBox | |||
Style="{StaticResource DataShowTextBoxStyle}" | |||
Text="{Binding Name}" | |||
TextAlignment="Center" /> | |||
TextAlignment="Center" MinWidth="100"/> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
@@ -347,12 +347,12 @@ | |||
<Button | |||
Margin="30,0" | |||
Content="新增主料数据" | |||
DockPanel.Dock="Right" /> | |||
DockPanel.Dock="Right" Command="{Binding AddMaterialCommand}" CommandParameter="主料"/> | |||
<Button | |||
Margin="30,0" | |||
Content="保存数据" | |||
DockPanel.Dock="Right" /> | |||
DockPanel.Dock="Right" Command="{Binding SaveMaterialInfoCommand}" CommandParameter="主料"/> | |||
</DockPanel> | |||
<!--#region 表格标题栏设置--> | |||
<Grid | |||
@@ -424,7 +424,7 @@ | |||
<TextBox | |||
Style="{StaticResource DataShowTextBoxStyle}" | |||
Text="{Binding Name}" | |||
TextAlignment="Center" /> | |||
TextAlignment="Center" MinWidth="100"/> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
@@ -433,7 +433,7 @@ | |||
<Grid Grid.Column="2"> | |||
<Button | |||
Command="{Binding DataContext.RemoveSeasoningCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
Command="{Binding DataContext.RemoveIngreditentCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Id}" | |||
Content="删除" | |||
FontSize="16" | |||
@@ -1,11 +1,13 @@ | |||
<UserControl x:Class="BPASmartClient.MorkCL.View.Debug" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.MorkCL.View" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<UserControl | |||
x:Class="BPASmartClient.MorkCL.View.Debug" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.MorkCL.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" Name="调试界面" | |||
mc:Ignorable="d"> | |||
<UserControl.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
@@ -14,7 +16,5 @@ | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</UserControl.Resources> | |||
<Grid> | |||
</Grid> | |||
<Grid /> | |||
</UserControl> |
@@ -76,15 +76,25 @@ | |||
</Grid.RowDefinitions> | |||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal"> | |||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding ParName, StringFormat={}{0}:}" /> | |||
<TextBox Style="{StaticResource InputTextboxStyle}" Text="{Binding ParValue}" /> | |||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding ParUnit}" HorizontalAlignment="Left"/> | |||
<TextBox | |||
Height="30" | |||
BorderBrush="DeepSkyBlue" | |||
BorderThickness="1" | |||
Style="{StaticResource InputTextboxStyle}" | |||
Text="{Binding ParValue}" /> | |||
<TextBlock | |||
Margin="5,0" | |||
HorizontalAlignment="Left" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="{Binding ParUnit}" /> | |||
</StackPanel> | |||
<TextBlock | |||
Grid.Row="1" | |||
HorizontalAlignment="Left" | |||
FontSize="12" | |||
Foreground="#7DC3D5" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="{Binding ParDescribe, StringFormat=备注:{0}}" Foreground="#7DC3D5"/> | |||
Text="{Binding ParDescribe, StringFormat=备注:{0}}" /> | |||
</Grid> | |||
</DataTemplate> | |||
@@ -23,6 +23,11 @@ namespace BPASmartClient.MorkCL.View | |||
{ | |||
InitializeComponent(); | |||
this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; | |||
ActionManage.GetInstance.Register((object b) => { | |||
this.DialogResult =(bool)b ; | |||
this.Close(); | |||
},"CloseFuncParmEditView",true); | |||
} | |||
private void Button_Click(object sender, RoutedEventArgs e) | |||
@@ -2,6 +2,7 @@ | |||
x:Class="BPASmartClient.MorkCL.View.EditRecipeView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:Behaviors="http://schemas.microsoft.com/xaml/behaviors" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.MorkCL.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
@@ -101,22 +102,19 @@ | |||
<Grid Margin="0,10,0,0" Background="#ff0C255F"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="50"/> | |||
<ColumnDefinition Width="50" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Grid Grid.Column="0"> | |||
<TextBlock | |||
Style="{StaticResource TitleTextblockStyle}" | |||
Text="步骤" /> | |||
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="步骤" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="1" | |||
@@ -136,12 +134,10 @@ | |||
Style="{StaticResource TitleTextblockStyle}" | |||
Text="删除" /> | |||
<Border | |||
Grid.ColumnSpan="10" | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<!--#endregion--> | |||
@@ -153,30 +149,31 @@ | |||
<DataTemplate> | |||
<Grid Name="gr" Height="30"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="50"/> | |||
<ColumnDefinition/> | |||
<ColumnDefinition Width="50" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Grid> | |||
<TextBlock | |||
Grid.Column="0" | |||
Style="{StaticResource LeftAligentTextStyle}" Text="{Binding Step}" HorizontalAlignment="Center" | |||
TextAlignment="Right" /> | |||
Grid.Column="0" | |||
HorizontalAlignment="Center" | |||
Style="{StaticResource LeftAligentTextStyle}" | |||
Text="{Binding Step}" | |||
TextAlignment="Right" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="2,0,2,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<Grid Grid.Column="1"> | |||
<ComboBox | |||
FontSize="18" | |||
IsReadOnly="True" | |||
Text="{Binding FuncName}" | |||
ItemsSource="{Binding DataContext.AllFunc, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"> | |||
ItemsSource="{Binding DataContext.AllFunc, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
Text="{Binding FuncName}"> | |||
</ComboBox> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
@@ -184,7 +181,6 @@ | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<Grid Grid.Column="2"> | |||
<Button | |||
Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
@@ -215,7 +211,6 @@ | |||
Grid.ColumnSpan="10" | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,1" /> | |||
</Grid> | |||
<DataTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
@@ -232,4 +227,4 @@ | |||
<!--#endregion--> | |||
</Grid> | |||
</Border> | |||
</Window> | |||
</Window> |
@@ -23,6 +23,11 @@ namespace BPASmartClient.MorkCL.View | |||
{ | |||
InitializeComponent(); | |||
this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; | |||
ActionManage.GetInstance.Register(() => | |||
{ | |||
this.Close(); | |||
}, "CloseEditRecipeView", true); | |||
} | |||
private void Button_Click(object sender, RoutedEventArgs e) | |||
@@ -5,10 +5,14 @@ | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.MorkCL.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:vm="clr-namespace:BPASmartClient.MorkCL.ViewModel" | |||
Name="库位状态" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.DataContext> | |||
<vm:ItemStorageViewModel /> | |||
</UserControl.DataContext> | |||
<UserControl.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
@@ -29,7 +33,7 @@ | |||
<!--#region 入库电子称状态--> | |||
<StackPanel> | |||
<TextBlock Width="200" Text="{Binding Weight, StringFormat=当前重量:{0}g}" /> | |||
<TextBlock Width="200" Text="{Binding ScaleCurrentWeight, StringFormat=秤当前重量:{0} g}" /> | |||
</StackPanel> | |||
<!--#endregion--> | |||
@@ -53,8 +57,10 @@ | |||
Grid.Row="1" | |||
Grid.Column="1" | |||
Margin="3" | |||
Background="AliceBlue" | |||
BorderThickness="1"> | |||
Background="Transparent" | |||
BorderThickness="1" | |||
ItemsSource="{Binding Materials}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<UniformGrid | |||
@@ -67,7 +73,50 @@ | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Border Background="Black" /> | |||
<Border Margin="5" Background="Transparent"> | |||
<Grid Height="180"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<TextBlock | |||
Margin="0,0,0,25" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Bottom" | |||
FontSize="25" | |||
Foreground="#ffccd61f" | |||
Text="{Binding Name}" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
Margin="0,0,0,35" | |||
HorizontalAlignment="Center" | |||
FontSize="20" | |||
Foreground="#FF0084FF" | |||
Text="{Binding Weight,StringFormat={}{0} KG}" /> | |||
<StackPanel | |||
Grid.Row="1" | |||
Margin="0,25" | |||
HorizontalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
FontSize="20" | |||
Foreground="#FF0084FF" | |||
Text="{Binding ID}" /> | |||
<TextBlock | |||
FontSize="20" | |||
Foreground="#FF0084FF" | |||
Text=" 号仓" /> | |||
</StackPanel> | |||
<Image | |||
Grid.RowSpan="2" | |||
Source="/BPASmartClient.CustomResource;component/Image/光柱.png" | |||
Stretch="Fill" /> | |||
</Grid> | |||
</Border> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
@@ -6,7 +6,7 @@ | |||
xmlns:local="clr-namespace:BPASmartClient.MorkCL.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
d:DesignWidth="800" Name="参数设置" | |||
mc:Ignorable="d"> | |||
<UserControl.Resources> | |||
<ResourceDictionary> | |||
@@ -171,18 +171,18 @@ | |||
<ColumnDefinition Width="100" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBox | |||
<TextBlock | |||
Grid.Column="0" | |||
IsReadOnly="True" | |||
Style="{StaticResource DataShowTextBoxStyle}" | |||
Text="{Binding ID}" | |||
Style="{StaticResource TextBlockStyle}" | |||
HorizontalAlignment="Center" | |||
Text="{Binding Name}" | |||
TextAlignment="Center" /> | |||
<Grid Grid.Column="1"> | |||
<TextBox | |||
Style="{StaticResource DataShowTextBoxStyle}" | |||
Text="{Binding Remark}" | |||
TextAlignment="Center" /> | |||
TextAlignment="Center" MinWidth="200"/> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
@@ -205,7 +205,7 @@ | |||
<Grid Grid.Column="3" Margin="5"> | |||
<Button | |||
Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding ID}" | |||
CommandParameter="{Binding}" | |||
Content="编辑" | |||
FontSize="16" | |||
Style="{StaticResource IssueRecipeButtonStyle}" /> | |||
@@ -5,6 +5,7 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.MorkCL.Model.DataInfo; | |||
using BPASmartClient.MorkCL.Model.Json; | |||
namespace BPASmartClient.MorkCL.ViewModel | |||
{ | |||
@@ -12,12 +13,51 @@ namespace BPASmartClient.MorkCL.ViewModel | |||
{ | |||
public AddRawMaterialViewModel() | |||
{ | |||
InitialTestData(); | |||
RemoveAccessoryCommand = new BPARelayCommand<string>((Id) => | |||
{ | |||
Accessories.Remove(Accessories.FirstOrDefault(a=>a.Id==Id)); | |||
}); | |||
RemoveIngreditentCommand = new BPARelayCommand<string>((Id) => | |||
{ | |||
Ingredients.Remove(Ingredients.FirstOrDefault(a => a.Id == Id)); | |||
}); | |||
RemoveSeasoningCommand = new BPARelayCommand<string>((Id) => | |||
{ | |||
Seasonings.Remove(Seasonings.FirstOrDefault(a => a.Id == Id)); | |||
}); | |||
AddMaterialCommand = new BPARelayCommand<string>((materialType) => | |||
{ | |||
switch (materialType) | |||
{ | |||
case "主料":Ingredients.Add(new IngredientsInfo()); | |||
break; | |||
case "辅料": | |||
Accessories.Add(new AccessoriesInfo()); | |||
break; | |||
case "调料": | |||
Seasonings.Add(new SeasoningInfo()); | |||
break; | |||
} | |||
}); | |||
SaveMaterialInfoCommand = new BPARelayCommand<string>((materialType) => | |||
{ | |||
//TODO:暂时不写 可能使用数据库保存。 | |||
switch (materialType) | |||
{ | |||
case "主料": | |||
break; | |||
case "辅料": | |||
break; | |||
case "调料": | |||
break; | |||
} | |||
}); | |||
} | |||
private void InitialTestData() | |||
@@ -67,5 +107,13 @@ namespace BPASmartClient.MorkCL.ViewModel | |||
/// 删除调料信息 | |||
/// </summary> | |||
public BPARelayCommand<string> RemoveSeasoningCommand { get; set; } | |||
/// <summary> | |||
/// 添加物料信息。 | |||
/// </summary> | |||
public BPARelayCommand<string> AddMaterialCommand { get; set; } | |||
/// <summary> | |||
/// 保存物料信息。 | |||
/// </summary> | |||
public BPARelayCommand<string> SaveMaterialInfoCommand { get; set; } | |||
} | |||
} |
@@ -13,7 +13,6 @@ namespace BPASmartClient.MorkCL.ViewModel | |||
public EditFunctionParamViewModel() | |||
{ | |||
//AddTestData(); | |||
ActionManage.GetInstance.CancelRegister("OpenFuncEditView"); | |||
ActionManage.GetInstance.Register((object o) => | |||
{ | |||
FuncPars.Clear(); | |||
@@ -34,7 +33,13 @@ namespace BPASmartClient.MorkCL.ViewModel | |||
} | |||
} | |||
} | |||
}, "OpenFuncEditView"); | |||
}, "OpenFuncEditView",true); | |||
SaveParamCommand = new BPARelayCommand(() =>{ | |||
//关闭视图窗口。 | |||
ActionManage.GetInstance.Send("CloseFuncParmEditView",true); | |||
}); | |||
} | |||
void AddTestData() | |||
@@ -59,15 +64,6 @@ namespace BPASmartClient.MorkCL.ViewModel | |||
/// 保存参数。 | |||
/// </summary> | |||
public BPARelayCommand SaveParamCommand { get; set; } | |||
/// <summary> | |||
/// 添加功能 | |||
/// </summary> | |||
public BPARelayCommand AddParamCommand { get; set; } | |||
/// <summary> | |||
/// 删除功能。 | |||
/// </summary> | |||
public BPARelayCommand<object> RemoveCommand { get; set; } | |||
private string _FuncName; | |||
/// <summary> | |||
@@ -79,7 +75,7 @@ namespace BPASmartClient.MorkCL.ViewModel | |||
set { _FuncName = value;OnPropertyChanged(); } | |||
} | |||
public ObservableCollection<FuncPar> FuncPars { get; set; } = new ObservableCollection<FuncPar>(); | |||
public static ObservableCollection<FuncPar> FuncPars { get; set; } = new ObservableCollection<FuncPar>(); | |||
} | |||
@@ -1,42 +1,141 @@ | |||
using BPASmartClient.MorkCL.HelpClass; | |||
using BPASmartClient.MorkCL.Model.Func; | |||
using System; | |||
using System.CodeDom; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.MorkCL.HelpClass; | |||
using BPASmartClient.MorkCL.Model.Json; | |||
using BPASmartClient.MorkCL.Model.Recipe; | |||
namespace BPASmartClient.MorkCL.ViewModel | |||
{ | |||
public class EditRecipeViewModel:NotifyBase | |||
public class EditRecipeViewModel : NotifyBase | |||
{ | |||
public EditRecipeViewModel() | |||
{ | |||
AddTestData(); | |||
//AddTestData(); | |||
Functions = new(); | |||
ActionManage.GetInstance.Register((object o) => | |||
{ | |||
if (o != null && o is TempRecipeData recipe) | |||
{ | |||
this.Name = recipe.Name; | |||
this.ID = recipe.ID; | |||
int step = 0; | |||
Functions.Clear(); | |||
foreach (var func in recipe.Functions) | |||
{ | |||
step++; | |||
Functions.Add(new FuncSet() { FuncName = Enum.GetName<EFunc>(func.Key), FuncPars = func.Value?.ToList(), Step = step }); | |||
} | |||
} | |||
}, "OpenRecipeEditView",true); | |||
AllFunc = new ObservableCollection<string>(); | |||
foreach (var item in Enum.GetNames(typeof(EFunc))) | |||
{ | |||
AllFunc.Add(item); | |||
} | |||
SaveParamCommand = new BPARelayCommand(() => | |||
{ | |||
if (!MessageNotify.GetInstance.ShowDialog("请确认是否保存该配方?")) | |||
{ | |||
return; | |||
} | |||
#region 数据验证 | |||
if (String.IsNullOrEmpty(Name)||Name.Length<=0) | |||
{ | |||
MessageNotify.GetInstance.ShowDialog("配方名称不可为空,请重新输入后重试!"); | |||
return; | |||
} | |||
if (!int.TryParse(ID,out int Id)) | |||
{ | |||
MessageNotify.GetInstance.ShowDialog("配方ID不是数字,请重新输入后重试!"); | |||
return; | |||
} | |||
if (Functions==null||Functions.Count<=0) | |||
{ | |||
MessageNotify.GetInstance.ShowDialog("没有可保存的配方功能配置,请验证后重试!"); | |||
return; | |||
} | |||
#endregion | |||
Dictionary<EFunc, FuncPar[]> TempFunces=new Dictionary<EFunc, FuncPar[]>(); | |||
//查询是否是编辑现有配方。 | |||
int index = Array.FindIndex(Json<RecipesInfo>.Data.LocalRecipes.ToArray(), p => p.ID == ID); | |||
//修改配方 | |||
if (index>=0) | |||
{ | |||
foreach (var item in Functions) | |||
{ | |||
TempFunces.Add((EFunc)Enum.Parse(typeof(EFunc), item.FuncName), item.FuncPars?.ToArray()); | |||
} | |||
Json<RecipesInfo>.Data.LocalRecipes.ElementAt(index).ID = ID; | |||
Json<RecipesInfo>.Data.LocalRecipes.ElementAt(index).Name = Name; | |||
Json<RecipesInfo>.Data.LocalRecipes.ElementAt(index).Functions = TempFunces; | |||
} | |||
//没找到则为新增配方 | |||
else | |||
{ | |||
foreach (var item in Functions) | |||
{ | |||
TempFunces.Add((EFunc)Enum.Parse(typeof(EFunc), item.FuncName), item.FuncPars?.ToArray()); | |||
} | |||
Json<RecipesInfo>.Data.LocalRecipes.Add(new TempRecipeData() | |||
{ | |||
ID = ID, | |||
Name = Name, | |||
Remark = " ", | |||
Functions = TempFunces | |||
}) ; | |||
} | |||
//关闭窗体。 | |||
ActionManage.GetInstance.Send("CloseEditRecipeView"); | |||
}); | |||
AddFuncCommand = new BPARelayCommand(() => | |||
{ | |||
Functions.Add(new FuncSet() | |||
{ | |||
Step=Functions.Count+1 | |||
}); | |||
}); | |||
RemoveCommand = new BPARelayCommand<object>((o) => | |||
{ | |||
if (o !=null && o is FuncSet func) | |||
{ | |||
Functions.Remove(func); | |||
} | |||
}); | |||
FuncChangeCommand = new BPARelayCommand<object>((o) => | |||
{ | |||
if (o!=null && o is FuncSet funcSet) | |||
{ | |||
funcSet.FuncPars = InitData.FunParInit[(EFunc)Enum.Parse(typeof(EFunc), funcSet.FuncName)]?.ToList(); | |||
} | |||
}); | |||
EditCommand = new BPARelayCommand<object>((o) => | |||
{ | |||
if (o is FuncSet) | |||
if (o is FuncSet funcSet) | |||
{ | |||
ActionManage.GetInstance.Send("OpenFuncEditView", o); | |||
EditFunctionParamView editFunction = new EditFunctionParamView(); | |||
editFunction.ShowDialog(); | |||
ActionManage.GetInstance.Send("OpenFuncEditView", o); | |||
if (editFunction.ShowDialog()==true) | |||
{ | |||
funcSet.FuncPars = EditFunctionParamViewModel.FuncPars?.ToList(); | |||
} | |||
} | |||
}); | |||
} | |||
private void AddTestData() | |||
{ | |||
ID = "32587"; | |||
@@ -48,38 +147,32 @@ namespace BPASmartClient.MorkCL.ViewModel | |||
//{ | |||
// Functions.Add(item); | |||
//} | |||
Functions = new(); | |||
int step = 0; | |||
foreach (var func in InitData.FunParInit) | |||
{ | |||
step++; | |||
Functions.Add(new FuncSet() { FuncName = Enum.GetName<EFunc>(func.Key), FuncPars = func.Value.ToList(),Step=step}); | |||
} | |||
AllFunc = new ObservableCollection<string>(); | |||
foreach (var item in Enum.GetNames(typeof(EFunc))) | |||
{ | |||
AllFunc.Add(item); | |||
} | |||
} | |||
/// <summary> | |||
/// 保存参数。 | |||
/// </summary> | |||
public BPARelayCommand SaveParamCommand { get; set; } | |||
/// <summary> | |||
/// 添加功能 | |||
/// </summary> | |||
public BPARelayCommand AddFuncCommand { get; set; } | |||
/// <summary> | |||
/// 删除功能。 | |||
/// </summary> | |||
public BPARelayCommand<object> RemoveCommand { get; set; } | |||
/// <summary> | |||
/// 功能改变。 | |||
/// </summary> | |||
public BPARelayCommand<object> FuncChangeCommand { get; set; } | |||
/// <summary> | |||
/// 编辑功能。 | |||
/// </summary> | |||
public BPARelayCommand<object> EditCommand { get; set; } | |||
private ObservableCollection<FuncSet> _Functions; | |||
public ObservableCollection<FuncSet> Functions | |||
@@ -88,17 +181,20 @@ namespace BPASmartClient.MorkCL.ViewModel | |||
set { _Functions = value; OnPropertyChanged(); } | |||
} | |||
private string _Name; | |||
/// <summary> | |||
/// 配方名称 | |||
/// </summary> | |||
public string Name | |||
{ | |||
get { return _Name; } | |||
set { _Name = value;OnPropertyChanged(); } | |||
set { _Name = value; OnPropertyChanged(); } | |||
} | |||
private string _ID; | |||
/// <summary> | |||
/// 配方ID。 | |||
/// </summary> | |||
public string ID | |||
{ | |||
get { return _ID; } | |||
@@ -106,13 +202,13 @@ namespace BPASmartClient.MorkCL.ViewModel | |||
} | |||
private ObservableCollection<string> _AllFunc; | |||
/// <summary> | |||
/// 所有功能集合。 | |||
/// </summary> | |||
public ObservableCollection<string> AllFunc | |||
{ | |||
get { return _AllFunc; } | |||
set { _AllFunc = value;OnPropertyChanged(); } | |||
set { _AllFunc = value; OnPropertyChanged(); } | |||
} | |||
} | |||
} | |||
} |
@@ -6,7 +6,43 @@ using System.Threading.Tasks; | |||
namespace BPASmartClient.MorkCL.ViewModel | |||
{ | |||
internal class ItemStorageViewModel | |||
public class ItemStorageViewModel:NotifyBase | |||
{ | |||
public ItemStorageViewModel() | |||
{ | |||
Materials = new ObservableCollection<TempMaterial>(); | |||
AddTestData(); | |||
} | |||
void AddTestData() | |||
{ | |||
ScaleCurrentWeight = 1.23f; | |||
Materials.Clear(); | |||
for (int i = 1; i < 13; i++) | |||
{ | |||
Materials.Add(new TempMaterial() { ID = 10000 + i, Loc = i.ToString(), Name = $"第{i}库位", Weight = new Random().NextSingle() }); | |||
} | |||
} | |||
private float _ScaleCurrentWeight; | |||
public float ScaleCurrentWeight { get { return _ScaleCurrentWeight; } set { _ScaleCurrentWeight = value; OnPropertyChanged(); } } | |||
private ObservableCollection<TempMaterial> _Materials; | |||
public ObservableCollection<TempMaterial> Materials | |||
{ | |||
get { return _Materials; } | |||
set { _Materials = value; OnPropertyChanged(); } | |||
} | |||
} | |||
public class TempMaterial | |||
{ | |||
public int ID { get; set; } | |||
public string Name { get; set; } | |||
public float Weight { get; set; } | |||
public string Loc { get; set; } | |||
} | |||
} |
@@ -1,41 +1,51 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.MorkCL.Model.Json; | |||
using BPASmartClient.MorkCL.Model.Recipe; | |||
namespace BPASmartClient.MorkCL.ViewModel | |||
{ | |||
public class RecipeManageViewModel:NotifyBase | |||
public class RecipeManageViewModel : NotifyBase | |||
{ | |||
public RecipeManageViewModel() | |||
{ | |||
Recipes = new(); | |||
AddTestData(); | |||
Recipes = Json<RecipesInfo>.Data.LocalRecipes; | |||
//AddTestData(); | |||
SaveParamCommand = new(() => | |||
{ | |||
if (MessageNotify.GetInstance.ShowDialog("是否保存所有配方信息?", DialogType.Warning)) | |||
{ | |||
Json<RecipesInfo>.Save(); | |||
} | |||
}); | |||
AddRecipeCommand = new(() => { | |||
AddRecipeCommand = new(() => | |||
{ | |||
EditRecipeView editRecipeView = new EditRecipeView(); | |||
editRecipeView.ShowDialog(); | |||
}); | |||
RemoveCommand = new((id) => | |||
{ | |||
if (MessageNotify.GetInstance.ShowDialog("是否删除该配方?", DialogType.Warning)) | |||
{ | |||
var deleteRecipe = Recipes.FirstOrDefault(recipe => recipe.ID == id.ToString()); | |||
if (deleteRecipe != null) | |||
{ | |||
Recipes.Remove(deleteRecipe); | |||
} | |||
} | |||
}); | |||
IssueCommand = new((id) => | |||
{ | |||
//TODO:下发逻辑,暂时不清楚。 | |||
}); | |||
EditCommand = new((o) => | |||
{ | |||
EditRecipeView editRecipeView = new EditRecipeView(); | |||
ActionManage.GetInstance.Send("OpenRecipeEditView", o); | |||
editRecipeView.ShowDialog(); | |||
}); | |||
} | |||
/// <summary> | |||
/// 配方类,里面应该包含配方数据。 | |||
/// </summary> | |||
@@ -45,37 +55,34 @@ namespace BPASmartClient.MorkCL.ViewModel | |||
/// 保存参数。 | |||
/// </summary> | |||
public BPARelayCommand SaveParamCommand { get; set; } | |||
/// <summary> | |||
/// 添加配方。 | |||
/// </summary> | |||
public BPARelayCommand AddRecipeCommand { get; set; } | |||
/// <summary> | |||
/// 移除配方。 | |||
/// </summary> | |||
public BPARelayCommand<object> RemoveCommand { get; set; } | |||
/// <summary> | |||
/// 下发配方。 | |||
/// </summary> | |||
public BPARelayCommand<object> IssueCommand { get; set; } | |||
/// <summary> | |||
/// 编辑配方。 | |||
/// </summary> | |||
public BPARelayCommand<object> EditCommand { get; set; } | |||
void AddTestData() | |||
private void AddTestData() | |||
{ | |||
Recipes.Clear(); | |||
for (int i = 1; i < 10; i++) | |||
{ | |||
Recipes.Add(new TempRecipeData() { ID = i.ToString(),Name=$"{i}道菜",Remark=$"这是第{i}道菜。" }); | |||
Recipes.Add(new TempRecipeData() { ID = i.ToString(), Name = $"{i}道菜", Remark = $"这是第{i}道菜。" }); | |||
} | |||
} | |||
public class TempRecipeData | |||
{ | |||
public string Name { get; set; } | |||
public string ID { get; set; } | |||
public string Remark { get; set; } | |||
} | |||
} | |||
} | |||
} |