3 changed files with 158 additions and 5 deletions
@ -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); |
|||
} |
|||
} |
|||
} |
@ -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() |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue