diff --git a/BBWY.Client/APIServices/BatchPurchaseService.cs b/BBWY.Client/APIServices/BatchPurchaseService.cs new file mode 100644 index 00000000..569c5011 --- /dev/null +++ b/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) + { + } + + /// + /// 获取包含对应平台采购方案的sku列表 + /// + /// + /// + /// + public ApiResponse> GetProductSkuAndSchemeList(string sku, string spu) + { + return SendRequest>(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); + } + } +} diff --git a/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseAddProductSkuViewModel.cs b/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseAddProductSkuViewModel.cs index 53757b1b..c9cfc18e 100644 --- a/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseAddProductSkuViewModel.cs +++ b/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 PurchaserList { get; set; } + public IList 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 SourceList { get; set; } + public IList 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() { defaultPurchaser }; + PurchasePlatformList = new ObservableCollection() + { + defaultPurchasePlatform, + new KVModel(){ Key=((int)Platform.拳探).ToString(),Value = Platform.拳探.ToString() }, + new KVModel(){ Key=((int)Platform.阿里巴巴).ToString(),Value = Platform.阿里巴巴.ToString() } + }; + + SourceList = new List(); + FilterList = new List(); + 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(); + 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() + { + + } } } diff --git a/BBWY.Client/Views/BatchPurchase/BatchPurchaseAddProductSku.xaml b/BBWY.Client/Views/BatchPurchase/BatchPurchaseAddProductSku.xaml index a978de68..a1083ff4 100644 --- a/BBWY.Client/Views/BatchPurchase/BatchPurchaseAddProductSku.xaml +++ b/BBWY.Client/Views/BatchPurchase/BatchPurchaseAddProductSku.xaml @@ -28,10 +28,10 @@ - + - + @@ -43,7 +43,7 @@ - + @@ -51,7 +51,11 @@ - + + + + +