From 46c21ce3f418a01b00253df8c27e488841333e85 Mon Sep 17 00:00:00 2001 From: liuwf Date: Sun, 24 Dec 2023 11:25:27 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E6=B3=A1=E5=89=8D=E5=BA=93?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=A4=9A=E4=B8=AA=E5=9E=8B=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Model_New/BaseMaterialInfo.cs | 6 + .../Aucma.Core.BoxFoam.csproj.user | 6 + Aucma.Core.BoxFoam/Models/SpaceInfoModel.cs | 7 +- .../ViewModels/BeforeFoamingPageModelView.cs | 33 +- .../ViewModels/SelectTypeViewModel.cs | 297 ++++++++++++++++++ .../Views/UserPage/BeforeFoamingPageView.xaml | 39 ++- .../Views/UserPage/SelectType.xaml | 133 ++++++++ .../Views/UserPage/SelectType.xaml.cs | 42 +++ 8 files changed, 552 insertions(+), 11 deletions(-) create mode 100644 Aucma.Core.BoxFoam/ViewModels/SelectTypeViewModel.cs create mode 100644 Aucma.Core.BoxFoam/Views/UserPage/SelectType.xaml create mode 100644 Aucma.Core.BoxFoam/Views/UserPage/SelectType.xaml.cs diff --git a/Admin.Core.Model/Model_New/BaseMaterialInfo.cs b/Admin.Core.Model/Model_New/BaseMaterialInfo.cs index 133873ee..db5eefd4 100644 --- a/Admin.Core.Model/Model_New/BaseMaterialInfo.cs +++ b/Admin.Core.Model/Model_New/BaseMaterialInfo.cs @@ -31,6 +31,12 @@ namespace Admin.Core.Model [SugarColumn(ColumnName = "MATERIAL_NAME")] public string MaterialName { get; set; } + /// + /// 物料小类 + /// + [SugarColumn(ColumnName = "MATERIAL_SUBCLASS")] + public string MaterialSubclass { get; set; } + /// /// 入库方向-A/B /// diff --git a/Aucma.Core.BoxFoam/Aucma.Core.BoxFoam.csproj.user b/Aucma.Core.BoxFoam/Aucma.Core.BoxFoam.csproj.user index 3c3d823c..e3ec02f0 100644 --- a/Aucma.Core.BoxFoam/Aucma.Core.BoxFoam.csproj.user +++ b/Aucma.Core.BoxFoam/Aucma.Core.BoxFoam.csproj.user @@ -37,6 +37,9 @@ Code + + Code + Code @@ -93,6 +96,9 @@ Designer + + Designer + Designer diff --git a/Aucma.Core.BoxFoam/Models/SpaceInfoModel.cs b/Aucma.Core.BoxFoam/Models/SpaceInfoModel.cs index b8ad5c14..c959cffc 100644 --- a/Aucma.Core.BoxFoam/Models/SpaceInfoModel.cs +++ b/Aucma.Core.BoxFoam/Models/SpaceInfoModel.cs @@ -37,7 +37,10 @@ namespace Aucma.Core.BoxFoam.Models /// 物料型号 /// public string materialType { get; set; } - + /// + /// 物料型号B + /// + public string typeCodeB { get; set; } /// /// 入库状态 /// @@ -66,5 +69,7 @@ namespace Aucma.Core.BoxFoam.Models /// 禁用 /// public string? setEnable { get; set; } + + } } diff --git a/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs b/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs index c3b49231..f2472ad6 100644 --- a/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs +++ b/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs @@ -28,17 +28,45 @@ namespace Aucma.Core.BoxFoam.ViewModels public BeforeFoamingPageModelView() { + + // 设置型号 + SubmitCommand = new RelayCommand(obj => SubmitCommandExecute(obj)); + SubmitCommand2 = new RelayCommand(obj => SubmitCommandExecute2(obj)); _baseSpaceDetailServices = App.ServiceProvider.GetService(); _baseSpaceInfoServices = App.ServiceProvider.GetService(); - + SelectTypeViewModel.RefreshPageEvent += LoadSpaceStoreMedthAsync; this.LoadSpaceStoreMedthAsync(); } + #region 参数定义 + /// + /// 设置型号 + /// + public RelayCommand SubmitCommand { get; set; } + + private void SubmitCommandExecute(string spaceCode) + { + + SelectType type = new SelectType(1, spaceCode); + type.ShowDialog(); + + } + + public RelayCommand SubmitCommand2 { get; set; } + + private void SubmitCommandExecute2(string spaceCode) + { + + SelectType type = new SelectType(2, spaceCode); + type.ShowDialog(); + + } + #endregion #region 加载泡前库货道信息 /// /// 加载泡前库货道信息 /// - private void LoadSpaceStoreMedthAsync() + private void LoadSpaceStoreMedthAsync() { string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code @@ -54,6 +82,7 @@ namespace Aucma.Core.BoxFoam.ViewModels model.onTheWay = item.OnRouteAmount; model.totalAmount = item.SpaceStock + item.OnRouteAmount; model.materialType = item.MaterialType; + model.typeCodeB = item.typeCodeB; model.unusualFlag = item.UnusualFlag == 2 ? "Red" : "White"; if (item.SpaceStatus == 2) { diff --git a/Aucma.Core.BoxFoam/ViewModels/SelectTypeViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/SelectTypeViewModel.cs new file mode 100644 index 00000000..a222db3b --- /dev/null +++ b/Aucma.Core.BoxFoam/ViewModels/SelectTypeViewModel.cs @@ -0,0 +1,297 @@ +using Admin.Core.Common; +using Admin.Core.IService; +using Admin.Core.Model; +using Admin.Core.Service; +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; + +namespace Aucma.Core.BoxFoam.ViewModels +{ + public class SelectTypeViewModel : ObservableObject + { + + /// + /// 委托,关闭窗口 + /// + /// + public delegate void close(); + public event close closeEvent; + + /// + /// 刷新泡后库页面 + /// + /// + 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; + + public RelayCommand MouseClickCommand { get; set; } + + private string spaceCodes = string.Empty; + + public SelectTypeViewModel() + { + + } + public SelectTypeViewModel(int ncount, string spaceCode) + { + _baseSpaceInfoServices = App.ServiceProvider.GetService(); + _baseMaterialInfoServices = App.ServiceProvider.GetService(); + QueryCommand = new RelayCommand(searchData); + SaveCommand = new RelayCommand(updateDirection); + deleteCommand = new RelayCommand(deleteModel); + spaceCodes = spaceCode; + MouseClickCommand = new RelayCommand(MouseClick); + materialDataGrid = new ObservableCollection(); + Console.WriteLine(spaceCode); + Load(); + if (ncount == 1) + { + IsSelectedOptionA = true; + } + else if (ncount == 2) + { + IsSelectedOptionB = true; + } + else if (ncount == 3) + { + IsSelectedOptionC = true; + } + } + 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 materialDataGrid; + + public ObservableCollection 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() + { + if (!IsSelectedOptionA && !IsSelectedOptionB && !IsSelectedOptionC) + { + MessageBox.Show("请至少选择一个型号!"); + return; + } + // 查询货道信息 + BaseSpaceInfo space = await _baseSpaceInfoServices.GetSpaceInfoBySpaceCode(storeCode, spaceCodes); + if (IsSelectedOptionA) + { + space.MaterialType = null; + space.typeNameA = null; + } + else if (IsSelectedOptionB) + { + space.typeCodeB = null; + space.typeNameB = null; + } + else if (IsSelectedOptionC) + { + space.typeCodeC = null; + space.typeNameC = null; + } + bool result = await _baseSpaceInfoServices.UpdateSpaceInfo(space); + if (result) + { + MessageBox.Show("清除型号成功!"); + } + //关闭窗口 + closeEvent?.Invoke(); + //刷新界面 + RefreshPageEvent?.Invoke(); + } + /// + /// 设置型号 + /// + private async void updateDirection() + { + + if (!IsSelectedOptionA && !IsSelectedOptionB && !IsSelectedOptionC) + { + MessageBox.Show("请至少选择一个型号!"); + return; + } + // 查询货道信息 + BaseSpaceInfo space =await _baseSpaceInfoServices.GetSpaceInfoBySpaceCode(storeCode, spaceCodes); + if (IsSelectedOptionA) + { + space.MaterialType = PlanInfo.MaterialCode; + space.typeNameA = PlanInfo.MaterialName; + } + else if (IsSelectedOptionB) + { + space.typeCodeB = PlanInfo.MaterialCode; + space.typeNameB = PlanInfo.MaterialName; + } + else if (IsSelectedOptionC) + { + space.typeCodeC = PlanInfo.MaterialCode; + space.typeNameC = PlanInfo.MaterialName; + } + bool result = await _baseSpaceInfoServices.UpdateSpaceInfo(space); + if (result) + { + MessageBox.Show("型号设置成功"); + } + + //关闭窗口 + closeEvent?.Invoke(); + //刷新界面 + RefreshPageEvent?.Invoke(); + } + + /// + ///条件查询型号 + /// + 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(); + } + } + } +} diff --git a/Aucma.Core.BoxFoam/Views/UserPage/BeforeFoamingPageView.xaml b/Aucma.Core.BoxFoam/Views/UserPage/BeforeFoamingPageView.xaml index e5e17a80..04a5d322 100644 --- a/Aucma.Core.BoxFoam/Views/UserPage/BeforeFoamingPageView.xaml +++ b/Aucma.Core.BoxFoam/Views/UserPage/BeforeFoamingPageView.xaml @@ -105,9 +105,9 @@ - - - + + + @@ -121,7 +121,7 @@ - + @@ -145,16 +145,39 @@ + + + + + - - + + - - + + + + + + + + + diff --git a/Aucma.Core.BoxFoam/Views/UserPage/SelectType.xaml b/Aucma.Core.BoxFoam/Views/UserPage/SelectType.xaml new file mode 100644 index 00000000..89db9af3 --- /dev/null +++ b/Aucma.Core.BoxFoam/Views/UserPage/SelectType.xaml @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + +