shanji 2 years ago
parent
commit
44a7421bb2
  1. 3
      BBWY.Client/Models/BatchPurchase/ProductSkuWithScheme.cs
  2. 1
      BBWY.Client/Models/MappingProfile.cs
  3. 24
      BBWY.Client/Models/Product/Purchaser.cs
  4. 94
      BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseAddProductSkuViewModel.cs
  5. 101
      BBWY.Client/Views/BatchPurchase/BatchPurchaseAddProductSku.xaml
  6. 2
      BBWY.Server.Business/PurchaseOrderV2/BatchPurchase/BatchPurchaseBusiness.cs

3
BBWY.Client/Models/BatchPurchase/ProductSkuWithScheme.cs

@ -7,6 +7,7 @@ namespace BBWY.Client.Models
public class ProductSkuWithScheme : NotifyObject public class ProductSkuWithScheme : NotifyObject
{ {
private int quantity; private int quantity;
private bool isSelected;
public string Id { get; set; } public string Id { get; set; }
public string SkuId { get; set; } public string SkuId { get; set; }
@ -41,6 +42,8 @@ namespace BBWY.Client.Models
public IList<PurchaseSchemeProductSku> PurchaseSchemeProductSkuList { get; set; } public IList<PurchaseSchemeProductSku> PurchaseSchemeProductSkuList { get; set; }
public bool IsSelected { get => isSelected; set { Set(ref isSelected, value); } }
public ProductSkuWithScheme() public ProductSkuWithScheme()
{ {
PurchaseSchemeProductSkuList = new ObservableCollection<PurchaseSchemeProductSku>(); PurchaseSchemeProductSkuList = new ObservableCollection<PurchaseSchemeProductSku>();

1
BBWY.Client/Models/MappingProfile.cs

@ -31,6 +31,7 @@ namespace BBWY.Client.Models
CreateMap<SDGroupPersonStatisticsResponse, SDGroupPersonStatistics>(); CreateMap<SDGroupPersonStatisticsResponse, SDGroupPersonStatistics>();
CreateMap<BillCorrectionOrderResponse, BillCorrectionOrder>(); CreateMap<BillCorrectionOrderResponse, BillCorrectionOrder>();
CreateMap<ServiceOrderItemResponse, ServiceOrder>(); CreateMap<ServiceOrderItemResponse, ServiceOrder>();
CreateMap<ProductSkuWithSchemeResponse, ProductSkuWithScheme>();
} }
} }
} }

24
BBWY.Client/Models/Product/Purchaser.cs

@ -1,4 +1,8 @@
namespace BBWY.Client.Models using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace BBWY.Client.Models
{ {
/// <summary> /// <summary>
/// 采购商 /// 采购商
@ -22,4 +26,22 @@
public Platform Platform { get; set; } public Platform Platform { get; set; }
} }
public class PurchaserComparer : IEqualityComparer<Purchaser>
{
public bool Equals([AllowNull] Purchaser x, [AllowNull] Purchaser y)
{
if (Object.ReferenceEquals(x, y)) return true;
if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))
return false;
return x?.Id == y?.Id;
}
public int GetHashCode([DisallowNull] Purchaser obj)
{
return base.GetHashCode();
}
}
} }

94
BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseAddProductSkuViewModel.cs

