diff --git a/BBWY.Client/Models/Product/PurchaseSchemeProductSku.cs b/BBWY.Client/Models/Product/PurchaseSchemeProductSku.cs index 20f5c206..6857fc82 100644 --- a/BBWY.Client/Models/Product/PurchaseSchemeProductSku.cs +++ b/BBWY.Client/Models/Product/PurchaseSchemeProductSku.cs @@ -7,6 +7,10 @@ namespace BBWY.Client.Models /// public class PurchaseSchemeProductSku : NotifyObject { + public PurchaseSchemeProductSku() + { + QuantityRatio = 1; + } /// /// 采购商品的SKU和采购方案的关系Id /// @@ -51,7 +55,16 @@ namespace BBWY.Client.Models private int itemTotal; private decimal skuAmount; + private int quantityRatio; public Action OnItemTotalChanged { get; set; } + + /// + /// 组成一件sku所需的数量 + /// + public int QuantityRatio + { + get => quantityRatio; set { Set(ref quantityRatio, value); } + } } } diff --git a/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseCreateNewOrderViewModel.cs b/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseCreateNewOrderViewModel.cs index 6221c2b4..1b665612 100644 --- a/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseCreateNewOrderViewModel.cs +++ b/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseCreateNewOrderViewModel.cs @@ -64,6 +64,8 @@ namespace BBWY.Client.ViewModels public ICommand AddProductSkuCommand { get; set; } public ICommand DeleteProductSkuWithSchemeCommand { get; set; } + public ICommand EditQuantityRatioCommand { get; set; } + public BatchPurchaseCreateNewOrderViewModel(PurchaseProductAPIService purchaseProductAPIService, PurchaseService purchaseService, GlobalContext globalContext) { this.globalContext = globalContext; @@ -75,7 +77,7 @@ namespace BBWY.Client.ViewModels PreviewOrderCommand = new RelayCommand(PreviewOrder); AddProductSkuCommand = new RelayCommand(AddProductSku); DeleteProductSkuWithSchemeCommand = new RelayCommand(DeleteProductSkuWithScheme); - + EditQuantityRatioCommand = new RelayCommand(EditQuantityRatio); this.delayTrigger = new DelayTrigger(); this.delayTrigger.OnExecute = OnDelayTriggerExecute; } @@ -100,7 +102,7 @@ namespace BBWY.Client.ViewModels return; } - IsLoading = false; + IsLoading = true; //IsLoading = true; //Task.Factory.StartNew(() => purchaseOrderService.PreviewPurchaseOrder(new Consignee() //{ @@ -292,5 +294,20 @@ namespace BBWY.Client.ViewModels ProductSkuWithSchemeList.Remove(productSkuWithScheme); this.delayTrigger.SetKey(Guid.NewGuid().ToString()); } + + private void EditQuantityRatio(object param) + { + var paramList = (object[])param; + var skuQuantity = Convert.ToInt32(paramList[0]); + var purchaseSchemeProductSku = paramList[1] as PurchaseSchemeProductSku; + + var editWindow = new EditQuantityRatioWindow(purchaseSchemeProductSku.QuantityRatio); + if (editWindow.ShowDialog() == true) + { + var quantityRatio = editWindow.QuantityRatio; + purchaseSchemeProductSku.QuantityRatio = quantityRatio; + purchaseSchemeProductSku.ItemTotal = quantityRatio * skuQuantity; + } + } } } diff --git a/BBWY.Client/Views/BatchPurchase/BatchCreateNewPurchaseOrder.xaml b/BBWY.Client/Views/BatchPurchase/BatchCreateNewPurchaseOrder.xaml index 40925521..10a00781 100644 --- a/BBWY.Client/Views/BatchPurchase/BatchCreateNewPurchaseOrder.xaml +++ b/BBWY.Client/Views/BatchPurchase/BatchCreateNewPurchaseOrder.xaml @@ -4,13 +4,19 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:BBWY.Client.Views.BatchPurchase" + xmlns:ctr="clr-namespace:BBWY.Client.Converters" mc:Ignorable="d" xmlns:cmodel="clr-namespace:BBWY.Client.Models" xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls" xmlns:b="http://schemas.microsoft.com/xaml/behaviors" Style="{StaticResource bwstyle}" DataContext="{Binding BatchPurchaseCreateNewOrder,Source={StaticResource Locator}}" - Title="新建采购单" Height="768" Width="1024"> + Title="新建采购单" Height="768" Width="1024" + MinButtonVisibility="Collapsed" + MaxButtonVisibility="Collapsed"> + + + @@ -200,14 +206,23 @@ - + + Foreground="{StaticResource Text.Color}" + Command="{Binding DataContext.EditQuantityRatioCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}}}"> + + + + + + + + + DataContext="{Binding BatchPurchaseAddProductSku,Source={StaticResource Locator}}" + MinButtonVisibility="Collapsed" + MaxButtonVisibility="Collapsed"> diff --git a/BBWY.Client/Views/BatchPurchase/EditQuantityRatioWindow.xaml b/BBWY.Client/Views/BatchPurchase/EditQuantityRatioWindow.xaml new file mode 100644 index 00000000..3a0bf5f7 --- /dev/null +++ b/BBWY.Client/Views/BatchPurchase/EditQuantityRatioWindow.xaml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/BatchPurchase/EditQuantityRatioWindow.xaml.cs b/BBWY.Client/Views/BatchPurchase/EditQuantityRatioWindow.xaml.cs new file mode 100644 index 00000000..455d56d9 --- /dev/null +++ b/BBWY.Client/Views/BatchPurchase/EditQuantityRatioWindow.xaml.cs @@ -0,0 +1,43 @@ +using BBWY.Controls; +using System.Windows; + +namespace BBWY.Client.Views.BatchPurchase +{ + /// + /// EditQuantityRatioWindow.xaml 的交互逻辑 + /// + public partial class EditQuantityRatioWindow : BWindow + { + public int QuantityRatio; + + public EditQuantityRatioWindow(int quantityRatio) + { + InitializeComponent(); + this.QuantityRatio = quantityRatio; + this.Loaded += EditQuantityRatioWindow_Loaded; + } + + private void EditQuantityRatioWindow_Loaded(object sender, RoutedEventArgs e) + { + txt_quantityRatio.Text = QuantityRatio.ToString(); + } + + private void btn_Save_Click(object sender, RoutedEventArgs e) + { + if (!int.TryParse(txt_quantityRatio.Text, out int quantityRatio)) + { + MessageBox.Show("无效数字", "提示"); + return; + } + if (quantityRatio <= 0) + { + MessageBox.Show("无效数字", "提示"); + return; + } + + this.QuantityRatio = quantityRatio; + this.DialogResult = true; + this.Close(); + } + } +}