From 32c2558875701277348f9e9b9e5202eadfa1b039 Mon Sep 17 00:00:00 2001 From: liuwf Date: Mon, 27 Nov 2023 17:23:46 +0800 Subject: [PATCH] =?UTF-8?q?change-=20=E6=88=90=E5=93=81=E4=B8=8B=E7=BA=BF?= =?UTF-8?q?=E6=94=B9=E5=85=A5=E5=BA=93=E6=96=B9=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IService_New/IBaseMaterialInfoServices.cs | 2 +- .../Service_New/BaseMaterialInfoServices.cs | 4 +- .../ViewModels/DirectionEditViewModel.cs | 27 +++- .../ViewModels/DirectionItemViewModel.cs | 128 ++++++++++++++++++ .../Views/DirectionEditView.xaml | 4 +- .../Views/DirectionEditView.xaml.cs | 5 +- .../Views/DirectionItemWindow.xaml | 94 +++++++++++++ .../Views/DirectionItemWindow.xaml.cs | 33 +++++ 8 files changed, 289 insertions(+), 8 deletions(-) create mode 100644 Aucma.Core.ProductOffLine/ViewModels/DirectionItemViewModel.cs create mode 100644 Aucma.Core.ProductOffLine/Views/DirectionItemWindow.xaml create mode 100644 Aucma.Core.ProductOffLine/Views/DirectionItemWindow.xaml.cs diff --git a/Admin.Core.IService/IService_New/IBaseMaterialInfoServices.cs b/Admin.Core.IService/IService_New/IBaseMaterialInfoServices.cs index b584a545..20e8fa22 100644 --- a/Admin.Core.IService/IService_New/IBaseMaterialInfoServices.cs +++ b/Admin.Core.IService/IService_New/IBaseMaterialInfoServices.cs @@ -14,6 +14,6 @@ namespace Admin.Core.IService /// /// 查出BASE_MATERIALINFO中存在的成品类型 /// - public Task> queryAsync(string search); + public Task> queryAsyncLike(string search); } } \ No newline at end of file diff --git a/Admin.Core.Service/Service_New/BaseMaterialInfoServices.cs b/Admin.Core.Service/Service_New/BaseMaterialInfoServices.cs index 7bccf04d..6db1ae58 100644 --- a/Admin.Core.Service/Service_New/BaseMaterialInfoServices.cs +++ b/Admin.Core.Service/Service_New/BaseMaterialInfoServices.cs @@ -27,9 +27,9 @@ namespace Admin.Core.Service } /// - /// 1.查出BASE_MATERIALINFO中存在的成品类型 + /// 1.条件查询使用,查出BASE_MATERIALINFO中存在的成品类型 /// - public async Task> queryAsync(string search) + public async Task> queryAsyncLike(string search) { List list; if (!string.IsNullOrEmpty(search)) diff --git a/Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs index 9c2464be..77e8e50f 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs @@ -2,6 +2,7 @@ using Admin.Core.Model; using Admin.Core.Service; using Aucma.Core.ProductOffLine.Models; +using Aucma.Core.ProductOffLine.Views; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using Microsoft.Extensions.DependencyInjection; @@ -21,12 +22,14 @@ namespace Aucma.Core.ProductOffLine.ViewModels public partial class DirectionEditViewModel : ObservableObject { public ICommand QueryCommand { get; set; } + public RelayCommand MouseClickCommand { get; set; } public ICommand SaveCommand { get; set; } private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices; public DirectionEditViewModel() { _baseMaterialInfoServices = App.ServiceProvider.GetService(); QueryCommand = new RelayCommand(ExecuteQuery); + MouseClickCommand = new RelayCommand(MouseClick); SaveCommand = new RelayCommand(ExecuteSave); Init(); } @@ -43,7 +46,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels { MaterialDataGrid.Clear(); // 处理查询按钮点击事件 - List materialInfoList = await _baseMaterialInfoServices.queryAsync(Search); + List materialInfoList = await _baseMaterialInfoServices.queryAsyncLike(Search); int count = 0; Application.Current.Dispatcher.Invoke(() => { @@ -53,6 +56,17 @@ namespace Aucma.Core.ProductOffLine.ViewModels } }); } + public void MouseClick(object obj) + { + + var info = SelectedDataItem as DirectionEditModel; + if (info != null) + { + DirectionItemWindow quantityIssuedWindow = new DirectionItemWindow(info); + quantityIssuedWindow.ShowDialog(); + } + + } private async void ExecuteSave() { @@ -95,6 +109,17 @@ namespace Aucma.Core.ProductOffLine.ViewModels } } + private DirectionEditModel selectedDataItem; + public DirectionEditModel SelectedDataItem + { + get { return selectedDataItem; } + set + { + selectedDataItem = value; + OnPropertyChanged(); + } + } + #region 初始化datagrid private ObservableCollection materialDataGrid = new ObservableCollection(); public ObservableCollection MaterialDataGrid diff --git a/Aucma.Core.ProductOffLine/ViewModels/DirectionItemViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/DirectionItemViewModel.cs new file mode 100644 index 00000000..4909d918 --- /dev/null +++ b/Aucma.Core.ProductOffLine/ViewModels/DirectionItemViewModel.cs @@ -0,0 +1,128 @@ +using Admin.Core.IService; +using Admin.Core.Model; +using Admin.Core.Service; +using Aucma.Core.ProductOffLine.Models; +using Aucma.Core.ProductOffLine.Views; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using Microsoft.Extensions.DependencyInjection; +using NPOI.SS.Formula.Functions; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Documents; +using System.Windows.Input; + +namespace Aucma.Core.ProductOffLine.ViewModels +{ + public partial class DirectionItemViewModel : ObservableObject + { + public RelayCommand CloseWindowCommand { get; set; } + + public RelayCommand SaveCommand { get; set; } + + + private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices; + public DirectionItemViewModel(DirectionEditModel info) { + _baseMaterialInfoServices = App.ServiceProvider.GetService(); + CloseWindowCommand = new RelayCommand(t => CloseWindow(t)); + SaveCommand = new RelayCommand(updateDirection); + PlanInfo = info; + if("A".Equals(info.SpaceCode)){ + IsSelectedOptionA = true; + } + else + { + IsSelectedOptionB = true; + } + } + + + + private DirectionEditModel planInfo = new DirectionEditModel(); + public DirectionEditModel PlanInfo + { + get { return planInfo; } + set { + planInfo = value; + OnPropertyChanged(nameof(PlanInfo)); + } + } + + #region 单选框 + private bool _isSelectedOptionA; + public bool IsSelectedOptionA + { + get { return _isSelectedOptionA; } + set + { + if (_isSelectedOptionA != value) + { + _isSelectedOptionA = value; + OnPropertyChanged(nameof(IsSelectedOptionA)); + + // 如果选择了A选项,将B选项设为false + if (_isSelectedOptionA) + { + IsSelectedOptionB = 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; + } + } + } + } + + + #endregion 关闭窗口 + private void CloseWindow(object parameter) + { + var window = parameter as Window; + if (window != null) + { + window.Close(); + } + + } + private async void updateDirection() + { + BaseMaterialInfo info = await _baseMaterialInfoServices.FirstAsync(x=>x.ObjId==PlanInfo.ObjId); + if (IsSelectedOptionA) + { + info.InboundDirection = "A"; + } + else + { + info.InboundDirection = "B"; + } + bool result = await _baseMaterialInfoServices.UpdateAsync(info); + if (result) + { + MessageBox.Show(info.MaterialName+"入库方向修改成功"); + } + } + + + } +} diff --git a/Aucma.Core.ProductOffLine/Views/DirectionEditView.xaml b/Aucma.Core.ProductOffLine/Views/DirectionEditView.xaml index 99e3aa03..d68f3aac 100644 --- a/Aucma.Core.ProductOffLine/Views/DirectionEditView.xaml +++ b/Aucma.Core.ProductOffLine/Views/DirectionEditView.xaml @@ -50,9 +50,9 @@ - + - + diff --git a/Aucma.Core.ProductOffLine/Views/DirectionEditView.xaml.cs b/Aucma.Core.ProductOffLine/Views/DirectionEditView.xaml.cs index e13be6f6..5d743080 100644 --- a/Aucma.Core.ProductOffLine/Views/DirectionEditView.xaml.cs +++ b/Aucma.Core.ProductOffLine/Views/DirectionEditView.xaml.cs @@ -9,15 +9,16 @@ namespace Aucma.Core.ProductOffLine.Views /// public partial class DirectionEditView : Window { + private DirectionEditViewModel directionEditViewModel = new DirectionEditViewModel(); public DirectionEditView() { InitializeComponent(); - this.DataContext = new DirectionEditViewModel(); + this.DataContext = directionEditViewModel; } private void dataGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { - // planInfoEditViewModel.MouseClick(sender); + directionEditViewModel.MouseClick(sender); } diff --git a/Aucma.Core.ProductOffLine/Views/DirectionItemWindow.xaml b/Aucma.Core.ProductOffLine/Views/DirectionItemWindow.xaml new file mode 100644 index 00000000..07a1d4a1 --- /dev/null +++ b/Aucma.Core.ProductOffLine/Views/DirectionItemWindow.xaml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +