提交代码

This commit is contained in:
hehaibing-1996
2024-04-25 09:48:38 +08:00
parent aaf7c17562
commit a1199028b3
22 changed files with 861 additions and 196 deletions

View File

@ -164,13 +164,18 @@ namespace 货架标准上位机.ViewModel
var Result = ApiHelp.GetDataFromHttp<ShelfGoInInstoreResponse>(LocalFile.Config.ApiIpHost + "instore/shelfGoInInStore", body, "POST");
if (Result != null && Result.Code == 200)
{
scanner.IsInstoreMode = true;
scanner.ShelfCode = Result.Data.ShelfCode;
scanner.ModulesStr = Result.Data.ModulesStr;
}
else if (Result != null && !string.IsNullOrEmpty(Result.Message))
{
Growl.Warning(Result.Message);
}
}
catch (Exception ex)
{
Growl.Warning(ex.Message);
}
#endregion
}
@ -196,13 +201,56 @@ namespace 货架标准上位机.ViewModel
{
scanner.MatSn = Result.Data.MatSN;
}
else if(Result != null && !string.IsNullOrEmpty(Result.Message))
{
Growl.Warning(Result.Message);
}
}
catch (Exception ex)
{
Growl.Warning(ex.Message);
}
#endregion
}
public ICommand BtnEndCommand { get => new DelegateCommand(BtnEnd); }
public void BtnEnd()
{
try
{
//获取当前入库的货架
ScannerManager.Scanners.Where(t => t.IsInstoreMode).ToList().ForEach(t =>
{
if (!string.IsNullOrEmpty(t.ShelfCode))
{
var body = new ShelfGoOutInStoreRequest()
{
ShelfCode = t.ShelfCode,
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "instore/shelfGoOutInStore", body, "POST");
if (Result != null && Result.Code == 200)
{
t.IsInstoreMode = false;
t.ShelfCode = string.Empty;
t.MatSn = string.Empty;
t.ScannerDisplayControl.RefreshValues(t.ShelfCode, t.MatSn);
}
}
else
{
t.IsInstoreMode = false;
Logs.Write($"扫码枪{t.COM}的货架码因为某种原因丢失!");
}
});
}
catch (Exception ex)
{
Growl.Warning(ex.Message);
}
}
#endregion
}
}

View File

@ -1,11 +1,15 @@
using HandyControl.Controls;
using Ping9719.WpfEx.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using WCS.BLL.DbModels;
using WCS.Model;
using WCS.Model.ApiModel.MatInventoryDetail;
using .Api;
namespace .ViewModels
{
@ -21,6 +25,16 @@ namespace 货架标准上位机.ViewModels
SetProperty(ref dataGridItemSource, value);
}
}
private MatInventorySummaryModel selectedItemSource;
public MatInventorySummaryModel SelectedItemSource
{
get { return selectedItemSource; }
set
{
SetProperty(ref selectedItemSource, value);
}
}
#endregion
#region Command
@ -60,7 +74,75 @@ namespace 货架标准上位机.ViewModels
}
}
// 定义一个事件,当需要关闭窗口时触发
public event Action RequestClose;
#endregion
// 一个方法,当满足某些条件时调用,以触发关闭窗口
protected virtual void OnRequestClose()
{
RequestClose?.Invoke();
}
public ICommand GenerateOutOrderCommand { get => new DelegateCommand(GenerateOutOrder); }
public void GenerateOutOrder()
{
//数据校验
if (DataGridItemSource == null || DataGridItemSource.Count == 0)
{
HandyControl.Controls.MessageBox.Show("选择的物料为空无法生成出库单!");
return;
}
foreach (var itemSource in DataGridItemSource)
{
if (itemSource.NeedQty == 0)
{
Growl.Warning("需求数量未填!");
SelectedItemSource = itemSource;
return;
}
//问一下此处是否要做限制 TO DO 物料分类Group By的规则 分到哪一类
//else if (itemSource.NeedQty > itemSource.TotalQty)
//{
// Growl.Warning("需求数量大于库存数量!");
// SelectedItemSource = itemSource;
// return;
//}
#region
try
{
var body = new SysOutOrderByMatCodeRequest()
{
OrderType = "出库",
OrderSource = "WCS前端",
ItemList = DataGridItemSource.Select(t => new MatCodeItemList()
{
MatCode = t.MatCode,
MatBatch = t.MatBatch,
ReqQty = t.NeedQty
}).ToList(),
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outstore/sysOutOrderByMatCode", body, "POST");
if (Result != null && Result.Code == 200)
{
Growl.Success(Result.Message);
OnRequestClose();
}
else if (Result != null)
{
Growl.Warning(Result.Message);
}
}
catch (Exception ex)
{
Growl.Error("加载数据失败:" + ex.Message);
}
finally
{
}
#endregion
}
}
#endregion
}
}

