|
@ -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() |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|