|
@ -1,9 +1,12 @@ |
|
|
using BBWY.Client.Models; |
|
|
using BBWY.Client.Models; |
|
|
using BBWY.Controls; |
|
|
using BBWY.Controls; |
|
|
|
|
|
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.Windows; |
|
|
using System.Windows; |
|
|
|
|
|
using System.Windows.Input; |
|
|
|
|
|
|
|
|
namespace BBWY.Client.Views.Order |
|
|
namespace BBWY.Client.Views.Order |
|
|
{ |
|
|
{ |
|
@ -12,22 +15,48 @@ namespace BBWY.Client.Views.Order |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public partial class RelationPurchaseOrder : BWindow |
|
|
public partial class RelationPurchaseOrder : BWindow |
|
|
{ |
|
|
{ |
|
|
|
|
|
public ICommand AddRelationPurchaseOrderSkuCommand { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public ICommand AddOrderDropShippingCommand { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public ICommand CloseShowChooseSkuPanelCommand { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IList<OrderDropShipping> OrderDropShippingList { get; set; } |
|
|
public IList<OrderDropShipping> OrderDropShippingList { get; set; } |
|
|
|
|
|
|
|
|
public IList<RelationPurchaseOrderSku> RelationPurchaseOrderSkuList { get; set; } |
|
|
public IList<RelationPurchaseOrderSku> RelationPurchaseOrderSkuList { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public IList<RelationPurchaseOrderSku> ChooseRelationPurchaseOrderSkuList { get; set; } |
|
|
|
|
|
|
|
|
public IList<PurchaseAccount> PurchaseAccountList { get; set; } |
|
|
public IList<PurchaseAccount> PurchaseAccountList { get; set; } |
|
|
|
|
|
|
|
|
public string OrderId { get; set; } |
|
|
public string OrderId { get; set; } |
|
|
|
|
|
|
|
|
public decimal TotalCost { get => totalCost; set { Set(ref totalCost, value); } } |
|
|
public decimal TotalCost { get => totalCost; set { Set(ref totalCost, value); } } |
|
|
|
|
|
public bool IsShowChooseSkuPanel |
|
|
|
|
|
{ |
|
|
|
|
|
get => isShowChooseSkuPanel; set |
|
|
|
|
|
{ |
|
|
|
|
|
if (Set(ref isShowChooseSkuPanel, value)) |
|
|
|
|
|
{ |
|
|
|
|
|
if (!value) |
|
|
|
|
|
OnShowChooseSkuPanelClose(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private decimal totalCost; |
|
|
private decimal totalCost; |
|
|
|
|
|
private bool isShowChooseSkuPanel; |
|
|
|
|
|
|
|
|
|
|
|
private OrderDropShipping currentOds; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public RelationPurchaseOrder(string orderId, IList<PurchaseAccount> purchaseAccountList, IList<OrderDropShipping> orderDropShippingList, IList<RelationPurchaseOrderSku> relationPurchaseOrderSkuList) |
|
|
public RelationPurchaseOrder(string orderId, IList<PurchaseAccount> purchaseAccountList, IList<OrderDropShipping> orderDropShippingList, IList<RelationPurchaseOrderSku> relationPurchaseOrderSkuList) |
|
|
{ |
|
|
{ |
|
|
InitializeComponent(); |
|
|
InitializeComponent(); |
|
|
this.DataContext = this; |
|
|
this.DataContext = this; |
|
|
|
|
|
|
|
|
this.PurchaseAccountList = purchaseAccountList; |
|
|
this.PurchaseAccountList = purchaseAccountList; |
|
|
this.OrderId = orderId; |
|
|
this.OrderId = orderId; |
|
|
OrderDropShippingList = new ObservableCollection<OrderDropShipping>(); |
|
|
OrderDropShippingList = new ObservableCollection<OrderDropShipping>(); |
|
@ -46,11 +75,22 @@ namespace BBWY.Client.Views.Order |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.RelationPurchaseOrderSkuList = relationPurchaseOrderSkuList; |
|
|
RelationPurchaseOrderSkuList = relationPurchaseOrderSkuList; |
|
|
|
|
|
ChooseRelationPurchaseOrderSkuList = new ObservableCollection<RelationPurchaseOrderSku>(); |
|
|
|
|
|
RefreshChooseRelationPurchaseOrderSkuList(); |
|
|
|
|
|
|
|
|
foreach (var sku in RelationPurchaseOrderSkuList) |
|
|
foreach (var sku in RelationPurchaseOrderSkuList) |
|
|
sku.OnSkuAmountChanged = OnSkuAmountChanged; |
|
|
sku.OnSkuAmountChanged = OnSkuAmountChanged; |
|
|
|
|
|
|
|
|
OnPurchaseAmountChanged(); |
|
|
OnPurchaseAmountChanged(); |
|
|
|
|
|
|
|
|
|
|
|
AddOrderDropShippingCommand = new RelayCommand(() => OrderDropShippingList.Add(new OrderDropShipping() |
|
|
|
|
|
{ |
|
|
|
|
|
BuyerAccount = PurchaseAccountList.FirstOrDefault()?.AccountName, |
|
|
|
|
|
OnPurchaseAmountChanged = OnPurchaseAmountChanged |
|
|
|
|
|
})); |
|
|
|
|
|
AddRelationPurchaseOrderSkuCommand = new RelayCommand<OrderDropShipping>(AddRelationPurchaseOrderSku); |
|
|
|
|
|
CloseShowChooseSkuPanelCommand = new RelayCommand(() => IsShowChooseSkuPanel = false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void OnSkuAmountChanged() |
|
|
private void OnSkuAmountChanged() |
|
@ -64,8 +104,23 @@ namespace BBWY.Client.Views.Order |
|
|
TotalCost = OrderDropShippingList.Sum(ods => ods.PurchaseAmount); |
|
|
TotalCost = OrderDropShippingList.Sum(ods => ods.PurchaseAmount); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void btn_Save_Click(object sender, System.Windows.RoutedEventArgs e) |
|
|
private void btn_Save_Click(object sender, RoutedEventArgs e) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (OrderDropShippingList.Count() == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
MessageBox.Show("关联订单信息不全", "提示"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (OrderDropShippingList.Any(ods => ods.RelationPurchaseOrderSkuList.Count() == 0 || |
|
|
|
|
|
string.IsNullOrEmpty(ods.PurchaseOrderId) || |
|
|
|
|
|
string.IsNullOrEmpty(ods.SellerAccount) || |
|
|
|
|
|
string.IsNullOrEmpty(ods.BuyerAccount) || |
|
|
|
|
|
ods.PurchaseAmount == 0)) |
|
|
|
|
|
{ |
|
|
|
|
|
MessageBox.Show("关联订单信息不全", "提示"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
//if (string.IsNullOrEmpty(OrderDropShipping.PurchaseOrderId) ||
|
|
|
//if (string.IsNullOrEmpty(OrderDropShipping.PurchaseOrderId) ||
|
|
|
// string.IsNullOrEmpty(OrderDropShipping.SellerAccount) ||
|
|
|
// string.IsNullOrEmpty(OrderDropShipping.SellerAccount) ||
|
|
|
// string.IsNullOrEmpty(OrderDropShipping.BuyerAccount) ||
|
|
|
// string.IsNullOrEmpty(OrderDropShipping.BuyerAccount) ||
|
|
@ -77,5 +132,31 @@ namespace BBWY.Client.Views.Order |
|
|
this.DialogResult = true; |
|
|
this.DialogResult = true; |
|
|
this.Close(); |
|
|
this.Close(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void AddRelationPurchaseOrderSku(OrderDropShipping ods) |
|
|
|
|
|
{ |
|
|
|
|
|
currentOds = ods; |
|
|
|
|
|
IsShowChooseSkuPanel = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void OnShowChooseSkuPanelClose() |
|
|
|
|
|
{ |
|
|
|
|
|
var chooseSkuList = ChooseRelationPurchaseOrderSkuList.Where(rsku => rsku.IsSelected); |
|
|
|
|
|
foreach (var chooseSku in chooseSkuList) |
|
|
|
|
|
{ |
|
|
|
|
|
chooseSku.OrderDropShippingId = currentOds.Id; |
|
|
|
|
|
currentOds.RelationPurchaseOrderSkuList.Add(chooseSku); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RefreshChooseRelationPurchaseOrderSkuList(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void RefreshChooseRelationPurchaseOrderSkuList() |
|
|
|
|
|
{ |
|
|
|
|
|
ChooseRelationPurchaseOrderSkuList.Clear(); |
|
|
|
|
|
var noChooseList = RelationPurchaseOrderSkuList.Where(rsku => rsku.OrderDropShippingId == null); |
|
|
|
|
|
foreach (var noChooseSku in noChooseList) |
|
|
|
|
|
ChooseRelationPurchaseOrderSkuList.Add(noChooseSku); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|