@ -1,18 +1,20 @@
using BBWY.Client.APIServices; using BBWY.Client.APIServices;
using BBWY.Client.Models; using BBWY.Client.Models;
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using BBWY.Common.Extensions;
namespace BBWY.Client.ViewModels namespace BBWY.Client.ViewModels
{ {
public class BatchPurchaseAddProductSkuViewModel : BaseVM public class BatchPurchaseAddProductSkuViewModel : BaseVM
{ {
private BatchPurchaseService batchPurchaseService; private BatchPurchaseService batchPurchaseService;
private bool isLoading;
private string sku; private string sku;
private string spu; private string spu;
private Purchaser selectedPurchaser; private Purchaser selectedPurchaser;
@ -21,8 +23,12 @@ namespace BBWY.Client.ViewModels
private KVModel selectedPurchasePlatform; private KVModel selectedPurchasePlatform;
private KVModel defaultPurchasePlatform; private KVModel defaultPurchasePlatform;
private bool allSelected;
public ICommand SearchCommand { get; set; } public ICommand SearchCommand { get; set; }
public ICommand FilterCommand { get; set; } public ICommand FilterCommand { get; set; }
public ICommand SaveCommand { get; set; }
public string Sku { get => sku; set { Set(ref sku, value); } } public string Sku { get => sku; set { Set(ref sku, value); } }
public string Spu { get => spu; set { Set(ref spu, value); } } public string Spu { get => spu; set { Set(ref spu, value); } }
@ -31,24 +37,26 @@ namespace BBWY.Client.ViewModels
public IList<KVModel> PurchasePlatformList { get; set; } public IList<KVModel> PurchasePlatformList { get; set; }
public Purchaser SelectedPurchaser public Purchaser SelectedPurchaser
{ {
get => selectedPurchaser; set get => selectedPurchaser; set { Set(ref selectedPurchaser, value); }
{
if (Set(ref selectedPurchaser, value))
OnFilterChanged();
}
} }
public KVModel SelectedPurchasePlatform public KVModel SelectedPurchasePlatform
{ {
get => selectedPurchasePlatform; set get => selectedPurchasePlatform; set { Set(ref selectedPurchasePlatform, value); }
{
if (Set(ref selectedPurchasePlatform, value))
OnFilterChanged();
}
} }
public IList<ProductSkuWithScheme> SourceList { get; set; } public IList<ProductSkuWithScheme> SourceList { get; set; }
public IList<ProductSkuWithScheme> FilterList { get; set; } public IList<ProductSkuWithScheme> FilterList { get; set; }
public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } }
public bool AllSelected
{
get => allSelected; set
{
if (Set(ref allSelected, value))
OnAllSelectedChanged();
}
}
public BatchPurchaseAddProductSkuViewModel(BatchPurchaseService batchPurchaseService) public BatchPurchaseAddProductSkuViewModel(BatchPurchaseService batchPurchaseService)
{ {
@ -66,17 +74,63 @@ namespace BBWY.Client.ViewModels
SourceList = new List<ProductSkuWithScheme>(); SourceList = new List<ProductSkuWithScheme>();
FilterList = new List<ProductSkuWithScheme>(); FilterList = new List<ProductSkuWithScheme>();
SelectedPurchaser = PurchaserList[0];
SelectedPurchasePlatform = PurchasePlatformList[0];
SearchCommand = new RelayCommand(Search); SearchCommand = new RelayCommand(Search);
FilterCommand = new RelayCommand(Filter); FilterCommand = new RelayCommand(Filter);
SaveCommand = new RelayCommand(Save);
SelectedPurchaser = PurchaserList[0];
SelectedPurchasePlatform = PurchasePlatformList[0];
}
private void Search()
{
IsLoading = true;
Task.Factory.StartNew(() => batchPurchaseService.GetProductSkuAndSchemeList(Sku, Spu)).ContinueWith(t =>
{
IsLoading = false;
var response = t.Result;
if (!response.Success)
{
App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "提示"));
return;
}
SourceList.Clear();
App.Current.Dispatcher.Invoke(() =>
{
PurchaserList.Clear();
FilterList.Clear();
PurchaserList.Add(defaultPurchaser);
SelectedPurchaser = PurchaserList[0];
SelectedPurchasePlatform = PurchasePlatformList[0];
});
if (response.Data == null || response.Data.Count() == 0)
return;
var list = response.Data.Map<IList<ProductSkuWithScheme>>();
#region 提取采购商
var purchaserList = list.Where(item => !string.IsNullOrEmpty(item.PurchaserId))
.Select(item => new Purchaser() { Id = item.PurchaserId, Name = item.PurchaseName, Platform = item.PurchasePlatform.Value })
.Distinct(new PurchaserComparer());
#endregion
App.Current.Dispatcher.Invoke(() =>
{
foreach (var purchaser in purchaserList)
PurchaserList.Add(purchaser);
foreach (var item in list)
SourceList.Add(item);
Filter();
});
});
} }
private void OnFilterChanged() private void Filter()
{ {
FilterList.Clear();
if (SourceList.Count() == 0) if (SourceList.Count() == 0)
return; return;
FilterList.Clear();
var resultList = new List<ProductSkuWithScheme>(); var resultList = new List<ProductSkuWithScheme>();
resultList.AddRange(SourceList); resultList.AddRange(SourceList);
@ -111,14 +165,14 @@ namespace BBWY.Client.ViewModels
} }
} }
private void Search() private void Save()
{ {
} }
private void Filter() private void OnAllSelectedChanged()
{ {
} }
} }
} }

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

@ -38,24 +38,117 @@
<RowDefinition/> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="SPU" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0"/> <TextBlock Text="SPU" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0"/>
<c:BTextBox Grid.Column="1"/> <c:BTextBox Grid.Column="1" Text="{Binding Spu}"/>
<TextBlock Text="SKU" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="2" Margin="0,0,5,0"/> <TextBlock Text="SKU" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="2" Margin="0,0,5,0"/>
<c:BTextBox Grid.Column="3"/> <c:BTextBox Grid.Column="3" Text="{Binding Sku}"/>
<c:BButton Grid.Column="4" Content="搜索" Width="70" Command="{Binding SearchCommand}"/> <c:BButton Grid.Column="4" Content="搜索" Width="70" Command="{Binding SearchCommand}"/>
<TextBlock Text="采购商" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Row="1" Margin="0,0,5,0"/> <TextBlock Text="采购商" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Row="1" Margin="0,0,5,0"/>
<ComboBox Grid.Column="1" Grid.Row="1" Height="30"/> <ComboBox Grid.Column="1" Grid.Row="1" Height="30"
ItemsSource="{Binding PurchaserList}"
DisplayMemberPath="Name"
VerticalContentAlignment="Center"/>
<TextBlock Text="平台" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="2" Grid.Row="1" Margin="0,0,5,0"/> <TextBlock Text="平台" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="2" Grid.Row="1" Margin="0,0,5,0"/>
<ComboBox Grid.Column="3" Grid.Row="1" Height="30"/> <ComboBox Grid.Column="3" Grid.Row="1" Height="30"
ItemsSource="{Binding PurchasePlatformList}"
DisplayMemberPath="Value"
VerticalContentAlignment="Center"/>
<c:BButton Grid.Column="4" Content="筛选" Width="70" Grid.Row="1" Background="#2879FF" Command="{Binding FilterCommand}"/> <c:BButton Grid.Column="4" Content="筛选" Width="70" Grid.Row="1" Background="#2879FF" Command="{Binding FilterCommand}"/>
</Grid> </Grid>
<DataGrid Grid.Row="2"
ItemsSource="{Binding FilterList}"
Margin="5,0"
BorderBrush="{StaticResource Border.Brush}"
BorderThickness="1"
RowHeight="90">
<DataGrid.Columns>
<DataGridTemplateColumn Width="35">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<CheckBox Margin="5,0,0,0"
IsChecked="{Binding DataContext.AllSelected,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type DataGrid}}}"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="商品信息" Width="*" HeaderStyle="{StaticResource ColumnHeaderStyle_Center}">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid Width="{Binding ActualWidth,ElementName=listbox_orerSku}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<!--{Binding Logo}-->
<c:BAsyncImage UrlSource="{Binding Logo}"
Width="80" DecodePixelWidth="80"
VerticalAlignment="Top" Margin="0,5,0,0"
Cursor="Hand"/>
<StackPanel Grid.Column="1" Orientation="Vertical" Margin="0,5,0,5">
<TextBlock TextTrimming="CharacterEllipsis">
<TextBlock.ToolTip>
<ToolTip Style="{StaticResource OrderCouponToolipStyle}">
<TextBlock Text="{Binding Title}"/>
</ToolTip>
</TextBlock.ToolTip>
<Run Text="SKU名称:"/>
<Run Text="{Binding Title}"/>
</TextBlock>
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="SPU:"/>
<c:BButton Content="{Binding ProductId}" Style="{StaticResource LinkButton}"
Command="{Binding DataContext.CopyTextCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Page}}}"
CommandParameter="{Binding ProductId}"
Margin=" 5,0,0,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="SKU:"/>
<c:BButton Content="{Binding Id}" Style="{StaticResource LinkButton}"
Command="{Binding DataContext.CopyTextCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Page}}}"
CommandParameter="{Binding Id}"
Margin=" 5,0,0,0"/>
</StackPanel>
<TextBlock TextWrapping="Wrap" Margin=" 5,0,0,0">
<Run Text="单价:"/>
<Run Text="{Binding Price}"/>
</TextBlock>
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="数量" Width="80" HeaderStyle="{StaticResource ColumnHeaderStyle_Center}">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<c:BButton Content="-"/>
<c:BTextBox Text="{Binding Quantity}" Margin="5,0"/>
<c:BButton Content="+"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<c:BButton Grid.Column="4" Content="确定" Width="80" Grid.Row="3" Command="{Binding SaveCommand}" HorizontalAlignment="Right" Margin="0,0,5,0"/> <c:BButton Grid.Column="4" Content="确定" Width="80" Grid.Row="3" Command="{Binding SaveCommand}" HorizontalAlignment="Right" Margin="0,0,5,0"/>
</Grid> </Grid>
</c:BWindow> </c:BWindow>

2
BBWY.Server.Business/PurchaseOrderV2/BatchPurchase/BatchPurchaseBusiness.cs

@ -23,7 +23,7 @@ namespace BBWY.Server.Business
/// <exception cref="BusinessException"></exception> /// <exception cref="BusinessException"></exception>
public IList<ProductSkuWithSchemeResponse> GetProductSkuAndSchemeList(SearchProductSkuAndSchemeRequest request) public IList<ProductSkuWithSchemeResponse> GetProductSkuAndSchemeList(SearchProductSkuAndSchemeRequest request)
{ {
if (string.IsNullOrEmpty(request.Spu) || string.IsNullOrEmpty(request.Sku)) if (string.IsNullOrEmpty(request.Spu) && string.IsNullOrEmpty(request.Sku))
throw new BusinessException("至少具备一个Sku或Spu条件"); throw new BusinessException("至少具备一个Sku或Spu条件");
var productSkuList = productBusiness.GetProductSkuList(new SearchProductSkuRequest() var productSkuList = productBusiness.GetProductSkuList(new SearchProductSkuRequest()

Loading…
Cancel
Save