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