From 936375bb2c6c804f561fb9ce51a613f115a60ea0 Mon Sep 17 00:00:00 2001 From: geht <2947093423@qq.com> Date: Sat, 9 May 2026 19:10:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8E=9F=E6=96=99=E5=85=A5?= =?UTF-8?q?=E5=9C=BA=E8=AE=B0=E5=BD=95=E7=BC=96=E8=BE=91=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E6=A1=86=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=8B=86=E7=A0=81=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E7=9A=84=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E7=94=A8=E6=88=B7=E4=BD=93=E9=AA=8C=E3=80=82?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=89=8D=E7=AB=AF=E8=A7=86=E5=9B=BE=E4=BB=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8B=86=E7=A0=81=E6=98=8E=E7=BB=86=E7=9A=84?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=8B=BC=E6=8E=A5=E6=98=BE=E7=A4=BA=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E8=B0=83=E6=95=B4=E7=9B=B8=E5=85=B3=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E5=B8=83=E5=B1=80=E5=92=8C=E6=A0=B7=E5=BC=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RawMaterialEntryEditDialogViewModel.cs | 79 +++- .../RawMaterialEntryOperationView.xaml | 419 ++++++++---------- .../_build_verify_out/YY.Admin.Core.dll | Bin 384000 -> 440320 bytes .../_build_verify_out/YY.Admin.Services.dll | Bin 229888 -> 507392 bytes .../_build_verify_out/YY.Admin.dll | Bin 1635840 -> 2172928 bytes .../_build_verify_out/YY.Admin.exe | Bin 151552 -> 151552 bytes 6 files changed, 272 insertions(+), 226 deletions(-) diff --git a/yy-admin-master/YY.Admin/ViewModels/RawMaterialEntry/RawMaterialEntryEditDialogViewModel.cs b/yy-admin-master/YY.Admin/ViewModels/RawMaterialEntry/RawMaterialEntryEditDialogViewModel.cs index 15b8a0c..b480b24 100644 --- a/yy-admin-master/YY.Admin/ViewModels/RawMaterialEntry/RawMaterialEntryEditDialogViewModel.cs +++ b/yy-admin-master/YY.Admin/ViewModels/RawMaterialEntry/RawMaterialEntryEditDialogViewModel.cs @@ -1,6 +1,9 @@ using HandyControl.Controls; using HandyControl.Tools.Extension; +using System.Collections.Specialized; +using System.ComponentModel; using System.Collections.ObjectModel; +using System.Globalization; using YY.Admin.Core; using YY.Admin.Core.Entity; using YY.Admin.Core.Services; @@ -117,6 +120,9 @@ public class RawMaterialEntryEditDialogViewModel : BaseViewModel, IDialogResulta public ObservableCollection> StatusOptions { get; } = new(); public ObservableCollection SplitCodeDetails { get; } = new(); public double SplitCodeTableHeight => CalculateSplitCodeTableHeight(); + public string SplitTotalPortionsDisplay => JoinSplitValue(item => item.Portions?.ToString(CultureInfo.InvariantCulture), true); + public string SplitPortionWeightDisplay => JoinSplitValue(item => FormatNullableDecimal(item.PortionWeight), true); + public string SplitPortionPackagesDisplay => JoinSplitValue(item => item.PortionPackages?.ToString(CultureInfo.InvariantCulture), true); private bool _result; public bool Result { get => _result; set => SetProperty(ref _result, value); } @@ -151,7 +157,7 @@ public class RawMaterialEntryEditDialogViewModel : BaseViewModel, IDialogResulta ClearMaterialCommand = new DelegateCommand(ClearMaterialSelection); OpenWeightRecordPickerCommand = new DelegateCommand(async () => await OpenWeightRecordPickerAsync()); ClearWeightRecordCommand = new DelegateCommand(ClearWeightRecordSelection); - SplitCodeDetails.CollectionChanged += (_, _) => RaisePropertyChanged(nameof(SplitCodeTableHeight)); + SplitCodeDetails.CollectionChanged += OnSplitCodeDetailsCollectionChanged; _ = LoadAllAsync(); } @@ -298,6 +304,9 @@ public class RawMaterialEntryEditDialogViewModel : BaseViewModel, IDialogResulta RaisePropertyChanged(nameof(TotalWeightInput)); RaisePropertyChanged(nameof(TotalPortionsInput)); RaisePropertyChanged(nameof(IsSpecialAdoptionValue)); + RaisePropertyChanged(nameof(SplitTotalPortionsDisplay)); + RaisePropertyChanged(nameof(SplitPortionWeightDisplay)); + RaisePropertyChanged(nameof(SplitPortionPackagesDisplay)); } public void InitializeForEdit(MesXslRawMaterialEntry entry) @@ -339,6 +348,9 @@ public class RawMaterialEntryEditDialogViewModel : BaseViewModel, IDialogResulta RaisePropertyChanged(nameof(TotalWeightInput)); RaisePropertyChanged(nameof(TotalPortionsInput)); RaisePropertyChanged(nameof(IsSpecialAdoptionValue)); + RaisePropertyChanged(nameof(SplitTotalPortionsDisplay)); + RaisePropertyChanged(nameof(SplitPortionWeightDisplay)); + RaisePropertyChanged(nameof(SplitPortionPackagesDisplay)); } private async Task SaveAsync() @@ -548,6 +560,71 @@ public class RawMaterialEntryEditDialogViewModel : BaseViewModel, IDialogResulta RaisePropertyChanged(nameof(SplitCodeTableHeight)); } + private void OnSplitCodeDetailsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) + { + if (e.OldItems != null) + { + foreach (var oldItem in e.OldItems.OfType()) + { + oldItem.PropertyChanged -= OnSplitDetailItemPropertyChanged; + } + } + + if (e.NewItems != null) + { + foreach (var newItem in e.NewItems.OfType()) + { + newItem.PropertyChanged += OnSplitDetailItemPropertyChanged; + } + } + + RaiseSplitDisplayPropertyChanged(); + RaisePropertyChanged(nameof(SplitCodeTableHeight)); + } + + private void OnSplitDetailItemPropertyChanged(object? sender, PropertyChangedEventArgs e) + { + if (e.PropertyName is nameof(RawMaterialSplitDetailItem.Portions) + or nameof(RawMaterialSplitDetailItem.PortionWeight) + or nameof(RawMaterialSplitDetailItem.PortionPackages)) + { + RaiseSplitDisplayPropertyChanged(); + } + } + + private void RaiseSplitDisplayPropertyChanged() + { + RaisePropertyChanged(nameof(SplitTotalPortionsDisplay)); + RaisePropertyChanged(nameof(SplitPortionWeightDisplay)); + RaisePropertyChanged(nameof(SplitPortionPackagesDisplay)); + } + + private string JoinSplitValue(Func selector, bool withTrailingSlash) + { + var values = SplitCodeDetails + .Select(selector) + .Where(x => !string.IsNullOrWhiteSpace(x)) + .Select(x => x!.Trim()) + .ToList(); + if (values.Count == 0) + { + return string.Empty; + } + + var joined = string.Join("/", values); + return withTrailingSlash ? $"{joined}/" : joined; + } + + private static string? FormatNullableDecimal(double? value) + { + if (!value.HasValue) + { + return null; + } + + return value.Value.ToString("0.##", CultureInfo.InvariantCulture); + } + private void ApplyFirstSplitDetailToEntry() { if (Entry == null || SplitCodeDetails.Count == 0) diff --git a/yy-admin-master/YY.Admin/Views/RawMaterialEntry/RawMaterialEntryOperationView.xaml b/yy-admin-master/YY.Admin/Views/RawMaterialEntry/RawMaterialEntryOperationView.xaml index 3cccb98..cfffc17 100644 --- a/yy-admin-master/YY.Admin/Views/RawMaterialEntry/RawMaterialEntryOperationView.xaml +++ b/yy-admin-master/YY.Admin/Views/RawMaterialEntry/RawMaterialEntryOperationView.xaml @@ -25,10 +25,15 @@ + - + @@ -76,7 +81,7 @@ hc:InfoElement.TitleWidth="80" hc:InfoElement.TitlePlacement="Left" Foreground="{DynamicResource SecondaryTextBrush}" - Margin="0,0,0,8"/> + Margin="0,0,0,4"/> @@ -88,7 +93,7 @@ hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Placeholder="自动生成" hc:InfoElement.ShowClearButton="True" - Margin="0,0,0,8"/> + Margin="0,0,0,4"/> @@ -100,11 +105,11 @@ hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Placeholder="自动生成" hc:InfoElement.ShowClearButton="True" - Margin="0,0,0,8"/> + Margin="0,0,0,4"/> - + @@ -116,7 +121,7 @@ - + @@ -154,7 +159,7 @@ hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Placeholder="请输入供料客户" hc:InfoElement.ShowClearButton="True" - Margin="0,0,0,8"/> + Margin="0,0,0,4"/> @@ -166,7 +171,7 @@ hc:InfoElement.Placeholder="根据榜单自动带出" hc:InfoElement.ShowClearButton="True" IsReadOnly="True" - Margin="0,0,0,8"/> + Margin="0,0,0,4"/> @@ -178,7 +183,7 @@ hc:InfoElement.Placeholder="自动带出厂家别名" hc:InfoElement.ShowClearButton="True" IsReadOnly="True" - Margin="0,0,0,8"/> + Margin="0,0,0,4"/> @@ -190,7 +195,7 @@ hc:InfoElement.Placeholder="自动计算到期日期" hc:InfoElement.ShowClearButton="True" IsReadOnly="True" - Margin="0,0,0,8"/> + Margin="0,0,0,4"/> @@ -203,99 +208,40 @@ hc:InfoElement.TitleWidth="80" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Placeholder="请输入总重" - Margin="0,0,0,8"/> + Margin="0,0,0,4"/> - + - + - - - - - - - - - - - - - - - - - + @@ -306,7 +252,7 @@ hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Placeholder="请输入库位" hc:InfoElement.ShowClearButton="True" - Margin="0,0,0,8"/> + Margin="0,0,0,4"/> @@ -317,7 +263,7 @@ hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Placeholder="请输入卸货人" hc:InfoElement.ShowClearButton="True" - Margin="0,0,0,8"/> + Margin="0,0,0,4"/> @@ -330,88 +276,7 @@ hc:InfoElement.TitleWidth="80" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Placeholder="请选择是否特采" - Margin="0,0,0,8"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Margin="0,0,0,4"/> @@ -426,13 +291,64 @@ HorizontalAlignment="Stretch" Height="64" VerticalScrollBarVisibility="Auto" - Margin="0,0,0,8"/> + Margin="0,0,0,4"/> + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - -