步步为盈
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.9 KiB

using BBWY.Client.APIServices;
using BBWY.Client.Models;
using BBWY.Common.Models;
using GalaSoft.MvvmLight.Command;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace BBWY.Client.ViewModels
{
public class ChoosePurchaseSchemeViewModel : BaseVM, IDenpendency
{
private PurchaseService purchaseService;
private GlobalContext globalContext;
public string SkuId { get; set; }
public IList<PurchaseScheme> PurchaseSchemeList { get; set; }
public ICommand DeleteCommand { get; set; }
public ChoosePurchaseSchemeViewModel(PurchaseService purchaseService, GlobalContext globalContext)
{
this.purchaseService = purchaseService;
this.globalContext = globalContext;
PurchaseSchemeList = new ObservableCollection<PurchaseScheme>();
DeleteCommand = new RelayCommand<PurchaseScheme>(Delete);
}
protected override void Load()
{
PurchaseSchemeList.Clear();
Task.Factory.StartNew(() => purchaseService.GetPurchaseSchemeList(SkuId, globalContext.User.Shop.ShopId)).ContinueWith(t =>
{
var r = t.Result;
if (!r.Success)
{
App.Current.Dispatcher.Invoke(() => MessageBox.Show(r.Msg, "获取采购方案"));
return;
}
App.Current.Dispatcher.Invoke(() =>
{
foreach (var apiModel in r.Data) PurchaseSchemeList.Add(PurchaseScheme.Convert(apiModel));
});
});
}
3 years ago
protected override void Unload()
{
this.SkuId = string.Empty;
PurchaseSchemeList.Clear();
}
public void Delete(PurchaseScheme purchaseScheme)
{
}
}
}