步步为盈
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.

76 lines
2.5 KiB

using BBWY.Client.Models;
3 years ago
using BBWY.Client.Views.SelectShop;
3 years ago
using BBWY.Common.Extensions;
using GalaSoft.MvvmLight.Command;
3 years ago
using System.Threading.Tasks;
using System.Windows;
3 years ago
using System.Windows.Input;
namespace BBWY.Client.ViewModels
{
public partial class OrderListViewModel
{
private int sdGroupButtonIndex;
private Shop sdGroupSelectedShop;
3 years ago
3 years ago
public int SDGroupButtonIndex { get => sdGroupButtonIndex; set { Set(ref sdGroupButtonIndex, value); } }
3 years ago
public ICommand SetSDButtinIndexCommand { get; set; }
3 years ago
public ICommand SDGroupSelectedShopChangedCommand { get; set; }
3 years ago
3 years ago
public ICommand SDGroupPullCommand { get; set; }
public Shop SdGroupSelectedShop { get => sdGroupSelectedShop; set { Set(ref sdGroupSelectedShop, value); } }
3 years ago
private void SDGroupInit()
{
SetSDButtinIndexCommand = new RelayCommand<int>(SetSDButtinIndex);
3 years ago
SDGroupSelectedShopChangedCommand = new RelayCommand<OnShopChangedEventArgs>(SDGroupSelectedShopChanged);
3 years ago
SDGroupPullCommand = new RelayCommand(SDGroupPull);
3 years ago
}
private void SetSDButtinIndex(int index)
{
SDGroupButtonIndex = index;
3 years ago
OrderList.Clear();
3 years ago
SearchOrderId = string.Empty;
3 years ago
OrderCount = 0;
PageIndex = 1;
3 years ago
}
3 years ago
private void SDGroupSelectedShopChanged(OnShopChangedEventArgs args)
{
this.SdGroupSelectedShop = args.SelectedShop;
}
3 years ago
private void SDGroupPull()
{
if (string.IsNullOrEmpty(SearchOrderId) || this.SdGroupSelectedShop == null)
{
MessageBox.Show("拉取条件不齐全", "提示");
return;
}
IsLoading = true;
Task.Factory.StartNew(() => orderService.SDGroupPullOrder(SearchOrderId, SdGroupSelectedShop)).ContinueWith(t =>
{
IsLoading = false;
var response = t.Result;
if (!response.Success)
{
App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "拉取订单"));
return;
}
PageIndex = 1;
OrderCount = 1;
var order = response.Data.Map<Order>();
App.Current.Dispatcher.Invoke(() =>
{
OrderList.Clear();
OrderList.Add(order);
});
});
}
3 years ago
}
}