View File

@ -29,7 +29,7 @@
<TextBlock FontSize="25" Name="Title" Text="新增出库单据" TextWrapping="Wrap" VerticalAlignment="Top" HorizontalAlignment="Center"/>
<hc:Divider Margin="0"></hc:Divider>
</StackPanel>
<Border Grid.Row="1" Margin="2 2 2 0" Background="AliceBlue" Padding="0">
<Border Background="AliceBlue" Padding="0">
<Grid >
@ -47,8 +47,10 @@
<Grid Margin="5,0" Grid.Row="2" >
<DataGrid Grid.Row="1" SelectedCellsChanged="DataGrid_SelectedCellsChanged"
RowHeight="39" ItemsSource="{Binding DataGridItemSource}"
AutoGenerateColumns="False" Name="dg1" FontSize="15">
RowHeight="39"
ItemsSource="{Binding DataGridItemSource}"
SelectedItem="{Binding SelectedItemSource, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
AutoGenerateColumns="False" Name="dg1" FontSize="15">
<DataGrid.Columns>
<DataGridTextColumn IsReadOnly="True" Header="物料编码" Binding="{Binding MatCode}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="物料名称" MaxWidth="150" Binding="{Binding MatName}"></DataGridTextColumn>
@ -58,13 +60,13 @@
<DataGridTemplateColumn CanUserResize="False" Header="需求数量">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Width="80" Height="25" Text="{Binding NeedQty}"/>
<TextBox Width="80" Height="25" Text="{Binding NeedQty, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn CanUserResize="False" Header="">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<DataTemplate>
<Button Style="{StaticResource ButtonDanger}" Margin="0,0,0,0" IsEnabled="True" Content="删除" Width="60" Command="{Binding DataContext.DelCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" CommandParameter="{Binding }"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
@ -80,11 +82,12 @@
</StackPanel>
<StackPanel Margin="3" x:Name="spacingPanel" Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Margin="0" Content="生成出库单" Background="ForestGreen" Foreground="White" MinHeight="40" FontSize="20" Click="comfirmClick"/>
<Button Margin="0" Content="生成出库单" Background="ForestGreen" Foreground="White" MinHeight="40" FontSize="20"
Command="{Binding GenerateOutOrderCommand}"/>
<TextBlock Margin="20" Text=""></TextBlock>
<Button Margin="0" Content="取消" Background="IndianRed" Foreground="White" MinHeight="40" FontSize="20" Click="closeClick"/>
</StackPanel>
</Grid>
</Border>
</hc:Window>

View File

@ -24,6 +24,7 @@ namespace 货架标准上位机
{
InitializeComponent();
this.DataContext = viewModel;
viewModel.RequestClose += OnRequestClose;
}
private void closeClick(object sender, RoutedEventArgs e)
@ -34,18 +35,7 @@ namespace 货架标准上位机
private void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
{
DataGrid datagrid = sender as DataGrid;
var index = datagrid.SelectedIndex;
if (index >= 0)
{
//if (viewModel.DataGridItemSource != null && viewModel.DataGridItemSource.Count() > index)
//{
// var data = viewModel.DataGridItemSource.ElementAt(index);
// data.IsSelected = !data.IsSelected;
// viewModel.DataGridItemSource = viewModel.DataGridItemSource.ToList();
//}
}
datagrid.UnselectAllCells();
}
private void txtMatQty1_PreviewTextInput(object sender, TextCompositionEventArgs e)
@ -56,42 +46,10 @@ namespace 货架标准上位机
}
}
//public List<InventoryDetail> DataGridItemSource = new List<InventoryDetail>();
private void comfirmClick(object sender, RoutedEventArgs e)
private void OnRequestClose()
{
this.DialogResult = true;
//if (viewModel.DataGridItemSource != null)
// DataGridItemSource = viewModel.DataGridItemSource.Where(t => t.IsSelected).ToList();
this.Close();
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
//viewModel.RefreshCount();
}
private void allChecked_Checked(object sender, RoutedEventArgs e)
{
//if (viewModel != null && viewModel.DataGridItemSource != null && viewModel.DataGridItemSource.Count() > 0)
//{
// foreach (var item in viewModel.DataGridItemSource)
// {
// item.IsSelected = true;
// }
// viewModel.DataGridItemSource = viewModel.DataGridItemSource.ToList();
//}
}
private void allChecked_Unchecked(object sender, RoutedEventArgs e)
{
//var viewMode = this.DataContext as OutInventoryDocumentDetailViewModel;
//if (viewMode != null && viewMode.DataGridItemSource != null && viewMode.DataGridItemSource.Count() > 0)
//{
// foreach (var item in viewMode.DataGridItemSource)
// {
// item.IsSelected = false;
// }
// viewMode.DataGridItemSource = viewMode.DataGridItemSource.ToList();
//}
}
}
}