diff --git a/BBWY.Client/APIServices/BatchPurchaseService.cs b/BBWY.Client/APIServices/BatchPurchaseService.cs new file mode 100644 index 00000000..d24e2351 --- /dev/null +++ b/BBWY.Client/APIServices/BatchPurchaseService.cs @@ -0,0 +1,139 @@ +using BBWY.Client.Models; +using BBWY.Common.Http; +using BBWY.Common.Models; +using System; +using System.Collections.Generic; +using System.Net.Http; + +namespace BBWY.Client.APIServices +{ + public class BatchPurchaseService : BaseApiService, IDenpendency + { + public BatchPurchaseService(RestApiService restApiService, GlobalContext globalContext) : base(restApiService, globalContext) + { + } + + /// + /// 获取包含对应平台采购方案的sku列表 + /// + /// + /// + /// + public ApiResponse> GetProductSkuAndSchemeList(string sku, string spu) + { + return SendRequest>(globalContext.BBYWApiHost, "api/BatchPurchase/GetProductSkuAndSchemeList", new + { + globalContext.User.Shop.Platform, + globalContext.User.Shop.AppKey, + globalContext.User.Shop.AppSecret, + globalContext.User.Shop.AppToken, + globalContext.User.Shop.ShopId, + sku, + spu + }, null, HttpMethod.Post); + } + + public ApiResponse PreviewOrder(IList productSkuWithSchemeList, + Consignee consignee, + PurchaseOrderMode purchaseOrderMode, + IList purchaseAccountList) + { + var productParamList = new List(); + foreach (var productSkuWithScheme in productSkuWithSchemeList) + { + foreach (var purchaseSchemeProductSku in productSkuWithScheme.PurchaseSchemeProductSkuList) + { + productParamList.Add(new + { + purchaseSchemeProductSku.PurchaseProductId, + purchaseSchemeProductSku.PurchaseSkuId, + PurchaseSpecId = purchaseSchemeProductSku.PurchaseSkuSpecId, + Quantity = purchaseSchemeProductSku.ItemTotal, + productSkuWithScheme.PurchaserId, + productSkuWithScheme.PurchaserName, + productSkuWithScheme.PurchasePlatform, + BelongSkuId = productSkuWithScheme.SkuId + }); + } + } + + return SendRequest(globalContext.BBYWApiHost, "api/BatchPurchase/PreviewOrder", new + { + consignee, + purchaseOrderMode, + purchaseAccountList, + productParamList + }, null, HttpMethod.Post); + } + + public ApiResponse CreateOrder(IList productSkuWithSchemeList, + Consignee consignee, + PurchaseOrderMode purchaseOrderMode, + IList purchaseAccountList, + string extensions, + string remark) + { + var productParamList = new List(); + foreach (var productSkuWithScheme in productSkuWithSchemeList) + { + foreach (var purchaseSchemeProductSku in productSkuWithScheme.PurchaseSchemeProductSkuList) + { + productParamList.Add(new + { + purchaseSchemeProductSku.PurchaseProductId, + purchaseSchemeProductSku.PurchaseSkuId, + PurchaseSpecId = purchaseSchemeProductSku.PurchaseSkuSpecId, + Quantity = purchaseSchemeProductSku.ItemTotal, + productSkuWithScheme.PurchaserId, + productSkuWithScheme.PurchaserName, + productSkuWithScheme.PurchasePlatform, + BelongSkuId = productSkuWithScheme.SkuId, + BelongProductId = productSkuWithScheme.ProductId, + BelongPrice = productSkuWithScheme.Price, + BelongSkuTitle = productSkuWithScheme.Title, + BelongLogo = productSkuWithScheme.Logo, + BelongQuantity = productSkuWithScheme.Quantity, + BelongPurchaseSchemeId = productSkuWithScheme.PurchaseSchemeId + }); + } + } + + return SendRequest(globalContext.BBYWApiHost, "api/BatchPurchase/BatchCreateOrder", new + { + consignee, + purchaseOrderMode, + purchaseAccountList, + productParamList, + extensions, + remark, + globalContext.User.Shop.ShopId, + globalContext.User.Shop.ShopName + }, null, HttpMethod.Post); + } + + public ApiResponse GetPurchaseOrderList(string spu, + string sku, + string purchaserName, + string purchaseOrderId, + int pageIndex, + int pageSize, + DateTime startDate, + DateTime endDate, + PurchaseOrderState? purchaseOrderState) + { + return SendRequest(globalContext.BBYWApiHost, "api/BatchPurchase/GetPurchaseOrderList", new + { + sku, + spu, + purchaseOrderId, + globalContext.User.Shop.ShopId, + purchaserName, + purchaseOrderState, + pageIndex, + pageSize, + startDate, + endDate + }, null, HttpMethod.Post); + } + } +} diff --git a/BBWY.Client/App.xaml.cs b/BBWY.Client/App.xaml.cs index 01b9ec17..ed5c0cd0 100644 --- a/BBWY.Client/App.xaml.cs +++ b/BBWY.Client/App.xaml.cs @@ -120,6 +120,8 @@ namespace BBWY.Client serviceCollection.AddTransient<_1688PreviewPurchaseViewModel>(); serviceCollection.AddTransient(); + serviceCollection.AddTransient(); + serviceCollection.AddTransient(); #region 注册拳探SDK相关类 serviceCollection.AddSingleton(); diff --git a/BBWY.Client/Models/APIModel/Response/BatchPurchase/BatchCreareOrderResponse.cs b/BBWY.Client/Models/APIModel/Response/BatchPurchase/BatchCreareOrderResponse.cs new file mode 100644 index 00000000..49eed28c --- /dev/null +++ b/BBWY.Client/Models/APIModel/Response/BatchPurchase/BatchCreareOrderResponse.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; + +namespace BBWY.Client.Models +{ + public class BatchCreareOrderResponse + { + /// + /// 已经成功下单的SkuId集合 + /// + public IList SuccessSkuIdList { get; set; } + + public IList FailSkuList { get; set; } + } + + public class BatchCreareOrderFailDetail + { + public string SkuId { get; set; } + + public string ErrorMsg { get; set; } + } +} diff --git a/BBWY.Client/Models/APIModel/Response/BatchPurchase/ProductSkuWithSchemeResponse.cs b/BBWY.Client/Models/APIModel/Response/BatchPurchase/ProductSkuWithSchemeResponse.cs new file mode 100644 index 00000000..f4e0efbc --- /dev/null +++ b/BBWY.Client/Models/APIModel/Response/BatchPurchase/ProductSkuWithSchemeResponse.cs @@ -0,0 +1,40 @@ +using System; + +namespace BBWY.Client.Models +{ + /// + /// 包含采购方案的Sku商品信息 + /// + public class ProductSkuWithSchemeResponse + { + public string Id { get; set; } + + public string ProductId { get; set; } + + public string SkuId { get; set; } + + public decimal Price { get; set; } + + /// + /// Sku标题 + /// + public string Title { get; set; } + + public string Logo { get; set; } + + /// + /// 京东Sku状态【1:上架 2:下架 4:删除】 + /// + public int State { get; set; } + + public DateTime? CreateTime { get; set; } + + public long PurchaseSchemeId { get; set; } + + public string PurchaserId { get; set; } + + public string PurchaserName { get; set; } + + public Platform? PurchasePlatform { get; set; } + } +} diff --git a/BBWY.Client/Models/APIModel/Response/BatchPurchase/PurchaseOrderSkuResponse.cs b/BBWY.Client/Models/APIModel/Response/BatchPurchase/PurchaseOrderSkuResponse.cs new file mode 100644 index 00000000..52486999 --- /dev/null +++ b/BBWY.Client/Models/APIModel/Response/BatchPurchase/PurchaseOrderSkuResponse.cs @@ -0,0 +1,99 @@ +using System; + +namespace BBWY.Client.Models +{ + public class PurchaseOrderSkuResponse + { + public long Id { get; set; } + + /// + /// 打包耗材费 + /// + public decimal? ConsumableAmount { get; set; } = 0.00M; + + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + + /// + /// 头程运费 + /// + public decimal? FirstFreight { get; set; } = 0.00M; + + + /// + /// 入仓费 + /// + public decimal? InStorageAmount { get; set; } = 0.00M; + + /// + /// Sku Logo + /// + + public string Logo { get; set; } + + /// + /// 单价 + /// + public decimal? Price { get; set; } = 0.00M; + + /// + /// 采购货款 + /// + public decimal? ProductAmount { get; set; } + + public string ProductId { get; set; } + + /// + /// 采购金额(采购货款+采购运费) + /// + public decimal? PurchaseAmount { get; set; } + + /// + /// 采购运费 + /// + public decimal? PurchaseFreight { get; set; } + + /// + /// 采购单Id + /// + public string PurchaseOrderId { get; set; } + + /// + /// 采购方案Id + /// + + public long? PurchaseSchemeId { get; set; } + + /// + /// 采购SkuId串 + /// + public string PurchaseSkuIds { get; set; } + + /// + /// 质检费 + /// + public decimal? QualityInspectionAmount { get; set; } = 0.00M; + + /// + /// 采购数量 + /// + + public int? Quantity { get; set; } + + /// + /// 店铺Id + /// + + public long? ShopId { get; set; } + + public string SkuId { get; set; } + + /// + /// Sku标题 + /// + + public string SkuTitle { get; set; } + } +} diff --git a/BBWY.Client/Models/APIModel/Response/BatchPurchase/PurchaseOrderV2ListResponse.cs b/BBWY.Client/Models/APIModel/Response/BatchPurchase/PurchaseOrderV2ListResponse.cs new file mode 100644 index 00000000..40ecd04c --- /dev/null +++ b/BBWY.Client/Models/APIModel/Response/BatchPurchase/PurchaseOrderV2ListResponse.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace BBWY.Client.Models +{ + public class PurchaseOrderV2ListResponse + { + public long Count { get; set; } + + public IList ItemList { get; set; } + } +} diff --git a/BBWY.Client/Models/APIModel/Response/BatchPurchase/PurchaseOrderV2Response.cs b/BBWY.Client/Models/APIModel/Response/BatchPurchase/PurchaseOrderV2Response.cs new file mode 100644 index 00000000..328ff1fa --- /dev/null +++ b/BBWY.Client/Models/APIModel/Response/BatchPurchase/PurchaseOrderV2Response.cs @@ -0,0 +1,177 @@ +using System; +using System.Collections.Generic; + +namespace BBWY.Client.Models +{ + public class PurchaseOrderV2Response + { + /// + /// 采购单号 + /// + public string Id { get; set; } + + /// + /// 完成时间 + /// + public DateTime? CompletionTime { get; set; } + + /// + /// 收货详细地址 + /// + + public string ConsigneeAddress { get; set; } + + /// + /// 收货市 + /// + public string ConsigneeCity { get; set; } + + /// + /// 收货联系人名称 + /// + public string ConsigneeContactName { get; set; } + + /// + /// 收货区 + /// + public string ConsigneeCounty { get; set; } + + /// + /// 收货联系人电话 + /// + public string ConsigneeMobile { get; set; } + + /// + /// 收货省 + /// + public string ConsigneeProvince { get; set; } + + /// + /// 收货镇 + /// + public string ConsigneeTown { get; set; } + + /// + /// 打包耗材费 + /// + public decimal? ConsumableAmount { get; set; } = 0.00M; + + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + + /// + /// 快递公司 + /// + public string ExpressName { get; set; } + + /// + /// 头程运费 + /// + public decimal? FirstFreight { get; set; } = 0.00M; + + /// + /// 入仓费 + /// + public decimal? InStorageAmount { get; set; } = 0.00M; + + /// + /// 是否转入库存 + /// + + public bool? IsConvertToStock { get; set; } = false; + + /// + /// 是否订阅快递100 + /// + + public bool? IsSubscribeKuaiDi100 { get; set; } = false; + + /// + /// 采购单状态(待付款=0,待发货=1,待收货=2,待质检=3,待打包=4,待结算=5,已完成=6) + /// + public PurchaseOrderState? OrderState { get; set; } + + /// + /// 支付时间 + /// + public DateTime? PayTime { get; set; } + + /// + /// 采购货款 + /// + public decimal? ProductAmount { get; set; } = 0.00M; + + /// + /// 采购账号Id + /// + + public long? PurchaseAccountId { get; set; } + + /// + /// 采购金额(采购货款+采购运费) + /// + public decimal? PurchaseAmount { get; set; } = 0.00M; + + /// + /// 采购运费 + /// + public decimal? PurchaseFreight { get; set; } = 0.00M; + + /// + /// 采购平台 + /// + public Platform? PurchasePlatform { get; set; } + + /// + /// 商家Id + /// + public string PurchaserId { get; set; } + + /// + /// 商家名称 + /// + public string PurchaserName { get; set; } + + /// + /// 质检费 + /// + public decimal? QualityInspectionAmount { get; set; } = 0.00M; + + /// + /// 备注信息 + /// + + public string Remark { get; set; } + + /// + /// 店铺Id + /// + + public long ShopId { get; set; } + + /// + /// 签收时间 + /// + public DateTime? SignTime { get; set; } + + /// + /// 快递单号 + /// + public string WaybillNo { get; set; } + + /// + /// 采购方式(线上=0, 线下=1) + /// + public PurchaseMethod PurchaseMethod { get; set; } + + /// + /// 采购单模式 批发 = 0,代发 = 1 + /// + public PurchaseOrderMode PurchaseOrderMode { get; set; } + + + public IList ItemList { get; set; } + } +} diff --git a/BBWY.Client/Models/BatchPurchase/ProductSkuWithScheme.cs b/BBWY.Client/Models/BatchPurchase/ProductSkuWithScheme.cs new file mode 100644 index 00000000..bef28ddd --- /dev/null +++ b/BBWY.Client/Models/BatchPurchase/ProductSkuWithScheme.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace BBWY.Client.Models +{ + public class ProductSkuWithScheme : NotifyObject + { + private int quantity; + private bool isSelected; + public string Id { get; set; } + + public string SkuId { get; set; } + + public string ProductId { get; set; } + + public decimal Price { get; set; } + + /// + /// Sku标题 + /// + public string Title { get; set; } + + public string Logo { get; set; } + + /// + /// 京东Sku状态【1:上架 2:下架 4:删除】 + /// + public int State { get; set; } + + public DateTime? CreateTime { get; set; } + + public long PurchaseSchemeId { get; set; } + + public string PurchaserId { get; set; } + + public string PurchaserName { get; set; } + + public Platform? PurchasePlatform { get; set; } + + public int Quantity { get => quantity; set { if (Set(ref quantity, value)) OnQuantityChanged(); } } + + public IList PurchaseSchemeProductSkuList { get; set; } + + public bool IsSelected + { + get => isSelected; set { if (Set(ref isSelected, value)) OnSelectChanged(); } + } + + public ProductSkuWithScheme() + { + PurchaseSchemeProductSkuList = new ObservableCollection(); + } + + private void OnSelectChanged() + { + if (IsSelected && Quantity <= 0) + Quantity = 1; + else if (!IsSelected) + Quantity = 0; + } + + private void OnQuantityChanged() + { + IsSelected = Quantity > 0; + } + } +} diff --git a/BBWY.Client/Models/BatchPurchase/PurchaseOrderSku.cs b/BBWY.Client/Models/BatchPurchase/PurchaseOrderSku.cs new file mode 100644 index 00000000..b1abc4d8 --- /dev/null +++ b/BBWY.Client/Models/BatchPurchase/PurchaseOrderSku.cs @@ -0,0 +1,6 @@ +namespace BBWY.Client.Models +{ + public class PurchaseOrderSku : PurchaseOrderSkuResponse + { + } +} diff --git a/BBWY.Client/Models/BatchPurchase/PurchaseOrderV2.cs b/BBWY.Client/Models/BatchPurchase/PurchaseOrderV2.cs new file mode 100644 index 00000000..2a0e53fc --- /dev/null +++ b/BBWY.Client/Models/BatchPurchase/PurchaseOrderV2.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace BBWY.Client.Models +{ + public class PurchaseOrderV2 : PurchaseOrderV2Response + { + + public new IList ItemList { get; set; } + } +} diff --git a/BBWY.Client/Models/Enums.cs b/BBWY.Client/Models/Enums.cs index 50640ff2..fbe5ae82 100644 --- a/BBWY.Client/Models/Enums.cs +++ b/BBWY.Client/Models/Enums.cs @@ -371,4 +371,11 @@ 无 = 0, 非新 = 1, 新 = 2 } + /// + /// 采购单状态 待付款 = 0, 待发货 = 1, 待收货 = 2, 待质检 = 3, 待打包 = 4, 待结算 = 5, 已完成 = 6, 已取消= 7 + /// + public enum PurchaseOrderState + { + 待付款 = 0, 待发货 = 1, 待收货 = 2, 待质检 = 3, 待打包 = 4, 待结算 = 5, 已完成 = 6, 已取消 = 7 + } } diff --git a/BBWY.Client/Models/MappingProfile.cs b/BBWY.Client/Models/MappingProfile.cs index 8ff89753..adfde434 100644 --- a/BBWY.Client/Models/MappingProfile.cs +++ b/BBWY.Client/Models/MappingProfile.cs @@ -31,6 +31,9 @@ namespace BBWY.Client.Models CreateMap(); CreateMap(); CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); } } } diff --git a/BBWY.Client/Models/Product/PurchaseSchemeProductSku.cs b/BBWY.Client/Models/Product/PurchaseSchemeProductSku.cs index 20f5c206..6857fc82 100644 --- a/BBWY.Client/Models/Product/PurchaseSchemeProductSku.cs +++ b/BBWY.Client/Models/Product/PurchaseSchemeProductSku.cs @@ -7,6 +7,10 @@ namespace BBWY.Client.Models /// public class PurchaseSchemeProductSku : NotifyObject { + public PurchaseSchemeProductSku() + { + QuantityRatio = 1; + } /// /// 采购商品的SKU和采购方案的关系Id /// @@ -51,7 +55,16 @@ namespace BBWY.Client.Models private int itemTotal; private decimal skuAmount; + private int quantityRatio; public Action OnItemTotalChanged { get; set; } + + /// + /// 组成一件sku所需的数量 + /// + public int QuantityRatio + { + get => quantityRatio; set { Set(ref quantityRatio, value); } + } } } diff --git a/BBWY.Client/Models/Product/Purchaser.cs b/BBWY.Client/Models/Product/Purchaser.cs index 21ab7466..5f766231 100644 --- a/BBWY.Client/Models/Product/Purchaser.cs +++ b/BBWY.Client/Models/Product/Purchaser.cs @@ -1,4 +1,8 @@ -namespace BBWY.Client.Models +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace BBWY.Client.Models { /// /// 采购商 @@ -22,4 +26,22 @@ public Platform Platform { get; set; } } + + public class PurchaserComparer : IEqualityComparer + { + public bool Equals([AllowNull] Purchaser x, [AllowNull] Purchaser y) + { + if (Object.ReferenceEquals(x, y)) return true; + + if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null)) + return false; + + return x?.Id == y?.Id; + } + + public int GetHashCode([DisallowNull] Purchaser obj) + { + return base.GetHashCode(); + } + } } diff --git a/BBWY.Client/ViewModels/BaseVM.cs b/BBWY.Client/ViewModels/BaseVM.cs index a657101c..28a6ae70 100644 --- a/BBWY.Client/ViewModels/BaseVM.cs +++ b/BBWY.Client/ViewModels/BaseVM.cs @@ -2,6 +2,8 @@ using GalaSoft.MvvmLight.Command; using System.Windows.Input; using System; +using System.Windows; + namespace BBWY.Client.ViewModels { public class BaseVM : ViewModelBase @@ -12,11 +14,27 @@ namespace BBWY.Client.ViewModels public ICommand UnloadCommand { get; set; } + public ICommand CopyTextCommand { get; set; } + public BaseVM() { VMId = Guid.NewGuid(); LoadCommand = new RelayCommand(Load); UnloadCommand = new RelayCommand(Unload); + + CopyTextCommand = new RelayCommand(s => + { + try + { + Clipboard.SetText(s); + } + catch (Exception ex) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(ex); + Console.ResetColor(); + } + }); } public virtual void Refresh() diff --git a/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseAddProductSkuViewModel.cs b/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseAddProductSkuViewModel.cs new file mode 100644 index 00000000..77ed9a55 --- /dev/null +++ b/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseAddProductSkuViewModel.cs @@ -0,0 +1,207 @@ +using BBWY.Client.APIServices; +using BBWY.Client.Models; +using GalaSoft.MvvmLight.Command; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; +using BBWY.Common.Extensions; + +namespace BBWY.Client.ViewModels +{ + public class BatchPurchaseAddProductSkuViewModel : BaseVM + { + private BatchPurchaseService batchPurchaseService; + private bool isLoading; + private string sku; + private string spu; + private Purchaser selectedPurchaser; + private Purchaser defaultPurchaser; + + private KVModel selectedPurchasePlatform; + private KVModel defaultPurchasePlatform; + + private bool allSelected; + + public ICommand SearchCommand { get; set; } + public ICommand FilterCommand { get; set; } + public ICommand SaveCommand { get; set; } + + public ICommand AddQuantityCommand { get; set; } + + public ICommand SubtractQuantityCommand { get; set; } + + public string Sku { get => sku; set { Set(ref sku, value); } } + public string Spu { get => spu; set { Set(ref spu, value); } } + + public IList PurchaserList { get; set; } + public IList PurchasePlatformList { get; set; } + public Purchaser SelectedPurchaser + { + get => selectedPurchaser; set { Set(ref selectedPurchaser, value); } + } + + public KVModel SelectedPurchasePlatform + { + get => selectedPurchasePlatform; set { Set(ref selectedPurchasePlatform, value); } + } + + public IList SourceList { get; set; } + public IList 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) + { + this.batchPurchaseService = batchPurchaseService; + defaultPurchaser = new Purchaser() { Id = "-1", Name = "全部" }; + defaultPurchasePlatform = new KVModel() { Key = "-1", Value = "全部" }; + + PurchaserList = new ObservableCollection() { defaultPurchaser }; + PurchasePlatformList = new ObservableCollection() + { + defaultPurchasePlatform, + new KVModel(){ Key=((int)Platform.拳探).ToString(),Value = Platform.拳探.ToString() }, + new KVModel(){ Key=((int)Platform.阿里巴巴).ToString(),Value = Platform.阿里巴巴.ToString() } + }; + + SourceList = new List(); + FilterList = new ObservableCollection(); + SearchCommand = new RelayCommand(Search); + FilterCommand = new RelayCommand(Filter); + SaveCommand = new RelayCommand(Save); + AddQuantityCommand = new RelayCommand(AddQuantity); + SubtractQuantityCommand = new RelayCommand(SubtractQuantity); + 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>(); + + #region 提取采购商 + var purchaserList = list.Where(item => item.PurchaseSchemeId != 0) + .Select(item => new Purchaser() { Id = item.PurchaserId, Name = item.PurchaserName, 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 Filter() + { + FilterList.Clear(); + if (SourceList.Count() == 0) + return; + var resultList = new List(); + 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 Save() + { + var selectedList = FilterList.Where(item => item.IsSelected).ToList(); + if (selectedList == null || selectedList.Count() == 0) + { + MessageBox.Show("至少选择一个商品"); + return; + } + GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(selectedList, "BatchPurchaseAddProductSkuSave"); + } + + private void OnAllSelectedChanged() + { + foreach (var item in FilterList) + { + if (item.PurchaseSchemeId == 0) + continue; + item.IsSelected = AllSelected; + } + } + + private void AddQuantity(ProductSkuWithScheme item) + { + item.Quantity++; + } + + private void SubtractQuantity(ProductSkuWithScheme item) + { + if (item.Quantity > 0) + item.Quantity--; + } + } +} diff --git a/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseCreateNewOrderViewModel.cs b/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseCreateNewOrderViewModel.cs new file mode 100644 index 00000000..7bb5611c --- /dev/null +++ b/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseCreateNewOrderViewModel.cs @@ -0,0 +1,369 @@ +using BBWY.Client.APIServices; +using BBWY.Client.Models; +using BBWY.Client.Views.BatchPurchase; +using BBWY.Common.Trigger; +using GalaSoft.MvvmLight.Command; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; + +namespace BBWY.Client.ViewModels +{ + public class BatchPurchaseCreateNewOrderViewModel : BaseVM + { + private GlobalContext globalContext; + private PurchaseProductAPIService purchaseProductAPIService; + private PurchaseService purchaseService; + private BatchPurchaseService batchPurchaseService; + private DelayTrigger delayTrigger; + + private bool isLoading; + private decimal productAmount; + private decimal freightAmount; + private decimal totalAmount; + private string contactName; + private string address; + private string mobile; + private string province; + private string city; + private string county; + private string town; + private string purchaseRemark; + private PurchaseOrderMode purchaseOrderMode = PurchaseOrderMode.批发; + + //private string tradeMode; + private string extensions; + + public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } } + + public decimal ProductAmount { get => productAmount; set { Set(ref productAmount, value); } } + public decimal FreightAmount { get => freightAmount; set { Set(ref freightAmount, value); } } + public decimal TotalAmount { get => totalAmount; set { Set(ref totalAmount, value); } } + public string ContactName { get => contactName; set { Set(ref contactName, value); } } + public string Address { get => address; set { Set(ref address, value); } } + public string Mobile { get => mobile; set { Set(ref mobile, value); } } + public string Province { get => province; set { Set(ref province, value); } } + public string City { get => city; set { Set(ref city, value); } } + public string County { get => county; set { Set(ref county, value); } } + public string Town { get => town; set { Set(ref town, value); } } + public string PurchaseRemark { get => purchaseRemark; set { Set(ref purchaseRemark, value); } } + + public PurchaseOrderMode PurchaseOrderMode + { + get => purchaseOrderMode; set + { + if (Set(ref purchaseOrderMode, value)) + OnDelayTriggerExecute(Guid.NewGuid().ToString()); + } + } + public IList ProductSkuWithSchemeList { get; set; } + + + public ICommand FastCreateOrderCommand { get; set; } + public ICommand PreviewOrderCommand { get; set; } + public ICommand AddProductSkuCommand { get; set; } + public ICommand DeleteProductSkuWithSchemeCommand { get; set; } + + public ICommand EditQuantityRatioCommand { get; set; } + + public ICommand AddQuantityCommand { get; set; } + + public ICommand SubtractQuantityCommand { get; set; } + + public BatchPurchaseCreateNewOrderViewModel(PurchaseProductAPIService purchaseProductAPIService, + PurchaseService purchaseService, + GlobalContext globalContext, + BatchPurchaseService batchPurchaseService) + { + this.globalContext = globalContext; + this.purchaseProductAPIService = purchaseProductAPIService; + this.purchaseService = purchaseService; + this.batchPurchaseService = batchPurchaseService; + ProductSkuWithSchemeList = new ObservableCollection(); + + FastCreateOrderCommand = new RelayCommand(FastCreateOrder); + PreviewOrderCommand = new RelayCommand(PreviewOrder); + AddProductSkuCommand = new RelayCommand(AddProductSku); + DeleteProductSkuWithSchemeCommand = new RelayCommand(DeleteProductSkuWithScheme); + EditQuantityRatioCommand = new RelayCommand(EditQuantityRatio); + AddQuantityCommand = new RelayCommand(AddQuantity); + SubtractQuantityCommand = new RelayCommand(SubtractQuantity); + this.delayTrigger = new DelayTrigger(); + this.delayTrigger.OnExecute = OnDelayTriggerExecute; + } + + private void OnDelayTriggerExecute(string key) + { + if (string.IsNullOrEmpty(key)) + { + IsLoading = false; + return; + } + + if (ProductSkuWithSchemeList.Count() == 0) + { + ProductAmount = 0; + FreightAmount = 0; + TotalAmount = 0; + IsLoading = false; + return; + } + + if (string.IsNullOrEmpty(ContactName) || + string.IsNullOrEmpty(Address) || + string.IsNullOrEmpty(Mobile) || + string.IsNullOrEmpty(Province) || + string.IsNullOrEmpty(City) || + string.IsNullOrEmpty(County)) + { + IsLoading = false; + MessageBox.Show("缺少完整的收货信息", "提示"); + return; + } + + IsLoading = true; + Task.Factory.StartNew(() => batchPurchaseService.PreviewOrder(ProductSkuWithSchemeList, new Consignee() + { + Address = Address, + City = City, + ContactName = ContactName, + County = County, + Mobile = Mobile, + Province = Province, + TelePhone = Mobile, + Town = Town + }, this.PurchaseOrderMode, globalContext.User.Shop.PurchaseAccountList)) + .ContinueWith(t => + { + IsLoading = false; + var r = t.Result; + if (!r.Success) + { + ProductAmount = FreightAmount = TotalAmount = 0; + //tradeMode = string.Empty; + App.Current.Dispatcher.Invoke(() => MessageBox.Show(r.Msg, "预览订单报价")); + return; + } + ProductAmount = r.Data.ProductAmount; + FreightAmount = r.Data.FreightAmount; + TotalAmount = r.Data.TotalAmount; + //tradeMode = r.Data.OrderTradeType?.Code; + extensions = r.Data.Extensions; + }); + } + + private void PreviewOrder() + { + OnDelayTriggerExecute(Guid.NewGuid().ToString()); + } + + private void FastCreateOrder() + { + if (IsLoading) + return; + if (TotalAmount == 0) + { + MessageBox.Show("总金额为0不能提交订单", "提示"); + return; + } + if (string.IsNullOrEmpty(Mobile) || + string.IsNullOrEmpty(Address) || + string.IsNullOrEmpty(City) || + string.IsNullOrEmpty(Province) || + string.IsNullOrEmpty(County) || + string.IsNullOrEmpty(Town) || + string.IsNullOrEmpty(ContactName)) + { + MessageBox.Show("收货人信息不全", "下单"); + return; + } + + IsLoading = true; + + Task.Factory.StartNew(() => batchPurchaseService.CreateOrder(ProductSkuWithSchemeList, + new Consignee() + { + Address = Address, + City = City, + ContactName = ContactName, + County = County, + Mobile = Mobile, + Province = Province, + TelePhone = Mobile, + Town = Town + }, + this.PurchaseOrderMode, + globalContext.User.Shop.PurchaseAccountList, + this.extensions, + this.PurchaseRemark)).ContinueWith(t => + { + IsLoading = false; + var response = t.Result; + if (!response.Success) + { + App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "创建采购单")); + return; + } + + if (response.Data.SuccessSkuIdList != null && response.Data.SuccessSkuIdList.Count() > 0) + { + //删除下单成功的订单 + App.Current.Dispatcher.Invoke(() => + { + for (var i = 0; i < ProductSkuWithSchemeList.Count(); i++) + { + if (response.Data.SuccessSkuIdList.Contains(ProductSkuWithSchemeList[i].SkuId)) + { + ProductSkuWithSchemeList.Remove(ProductSkuWithSchemeList[i]); + i--; + } + } + }); + } + + if (response.Data.FailSkuList != null && response.Data.FailSkuList.Count() > 0) + { + var errorBuilder = new StringBuilder(); + foreach (var error in response.Data.FailSkuList) + { + errorBuilder.AppendLine($"SkuId {error.SkuId}"); + errorBuilder.AppendLine($"错误信息 {error.ErrorMsg}"); + errorBuilder.AppendLine(); + } + App.Current.Dispatcher.Invoke(() => MessageBox.Show(errorBuilder.ToString(), "创建采购单")); + } + else + { + //关闭窗口 + App.Current.Dispatcher.Invoke(() => GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(true, "BatchCreateNewPurchaseOrderClose")); + + } + }); + } + + private void AddProductSku() + { + var addProductSkuWindow = new BatchPurchaseAddProductSku(); + if (addProductSkuWindow.ShowDialog() != true) + return; + + var newProductSkuWithSchemeList = addProductSkuWindow.SelectedProductSkuWithSchemeList; + var waitList = new List(); + foreach (var newProductSkuWithScheme in newProductSkuWithSchemeList) + { + if (ProductSkuWithSchemeList.Any(item => item.SkuId == newProductSkuWithScheme.SkuId)) + continue; + ProductSkuWithSchemeList.Add(newProductSkuWithScheme); + var ewh = new ManualResetEvent(false); + waitList.Add(ewh); + Task.Factory.StartNew(() => LoadPurchaseScheme(newProductSkuWithScheme, ewh)); + } + if (waitList.Count() == 0) + return; + IsLoading = true; + Task.Factory.StartNew(() => + { + WaitHandle.WaitAll(waitList.ToArray()); + PreviewOrder(); //预览订单 + }); + } + + private void LoadPurchaseScheme(ProductSkuWithScheme productSkuWithScheme, EventWaitHandle ewh) + { + try + { + #region 加载采购方案 + var purchaseSchemeResponse = purchaseService.GetPurchaseSchemeList(shopId: globalContext.User.Shop.ShopId, schemeId: productSkuWithScheme.PurchaseSchemeId); + if (!purchaseSchemeResponse.Success) + { + App.Current.Dispatcher.Invoke(() => MessageBox.Show($"方案Id{productSkuWithScheme.PurchaseSchemeId}\r\n{purchaseSchemeResponse.Msg}", "加载采购方案失败")); + return; + } + + var purchaseScheme = purchaseSchemeResponse.Data[0]; + #endregion + + #region 完善采购方案基本信息 + foreach (var purchaseSchemeProduct in purchaseScheme.PurchaseSchemeProductList) + { + var data = purchaseProductAPIService.GetProductInfo(productSkuWithScheme.PurchasePlatform.Value, + productSkuWithScheme.ProductId, + productSkuWithScheme.SkuId, + purchaseSchemeProduct.PurchaseProductId, + PurchaseOrderMode.批发, + PurchaseProductAPIMode.Spider); + + if (data != null && data.Value.purchaseSchemeProductSkus != null && data.Value.purchaseSchemeProductSkus.Count > 0) + { + App.Current.Dispatcher.Invoke(() => + { + foreach (var purchaseSchemeProductSku in data.Value.purchaseSchemeProductSkus) + { + if (purchaseSchemeProduct.PurchaseSchemeProductSkuList.Any(s => s.PurchaseSkuId == purchaseSchemeProductSku.PurchaseSkuId)) + { + productSkuWithScheme.PurchaseSchemeProductSkuList.Add(purchaseSchemeProductSku); + + purchaseSchemeProductSku.ItemTotal = productSkuWithScheme.Quantity; + purchaseSchemeProductSku.OnItemTotalChanged = OnItemTotalChanged; + } + } + }); + } + } + #endregion + } + catch + { + + } + finally + { + ewh.Set(); + } + } + + private void OnItemTotalChanged(int itemTotal) + { + Console.WriteLine($"OnItemTotalChanged {DateTime.Now} {itemTotal}"); + this.delayTrigger.SetKey(Guid.NewGuid().ToString()); + } + + private void DeleteProductSkuWithScheme(ProductSkuWithScheme productSkuWithScheme) + { + ProductSkuWithSchemeList.Remove(productSkuWithScheme); + this.delayTrigger.SetKey(Guid.NewGuid().ToString()); + } + + private void EditQuantityRatio(object param) + { + var paramList = (object[])param; + var skuQuantity = Convert.ToInt32(paramList[0]); + var purchaseSchemeProductSku = paramList[1] as PurchaseSchemeProductSku; + + var editWindow = new EditQuantityRatioWindow(purchaseSchemeProductSku.QuantityRatio); + if (editWindow.ShowDialog() == true) + { + var quantityRatio = editWindow.QuantityRatio; + purchaseSchemeProductSku.QuantityRatio = quantityRatio; + purchaseSchemeProductSku.ItemTotal = quantityRatio * skuQuantity; + } + } + + private void AddQuantity(PurchaseSchemeProductSku purchaseSchemeProductSku) + { + purchaseSchemeProductSku.ItemTotal++; + } + + private void SubtractQuantity(PurchaseSchemeProductSku purchaseSchemeProductSku) + { + if (purchaseSchemeProductSku.ItemTotal > 1) + purchaseSchemeProductSku.ItemTotal--; + } + } +} diff --git a/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseOrderListViewModel.cs b/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseOrderListViewModel.cs new file mode 100644 index 00000000..0839dce2 --- /dev/null +++ b/BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseOrderListViewModel.cs @@ -0,0 +1,145 @@ +using BBWY.Client.APIServices; +using BBWY.Client.Models; +using BBWY.Client.Views.BatchPurchase; +using BBWY.Common.Extensions; +using BBWY.Common.Models; +using BBWY.Controls; +using GalaSoft.MvvmLight.Command; +using HandyControl.Controls; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace BBWY.Client.ViewModels +{ + public class BatchPurchaseOrderListViewModel : BaseVM, IDenpendency + { + private BatchPurchaseService batchPurchaseService; + private GlobalContext globalContext; + private DateTime startDate; + private DateTime endDate; + private string searchPurchaseOrderId; + private string searchPurchaseName; + private string searchProductId; + private string searchSkuId; + private PurchaseOrderState? purchaseOrderState; + private int pageIndex; + private int pageSize; + private bool isLoading; + private long totalCount; + + public ICommand SearchPurchaseOrderCommand { get; set; } + public ICommand OpenCreateNewPurchaseOrderDialogCommand { get; set; } + + public ICommand SetSearchDateCommand { get; set; } + + public ICommand SetPurchaseOrderStateCommand { get; set; } + + public ICommand OnPageIndexChangedCommand { get; set; } + + + public DateTime StartDate { get => startDate; set { Set(ref startDate, value); } } + public DateTime EndDate { get => endDate; set { Set(ref endDate, value); } } + public string SearchPurchaseOrderId { get => searchPurchaseOrderId; set { Set(ref searchPurchaseOrderId, value); } } + public string SearchPurchaseName { get => searchPurchaseName; set { Set(ref searchPurchaseName, value); } } + public string SearchProductId { get => searchProductId; set { Set(ref searchProductId, value); } } + public string SearchSkuId { get => searchSkuId; set { Set(ref searchSkuId, value); } } + public PurchaseOrderState? PurchaseOrderState { get => purchaseOrderState; set { Set(ref purchaseOrderState, value); } } + public int PageIndex { get => pageIndex; set { Set(ref pageIndex, value); } } + + public int PageSize { get => pageSize; set { Set(ref pageSize, value); } } + + public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } } + + public long TotalCount { get => totalCount; set { Set(ref totalCount, value); } } + + public IList PurchaseOrderList { get; set; } + + public BatchPurchaseOrderListViewModel(GlobalContext globalContext, BatchPurchaseService batchPurchaseService) + { + this.batchPurchaseService = batchPurchaseService; + SetSearchDateCommand = new RelayCommand(SetSearchDate); + SetPurchaseOrderStateCommand = new RelayCommand(SetPurchaseOrderState); + SearchPurchaseOrderCommand = new RelayCommand(InitQueryPurchaseOrder); + OpenCreateNewPurchaseOrderDialogCommand = new RelayCommand(OpenCreateNewPurchaseOrderDialog); + OnPageIndexChangedCommand = new RelayCommand(OnPageIndexChanged); + PageSize = 10; + this.globalContext = globalContext; + EndDate = DateTime.Now.Date; + StartDate = DateTime.Now.Date.AddDays(-15); + PurchaseOrderList = new ObservableCollection(); + InitQueryPurchaseOrder(); + } + + + private void InitQueryPurchaseOrder() + { + PageIndex = 1; + Task.Factory.StartNew(() => QueryPurchaseOrder(PageIndex)); + } + + private void SetPurchaseOrderState(PurchaseOrderState? purchaseOrderState) + { + this.PurchaseOrderState = purchaseOrderState; + InitQueryPurchaseOrder(); + } + + private void SetSearchDate(int d) + { + EndDate = d == 1 ? DateTime.Now.Date.AddDays(-1) : DateTime.Now; + StartDate = DateTime.Now.Date.AddDays(d * -1); + InitQueryPurchaseOrder(); + } + + private void QueryPurchaseOrder(int pageIndex) + { + IsLoading = true; + var response = batchPurchaseService.GetPurchaseOrderList(SearchProductId, + SearchSkuId, + SearchPurchaseName, + SearchPurchaseOrderId, + pageIndex, + PageSize, + StartDate, + EndDate, + this.PurchaseOrderState); + IsLoading = false; + if (!response.Success) + { + App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "提示")); + return; + } + + TotalCount = response.Data.Count; + App.Current.Dispatcher.Invoke(() => PurchaseOrderList.Clear()); + + if (response.Data.ItemList == null || response.Data.ItemList.Count() == 0) + return; + + var list = response.Data.ItemList.Map>(); + + App.Current.Dispatcher.Invoke(() => + { + foreach (var p in list) + PurchaseOrderList.Add(p); + }); + } + + private void OpenCreateNewPurchaseOrderDialog() + { + var createWindow = new BatchCreateNewPurchaseOrder(); + if (createWindow.ShowDialog() == true) + { + InitQueryPurchaseOrder(); //刷新采购单页面 + } + } + + private void OnPageIndexChanged(PageArgs pageArgs) + { + Task.Factory.StartNew(() => QueryPurchaseOrder(pageArgs.PageIndex)); + } + } +} diff --git a/BBWY.Client/ViewModels/MainViewModel.cs b/BBWY.Client/ViewModels/MainViewModel.cs index 1a7d75d8..aa957f9d 100644 --- a/BBWY.Client/ViewModels/MainViewModel.cs +++ b/BBWY.Client/ViewModels/MainViewModel.cs @@ -164,6 +164,16 @@ namespace BBWY.Client.ViewModels } }); + MenuList.Add(new MenuModel() + { + Name = "采购管理", + ChildList = new List() + { + new MenuModel(){ Name="采购列表",Url="/Views/BatchPurchase/BatchPurchaseOrderList.xaml" } + //new MenuModel(){ Name="采购账单",Url="/Views/ServiceOrder/ServiceOrderList.xaml" } + } + }); + MenuList.Add(new MenuModel() { Name = "商品管理", @@ -376,7 +386,8 @@ namespace BBWY.Client.ViewModels vm.WareManager.Refresh(); if (vm.IsCreateWareStock) vm.WareStock.Refresh(); - + if(vm.IsCreateBatchPurchaseOrderList) + vm.BatchPurchaseOrderListVM.Refresh(); try { w2m.Close(); diff --git a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs index af24296a..28946e89 100644 --- a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs +++ b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs @@ -104,8 +104,6 @@ namespace BBWY.Client.ViewModels public ICommand ExportCommand { get; set; } - public ICommand CopyTextCommand { get; set; } - public ICommand CopyOrderWaybillCommand { get; set; } public ICommand SetSearchDateCommand { get; set; } @@ -190,20 +188,6 @@ namespace BBWY.Client.ViewModels Task.Factory.StartNew(() => LoadOrder(1)); //手动点击查询订单 }); SyncOrderCommand = new RelayCommand(SyncOrder); - CopyTextCommand = new RelayCommand(s => - { - try - { - Clipboard.SetText(s); - } - catch (Exception ex) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine(ex); - Console.ResetColor(); - } - } - ); CopyOrderWaybillCommand = new RelayCommand(o => Clipboard.SetText(o.WaybillNo)); SetSearchDateCommand = new RelayCommand(d => { diff --git a/BBWY.Client/ViewModels/ViewModelLocator.cs b/BBWY.Client/ViewModels/ViewModelLocator.cs index daf28eb1..822de160 100644 --- a/BBWY.Client/ViewModels/ViewModelLocator.cs +++ b/BBWY.Client/ViewModels/ViewModelLocator.cs @@ -16,8 +16,8 @@ namespace BBWY.Client.ViewModels public bool IsCreateWareStock { get; private set; } public bool IsCreateOrderList { get; private set; } - - + public bool IsCreateBatchPurchaseOrderList { get; private set; } + @@ -112,7 +112,7 @@ namespace BBWY.Client.ViewModels { get { - + using (var s = sp.CreateScope()) { return s.ServiceProvider.GetRequiredService(); @@ -238,5 +238,33 @@ namespace BBWY.Client.ViewModels return s.ServiceProvider.GetRequiredService(); } } + + public BatchPurchaseOrderListViewModel BatchPurchaseOrderListVM + { + get + { + IsCreateBatchPurchaseOrderList = true; + using var s = sp.CreateScope(); + return s.ServiceProvider.GetRequiredService(); + } + } + + public BatchPurchaseCreateNewOrderViewModel BatchPurchaseCreateNewOrder + { + get + { + using var s = sp.CreateScope(); + return s.ServiceProvider.GetRequiredService(); + } + } + + public BatchPurchaseAddProductSkuViewModel BatchPurchaseAddProductSku + { + get + { + using var s = sp.CreateScope(); + return s.ServiceProvider.GetRequiredService(); + } + } } } diff --git a/BBWY.Client/Views/BatchPurchase/BatchCreateNewPurchaseOrder.xaml b/BBWY.Client/Views/BatchPurchase/BatchCreateNewPurchaseOrder.xaml new file mode 100644 index 00000000..d7b0cc98 --- /dev/null +++ b/BBWY.Client/Views/BatchPurchase/BatchCreateNewPurchaseOrder.xaml @@ -0,0 +1,346 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/BatchPurchase/BatchCreateNewPurchaseOrder.xaml.cs b/BBWY.Client/Views/BatchPurchase/BatchCreateNewPurchaseOrder.xaml.cs new file mode 100644 index 00000000..9f4239b8 --- /dev/null +++ b/BBWY.Client/Views/BatchPurchase/BatchCreateNewPurchaseOrder.xaml.cs @@ -0,0 +1,32 @@ +using BBWY.Controls; +using System.Windows; + +namespace BBWY.Client.Views.BatchPurchase +{ + /// + /// BatchCreateNewPurchaseOrder.xaml 的交互逻辑 + /// + public partial class BatchCreateNewPurchaseOrder : BWindow + { + public BatchCreateNewPurchaseOrder() + { + InitializeComponent(); + this.Loaded += BatchCreateNewPurchaseOrder_Loaded; + this.Unloaded += BatchCreateNewPurchaseOrder_Unloaded; + } + + private void BatchCreateNewPurchaseOrder_Unloaded(object sender, RoutedEventArgs e) + { + GalaSoft.MvvmLight.Messaging.Messenger.Default.Unregister(this); + } + + private void BatchCreateNewPurchaseOrder_Loaded(object sender, RoutedEventArgs e) + { + GalaSoft.MvvmLight.Messaging.Messenger.Default.Register(this, "BatchCreateNewPurchaseOrderClose", (r) => + { + this.DialogResult = r; + this.Close(); + }); + } + } +} diff --git a/BBWY.Client/Views/BatchPurchase/BatchPurchaseAddProductSku.xaml b/BBWY.Client/Views/BatchPurchase/BatchPurchaseAddProductSku.xaml new file mode 100644 index 00000000..e7a0f77c --- /dev/null +++ b/BBWY.Client/Views/BatchPurchase/BatchPurchaseAddProductSku.xaml @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/BatchPurchase/BatchPurchaseAddProductSku.xaml.cs b/BBWY.Client/Views/BatchPurchase/BatchPurchaseAddProductSku.xaml.cs new file mode 100644 index 00000000..fcc3ba4f --- /dev/null +++ b/BBWY.Client/Views/BatchPurchase/BatchPurchaseAddProductSku.xaml.cs @@ -0,0 +1,37 @@ +using BBWY.Client.Models; +using BBWY.Controls; +using System.Collections.Generic; +using System.Windows; + +namespace BBWY.Client.Views.BatchPurchase +{ + /// + /// BatchPurchaseAddProductSku.xaml 的交互逻辑 + /// + public partial class BatchPurchaseAddProductSku : BWindow + { + public IList SelectedProductSkuWithSchemeList { get; private set; } + + public BatchPurchaseAddProductSku() + { + InitializeComponent(); + this.Loaded += BatchPurchaseAddProductSku_Loaded; + this.Unloaded += BatchPurchaseAddProductSku_Unloaded; + } + + private void BatchPurchaseAddProductSku_Unloaded(object sender, RoutedEventArgs e) + { + GalaSoft.MvvmLight.Messaging.Messenger.Default.Unregister(this); + } + + private void BatchPurchaseAddProductSku_Loaded(object sender, RoutedEventArgs e) + { + GalaSoft.MvvmLight.Messaging.Messenger.Default.Register>(this, "BatchPurchaseAddProductSkuSave", (list) => + { + SelectedProductSkuWithSchemeList = list; + this.DialogResult = true; + this.Close(); + }); + } + } +} diff --git a/BBWY.Client/Views/BatchPurchase/BatchPurchaseOrderList.xaml b/BBWY.Client/Views/BatchPurchase/BatchPurchaseOrderList.xaml new file mode 100644 index 00000000..c409998f --- /dev/null +++ b/BBWY.Client/Views/BatchPurchase/BatchPurchaseOrderList.xaml @@ -0,0 +1,388 @@ + + + 0 + 1 + 2 + 6 + 14 + 29 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +