dev
liuwf 1 year ago
parent b7bca5fe07
commit 54ddcbfb9a

@ -89,6 +89,9 @@
<Compile Update="Views\SearchCriteriaView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\SelectType.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>

@ -0,0 +1,268 @@
using Admin.Core.Common;
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using Admin.Core.Service;
using Aucma.Core.OldBoxFoam;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using log4net;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Logging;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
namespace Aucma.Core.OldBoxFoam.ViewModels
{
public class SelectTypeViewModel : ObservableObject
{
/// <summary>
/// 委托,关闭窗口
/// </summary>
/// <param name="message"></param>
public delegate void close();
public event close closeEvent;
/// <summary>
/// 刷新泡后库页面
/// </summary>
/// <param name="message"></param>
public delegate void RefreshPage();
public static event RefreshPage RefreshPageEvent;
public RelayCommand QueryCommand { get; set; }
public RelayCommand deleteCommand { get; set; }
public RelayCommand SaveCommand { get; set; }
private string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(BaseSpaceInfoServices));
private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices;
//private readonly IBaseSpaceInfoServices _baseSpaceInfoServices;
IOldBoxFoamTypeServices _oldBoxFoamTypeServices;
public RelayCommand<object> MouseClickCommand { get; set; }
private string spaceCodes = string.Empty;
public SelectTypeViewModel()
{
}
public SelectTypeViewModel(string spaceCode)
{
//_baseSpaceInfoServices = App.ServiceProvider.GetService<IBaseSpaceInfoServices>();
_oldBoxFoamTypeServices = App.ServiceProvider.GetService<IOldBoxFoamTypeServices>();
_baseMaterialInfoServices = App.ServiceProvider.GetService<IBaseMaterialInfoServices>();
QueryCommand = new RelayCommand(searchData);
SaveCommand = new RelayCommand(updateDirection);
deleteCommand = new RelayCommand(deleteModel);
spaceCodes = spaceCode;
MouseClickCommand = new RelayCommand<object>(MouseClick);
materialDataGrid = new ObservableCollection<BaseMaterialInfo>();
Console.WriteLine(spaceCode);
Load();
}
public async void Load()
{
var infos = await _baseMaterialInfoServices.QueryAsync(x=>x.MaterialSubclass=="200");
MaterialDataGrid.Clear();
Application.Current.Dispatcher.Invoke(() =>
{
foreach (BaseMaterialInfo info in infos)
{
MaterialDataGrid.Add(info);
}
});
}
private ObservableCollection<BaseMaterialInfo> materialDataGrid;
public ObservableCollection<BaseMaterialInfo> MaterialDataGrid
{
get { return materialDataGrid; }
set => SetProperty(ref materialDataGrid, value);
}
private BaseMaterialInfo selectedDataItem;
public BaseMaterialInfo SelectedDataItem
{
get { return selectedDataItem; }
set => SetProperty(ref selectedDataItem, value);
}
public void MouseClick(object obj)
{
var info = SelectedDataItem as BaseMaterialInfo;
if (info != null)
{
PlanInfo = info;
// SelectTypeWindow window = new SelectTypeWindow(spaceCodes, SelectedDataItem);
// window.ShowDialog();
}
}
private BaseMaterialInfo planInfo = new BaseMaterialInfo();
public BaseMaterialInfo PlanInfo
{
get { return planInfo; }
set => SetProperty(ref planInfo, value);
}
private string searchText;
public string SearchText
{
get { return searchText; }
set => SetProperty(ref searchText, value);
}
#region 单选框
private bool _isSelectedOptionA;
public bool IsSelectedOptionA
{
get { return _isSelectedOptionA; }
set
{
if (_isSelectedOptionA != value)
{
_isSelectedOptionA = value;
OnPropertyChanged(nameof(IsSelectedOptionA));
// 如果选择了A选项将BC选项设为false
if (_isSelectedOptionA)
{
IsSelectedOptionB = false;
IsSelectedOptionC = false;
}
}
}
}
private bool _isSelectedOptionB;
public bool IsSelectedOptionB
{
get { return _isSelectedOptionB; }
set
{
if (_isSelectedOptionB != value)
{
_isSelectedOptionB = value;
OnPropertyChanged(nameof(IsSelectedOptionB));
// 如果选择了B选项将A选项设为false
if (_isSelectedOptionB)
{
IsSelectedOptionA = false;
IsSelectedOptionC = false;
}
}
}
}
private bool _isSelectedOptionC;
public bool IsSelectedOptionC
{
get { return _isSelectedOptionC; }
set
{
if (_isSelectedOptionC != value)
{
_isSelectedOptionC = value;
OnPropertyChanged(nameof(IsSelectedOptionC));
if (_isSelectedOptionC)
{
IsSelectedOptionA = false;
IsSelectedOptionB = false;
}
}
}
}
#endregion
private async void deleteModel()
{
// 查询货道信息
List<OldBoxFoamType> spaceList = await _oldBoxFoamTypeServices.QueryAsync();
// BaseSpaceInfo space = await _baseSpaceInfoServices.GetSpaceInfoBySpaceCode(storeCode, spaceCodes);
if (string.IsNullOrEmpty(spaceCodes))
{
MessageBox.Show("先选中一个货道");
return;
}
OldBoxFoamType space = spaceList.Where(x => x.ObjId == int.Parse(spaceCodes)).FirstOrDefault();
space.MaterialCode = string.Empty;
space.MaterialName = string.Empty;
bool result = await _oldBoxFoamTypeServices.UpdateAsync(space);
if (result)
{
MessageBox.Show("清除型号成功!");
}
//关闭窗口
closeEvent?.Invoke();
//刷新界面
RefreshPageEvent?.Invoke();
}
/// <summary>
/// 设置型号
/// </summary>
private async void updateDirection()
{
if (string.IsNullOrEmpty(spaceCodes))
{
MessageBox.Show("请至少选择一个型号!");
return;
}
// 查询货道信息
List<OldBoxFoamType> spaceList = await _oldBoxFoamTypeServices.QueryAsync();
OldBoxFoamType space = spaceList.Where(x => x.ObjId == int.Parse(spaceCodes)).FirstOrDefault();
space.MaterialCode = PlanInfo.MaterialCode;
space.MaterialName = PlanInfo.MaterialName;
bool result = await _oldBoxFoamTypeServices.UpdateAsync(space);
if (result)
{
MessageBox.Show("型号设置成功");
}
//关闭窗口
closeEvent?.Invoke();
//刷新界面
RefreshPageEvent?.Invoke();
}
///<summary>
///条件查询型号
/// </summary>
private async void searchData()
{
if (!string.IsNullOrEmpty(searchText))
{
var infos =await _baseMaterialInfoServices.QueryAsync(x=>x.MaterialSubclass=="200" && (x.MaterialName.Contains(searchText) || x.MaterialCode.Contains(searchText)));
MaterialDataGrid.Clear();
Application.Current.Dispatcher.Invoke(() =>
{
foreach (BaseMaterialInfo info in infos)
{
MaterialDataGrid.Add(info);
}
});
}
else
{
Load();
}
}
}
}

@ -137,12 +137,13 @@
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="395*"/>
<RowDefinition Height="314*"/>
<RowDefinition Height="81*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0">
<Grid>
<Grid.Resources>
@ -221,7 +222,7 @@
</Border>
</Grid>
</Border>
<Grid Grid.Row="2">
<Grid Grid.Row="1" Grid.RowSpan="2">
<DataGrid Grid.Row="0" ItemsSource="{Binding ListItems}" ColumnHeaderHeight="35" Height="{Binding Path=ActualHeight, ElementName=ScanPanel}"
RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Auto"

@ -203,8 +203,12 @@
<Border Grid.Column="0" Grid.Row="0" BorderBrush="White" BorderThickness="1" >
<TextBlock Text="{Binding MaterialCode}" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Column="1" Grid.Row="0" BorderBrush="White" BorderThickness="1" >
<TextBlock x:Name="spaceCodeText2" Text="{Binding MaterialName}" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Command="{Binding DataContext.SubmitCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding Text, ElementName=spaceCodeText}" Background="Transparent">
<TextBlock Text="{Binding MaterialName}" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button>
<!--<TextBlock x:Name="spaceCodeText2" Text="{Binding MaterialName}" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>-->
</Border>
<!--<Border Grid.Column="2" Grid.Row="0" BorderBrush="White" BorderThickness="1" >
<TextBlock Text="清除" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>

@ -1,4 +1,4 @@
using Aucma.Core.BoxFoam.ViewModels;

using Aucma.Core.OldBoxFoam.ViewModels;
using System;
using System.Collections.Generic;

@ -0,0 +1,195 @@
<Window x:Class="Aucma.Core.OldBoxFoam.Views.SelectType"
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d" FontFamily="Microsoft YaHei"
Name="window" Background="#1254AB" d:DesignHeight="800" d:DesignWidth="1200">
<Window.Resources>
<Style TargetType="{x:Type Slider}">
<Style.Resources>
<!-- 重写重复触发按钮的样式 -->
<Style x:Key="RepeatButtonStyle" TargetType="{x:Type RepeatButton}">
<Setter Property="Focusable" Value="false" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Padding" Value="0" />
<Setter Property="Width" Value="30" />
</Style>
</Style.Resources>
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="false" />
<Setter Property="SmallChange" Value="1" />
</Style>
<Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}">
<!--<Setter Property="Height" Value="40"/>-->
<Setter Property="FontSize" Value="16"/>
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Left" />
</Style>
<Style TargetType="DataGrid">
<!--网格线颜色-->
<Setter Property="CanUserResizeColumns" Value="false"/>
<Setter Property="Background" Value="#1152AC" />
<Setter Property="BorderBrush" Value="#4285DE" />
<Setter Property="Foreground" Value="White"/>
<Setter Property="HorizontalGridLinesBrush">
<Setter.Value>
<SolidColorBrush Color="#4285DE"/>
</Setter.Value>
</Setter>
<Setter Property="VerticalGridLinesBrush">
<Setter.Value>
<SolidColorBrush Color="#1152AC"/>
</Setter.Value>
</Setter>
</Style>
<!--列头标题栏样式-->
<Style TargetType="DataGridColumnHeader">
<!--<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>-->
<!--<Setter Property="Background" Value="#dddddd"/>
<Setter Property="Foreground" Value="Black"/>-->
<!--<Setter Property="BorderThickness" Value="1" />-->
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="BorderBrush" Value="#dddddd" />
<Setter Property="Height" Value="48"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="Background" Value="#4285DE"/>
<Setter Property="Foreground" Value="White"/>
</Style>
<!--单元格样式-->
<Style TargetType="DataGridCell">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="Height" Value="40"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}" >
<ContentPresenter HorizontalAlignment="Left" VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#4285DE"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Border Margin="5" Background="#1254AB" CornerRadius="1">
<Border.Effect>
<DropShadowEffect Color="Gray" ShadowDepth="0" BlurRadius="5" Opacity="0.3" Direction="0"></DropShadowEffect>
</Border.Effect>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="10*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Grid.Column="0">
<TextBox Width="200" Height="25" Margin="10 0 0 0" Text="{Binding SearchText}" Foreground="White" VerticalAlignment="Center" FontSize="18"/>
<Button Content="查 询" Command="{Binding QueryCommand}" Background="#007DFA" BorderBrush="#007DFA" VerticalAlignment="Center" Foreground="White" Height="30" Width="100" Margin="0 0 50 0"/>
<Button Content="清除型号" Command="{Binding deleteCommand}" Background="#FF9900" Foreground="white" BorderBrush="#FF9900" VerticalAlignment="Center" Height="30" Width="100" />
</StackPanel>
<!--计划列表-->
<Border Grid.Row="1" Grid.Column="0" BorderThickness="0" CornerRadius="5" Margin="1,1,5,5" >
<DataGrid ItemsSource="{Binding MaterialDataGrid}" Height="{Binding Path=ActualHeight, ElementName=HeightPanel}"
HorizontalAlignment="Left" VerticalAlignment="Top" AlternationCount="2" RowHeaderWidth="0"
ColumnWidth="*" AutoGenerateColumns="False" IsReadOnly="True" CanUserAddRows="False" SelectionMode="Single"
SelectedItem="{Binding SelectedDataItem}" SelectionChanged="DataGrid_SelectionChanged">
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding MaterialCode}" Width="*" Header="产品编码" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding MaterialName}" Width="2*" Header="产品名称" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
</DataGrid.Columns>
</DataGrid>
</Border>
<Border Grid.Row="1" Grid.Column="1" BorderBrush="#1254AB" BorderThickness="3" CornerRadius="5" Background="Transparent" Margin="5,5">
<Border.Effect>
<DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="50,0,0,0">
<TextBlock Text="产品编码:" FontSize="18" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" />
<TextBox x:Name="MaterialCode" Text="{Binding PlanInfo.MaterialCode}" Foreground="white" BorderBrush="White" IsReadOnly="True" Margin="15 0 0 0 " FontSize="18" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" Width="350"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="50,0,0,0">
<TextBlock Text="产品型号:" FontSize="18" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBox x:Name="MaterialName" Text="{Binding PlanInfo.MaterialName}" Foreground="white" BorderBrush="White" IsReadOnly="True" Margin="15 0 0 0 " FontSize="18" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" Width="350"/>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Center" Margin="60,0,0,0" >
<!--单选框样式-->
<StackPanel.Resources>
<Style TargetType="RadioButton">
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="Background" Value="White"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<BulletDecorator Background="Transparent">
<BulletDecorator.Bullet>
<Grid Width="20" Height="20">
<Ellipse x:Name="BulletRadio" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1"/>
</Grid>
</BulletDecorator.Bullet>
<ContentPresenter Margin="4,0,0,0" VerticalAlignment="Center" RecognizesAccessKey="True"/>
</BulletDecorator>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="BulletRadio" Property="Fill" Value="Green"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="Green"/>
</Trigger>
</Style.Triggers>
</Style>
</StackPanel.Resources>
<!--<TextBlock Text="选择型号: " FontSize="18" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" />
<RadioButton Content="型号1" GroupName="Direction" IsChecked="{Binding IsSelectedOptionA, Mode=TwoWay}" Foreground="white" BorderBrush="White" Margin="15 0 0 0 " FontSize="18" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" />
<RadioButton Content="型号2" GroupName="Direction" IsChecked="{Binding IsSelectedOptionB, Mode=TwoWay}" Foreground="white" BorderBrush="White" Margin="15 0 0 0 " FontSize="18" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" />-->
<!--<RadioButton Content="型号3" GroupName="Direction" IsChecked="{Binding IsSelectedOptionC, Mode=TwoWay}" Margin="10 0 0 0"/>-->
</StackPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Content="保 存" FontSize="20" Command="{Binding SaveCommand}" Background="#FF36B5C1" BorderBrush="#FF36B5C1" Foreground="white" Margin="0,0,10,0" Height="50" Width="100" />
</StackPanel>
</Grid>
</Border>
</Grid>
</Border>
</Window>

@ -0,0 +1,43 @@

using Aucma.Core.OldBoxFoam.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Aucma.Core.OldBoxFoam.Views
{
/// <summary>
/// SelectType.xaml 的交互逻辑
/// </summary>
public partial class SelectType : Window
{
private SelectTypeViewModel viewModel = null;
public SelectType(string spaceCode)
{
InitializeComponent();
viewModel = new SelectTypeViewModel(spaceCode);
this.DataContext = viewModel;
viewModel.closeEvent += closeWindow;
}
private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
viewModel.MouseClick(sender);
}
private void closeWindow()
{
this.Close();
}
}
}
Loading…
Cancel
Save