shanji 2 years ago
parent
commit
4c807e910b
  1. 13
      BBWY.Client/Models/Product/PurchaseSchemeProductSku.cs
  2. 21
      BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseCreateNewOrderViewModel.cs
  3. 21
      BBWY.Client/Views/BatchPurchase/BatchCreateNewPurchaseOrder.xaml
  4. 4
      BBWY.Client/Views/BatchPurchase/BatchPurchaseAddProductSku.xaml
  5. 39
      BBWY.Client/Views/BatchPurchase/EditQuantityRatioWindow.xaml
  6. 43
      BBWY.Client/Views/BatchPurchase/EditQuantityRatioWindow.xaml.cs

13
BBWY.Client/Models/Product/PurchaseSchemeProductSku.cs

@ -7,6 +7,10 @@ namespace BBWY.Client.Models
/// </summary>
public class PurchaseSchemeProductSku : NotifyObject
{
public PurchaseSchemeProductSku()
{
QuantityRatio = 1;
}
/// <summary>
/// 采购商品的SKU和采购方案的关系Id
/// </summary>
@ -51,7 +55,16 @@ namespace BBWY.Client.Models
private int itemTotal;
private decimal skuAmount;
private int quantityRatio;
public Action<int> OnItemTotalChanged { get; set; }
/// <summary>
/// 组成一件sku所需的数量
/// </summary>
public int QuantityRatio
{
get => quantityRatio; set { Set(ref quantityRatio, value); }
}
}
}

21
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<ProductSkuWithScheme>(DeleteProductSkuWithScheme);
EditQuantityRatioCommand = new RelayCommand<object>(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;
}
}
}
}

21
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">
<c:BWindow.Resources>
<ctr:MultiParameterTransferConverter x:Key="mptConverter"/>
</c:BWindow.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
@ -200,14 +206,23 @@
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Margin="0,0,2,0"/>
<TextBlock Text="1" Style="{StaticResource middleTextBlock}" Grid.Column="1" Margin="0,0,0,25"/>
<TextBlock Text="{Binding QuantityRatio}" Style="{StaticResource middleTextBlock}" Grid.Column="1" Margin="0,0,0,25"/>
<c:BButton Content="修改" Grid.Column="1" VerticalAlignment="Bottom"
Background="White"
Foreground="{StaticResource Text.Color}"/>
Foreground="{StaticResource Text.Color}"
Command="{Binding DataContext.EditQuantityRatioCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}}}">
<c:BButton.CommandParameter>
<MultiBinding Converter="{StaticResource mptConverter}">
<Binding Path="DataContext.Quantity" RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1}"/>
<Binding Path="."/>
</MultiBinding>
</c:BButton.CommandParameter>
</c:BButton>
<Border Grid.Column="1" Height="1" Background="{StaticResource Border.Brush}" VerticalAlignment="Bottom" Margin="-2,0,2,30"/>
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Margin="0,0,2,0" Grid.Column="1"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Column="2" Margin="0,0,5,0">
<c:BButton Content="-" Background="White" Foreground="Black"
BorderBrush="{StaticResource Border.Brush}"

4
BBWY.Client/Views/BatchPurchase/BatchPurchaseAddProductSku.xaml

@ -10,7 +10,9 @@
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
Style="{StaticResource bwstyle}"
Title="BatchPurchaseAddProductSku" Height="600" Width="550"
DataContext="{Binding BatchPurchaseAddProductSku,Source={StaticResource Locator}}">
DataContext="{Binding BatchPurchaseAddProductSku,Source={StaticResource Locator}}"
MinButtonVisibility="Collapsed"
MaxButtonVisibility="Collapsed">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>

39
BBWY.Client/Views/BatchPurchase/EditQuantityRatioWindow.xaml

@ -0,0 +1,39 @@
<c:BWindow x:Class="BBWY.Client.Views.BatchPurchase.EditQuantityRatioWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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"
mc:Ignorable="d"
xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls"
Title="EditQuantityRatioWindow" Height="150" Width="300"
Style="{StaticResource bwstyle}"
MinButtonVisibility="Collapsed"
MaxButtonVisibility="Collapsed">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource MainMenu.BorderBrush}"
Background="{StaticResource Border.Background}">
<TextBlock Text="组合配置" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center">
<StackPanel Orientation="Horizontal">
<TextBlock VerticalAlignment="Center">
<Run Text="1件" Foreground="{StaticResource Text.Pink}"/>
<Run Text="店铺SKU需要配置的数量"/>
</TextBlock>
<c:BTextBox x:Name="txt_quantityRatio" Width="55" Margin="5,0,0,0"/>
</StackPanel>
<TextBlock Text="该数量为组合配置比例,非实际采购数量" Margin="0,10,0,0"
Foreground="Gray"/>
</StackPanel>
<c:BButton x:Name="btn_Save" Content="保存" Grid.Row="2" Width="60" HorizontalAlignment="Right" Margin="0,0,8,0"
Click="btn_Save_Click"/>
</Grid>
</c:BWindow>

43
BBWY.Client/Views/BatchPurchase/EditQuantityRatioWindow.xaml.cs

@ -0,0 +1,43 @@
using BBWY.Controls;
using System.Windows;
namespace BBWY.Client.Views.BatchPurchase
{
/// <summary>
/// EditQuantityRatioWindow.xaml 的交互逻辑
/// </summary>
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();
}
}
}
Loading…
Cancel
Save