shanji 2 years ago
parent
commit
210b1ada73
  1. 35
      BBWY.Client/APIServices/BatchPurchaseService.cs
  2. 116
      BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseAddProductSkuViewModel.cs
  3. 12
      BBWY.Client/Views/BatchPurchase/BatchPurchaseAddProductSku.xaml

35
BBWY.Client/APIServices/BatchPurchaseService.cs

@ -0,0 +1,35 @@
using BBWY.Client.Models;
using BBWY.Common.Http;
using BBWY.Common.Models;
using System.Collections.Generic;
using System.Net.Http;
namespace BBWY.Client.APIServices
{
public class BatchPurchaseService : BaseApiService, IDenpendency
{
public BatchPurchaseService(RestApiService restApiService, GlobalContext globalContext) : base(restApiService, globalContext)
{
}
/// <summary>
/// 获取包含对应平台采购方案的sku列表
/// </summary>
/// <param name="sku"></param>
/// <param name="spu"></param>
/// <returns></returns>
public ApiResponse<IList<ProductSkuWithSchemeResponse>> GetProductSkuAndSchemeList(string sku, string spu)
{
return SendRequest<IList<ProductSkuWithSchemeResponse>>(globalContext.BBYWApiHost, "api/BatchPurchase/GetProductSkuAndSchemeList", new
{
globalContext.User.Shop.Platform,
globalContext.User.Shop.AppKey,
globalContext.User.Shop.AppSecret,
globalContext.User.Shop.AppToken,
globalContext.User.Shop.ShopId,
sku,
spu
}, null, HttpMethod.Post);
}
}
}

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

@ -1,10 +1,124 @@
using System;
using BBWY.Client.APIServices;
using BBWY.Client.Models;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows.Input;
namespace BBWY.Client.ViewModels
{
public class BatchPurchaseAddProductSkuViewModel : BaseVM
{
private BatchPurchaseService batchPurchaseService;
private string sku;
private string spu;
private Purchaser selectedPurchaser;
private Purchaser defaultPurchaser;
private KVModel selectedPurchasePlatform;
private KVModel defaultPurchasePlatform;
public ICommand SearchCommand { get; set; }
public ICommand FilterCommand { get; set; }
public string Sku { get => sku; set { Set(ref sku, value); } }
public string Spu { get => spu; set { Set(ref spu, value); } }
public IList<Purchaser> PurchaserList { get; set; }
public IList<KVModel> PurchasePlatformList { get; set; }
public Purchaser SelectedPurchaser
{
get => selectedPurchaser; set
{
if (Set(ref selectedPurchaser, value))
OnFilterChanged();
}
}
public KVModel SelectedPurchasePlatform
{
get => selectedPurchasePlatform; set
{
if (Set(ref selectedPurchasePlatform, value))
OnFilterChanged();
}
}
public IList<ProductSkuWithScheme> SourceList { get; set; }
public IList<ProductSkuWithScheme> FilterList { get; set; }
public BatchPurchaseAddProductSkuViewModel(BatchPurchaseService batchPurchaseService)
{
this.batchPurchaseService = batchPurchaseService;
defaultPurchaser = new Purchaser() { Id = "-1", Name = "全部" };
defaultPurchasePlatform = new KVModel() { Key = "-1", Value = "全部" };
PurchaserList = new ObservableCollection<Purchaser>() { defaultPurchaser };
PurchasePlatformList = new ObservableCollection<KVModel>()
{
defaultPurchasePlatform,
new KVModel(){ Key=((int)Platform.).ToString(),Value = Platform..ToString() },
new KVModel(){ Key=((int)Platform.).ToString(),Value = Platform..ToString() }
};
SourceList = new List<ProductSkuWithScheme>();
FilterList = new List<ProductSkuWithScheme>();
SelectedPurchaser = PurchaserList[0];
SelectedPurchasePlatform = PurchasePlatformList[0];
SearchCommand = new RelayCommand(Search);
FilterCommand = new RelayCommand(Filter);
}
private void OnFilterChanged()
{
if (SourceList.Count() == 0)
return;
FilterList.Clear();
var resultList = new List<ProductSkuWithScheme>();
resultList.AddRange(SourceList);
if (SelectedPurchaser.Id != "-1")
{
for (var i = 0; i < resultList.Count(); i++)
{
if (resultList[i].PurchaserId != SelectedPurchaser.Id)
{
resultList.Remove(resultList[i]);
i--;
}
}
}
if (SelectedPurchasePlatform.Key != "-1")
{
for (var i = 0; i < resultList.Count(); i++)
{
if (resultList[i].PurchasePlatform != (Platform)int.Parse(SelectedPurchasePlatform.Key))
{
resultList.Remove(resultList[i]);
i--;
}
}
}
if (resultList.Count() > 0)
{
foreach (var item in resultList)
FilterList.Add(item);
}
}
private void Search()
{
}
private void Filter()
{
}
}
}

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

@ -28,10 +28,10 @@
<Grid Grid.Row="1" Margin="5,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="150"/>
<ColumnDefinition/>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="150"/>
<ColumnDefinition/>
<ColumnDefinition Width="80"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
@ -43,7 +43,7 @@
<TextBlock Text="SKU" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="2" Margin="0,0,5,0"/>
<c:BTextBox Grid.Column="3"/>
<c:BButton Grid.Column="4" Content="搜索" Width="70"/>
<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"/>
<ComboBox Grid.Column="1" Grid.Row="1" Height="30"/>
@ -51,7 +51,11 @@
<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"/>
<c:BButton Grid.Column="4" Content="搜索" Width="70" Grid.Row="1"/>
<c:BButton Grid.Column="4" Content="筛选" Width="70" Grid.Row="1" Background="#2879FF" Command="{Binding FilterCommand}"/>
</Grid>
<c:BButton Grid.Column="4" Content="确定" Width="80" Grid.Row="3" Command="{Binding SaveCommand}" HorizontalAlignment="Right" Margin="0,0,5,0"/>
</Grid>
</c:BWindow>

Loading…
Cancel
Save