20 changed files with 2623 additions and 74 deletions
@ -0,0 +1,166 @@ |
|||||
|
using BBWYB.Client.Models; |
||||
|
using BBWYB.Common.Http; |
||||
|
using BBWYB.Common.Models; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Net.Http; |
||||
|
|
||||
|
namespace BBWYB.Client.APIServices |
||||
|
{ |
||||
|
public class PurchaseOrderService : BaseApiService, IDenpendency |
||||
|
{ |
||||
|
public PurchaseOrderService(RestApiService restApiService, GlobalContext globalContext) : base(restApiService, globalContext) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public ApiResponse<object> AddPurchaseOrder(PurchaseOrder purchaseOrder) |
||||
|
{ |
||||
|
return SendRequest<object>(globalContext.BBYWApiHost, |
||||
|
"api/PurchaseOrder/AddPurchaseOrder", |
||||
|
purchaseOrder, |
||||
|
null, |
||||
|
HttpMethod.Post); |
||||
|
} |
||||
|
|
||||
|
public ApiResponse<object> EditPurchaseOrder(PurchaseOrder purchaseOrder) |
||||
|
{ |
||||
|
return SendRequest<object>(globalContext.BBYWApiHost, |
||||
|
"api/PurchaseOrder/EditPurchaseOrder", |
||||
|
purchaseOrder, |
||||
|
null, |
||||
|
HttpMethod.Put); |
||||
|
} |
||||
|
|
||||
|
public ApiResponse<IList<PurchaseOrderResponse>> GetList(IList<string> skuIdList, StorageType storageType, long shopId) |
||||
|
{ |
||||
|
return SendRequest<IList<PurchaseOrderResponse>>(globalContext.BBYWApiHost, |
||||
|
"api/PurchaseOrder/GetList", |
||||
|
new { SkuIdList = skuIdList, StorageType = storageType, ShopId = shopId }, |
||||
|
null, |
||||
|
HttpMethod.Post); |
||||
|
} |
||||
|
|
||||
|
public ApiResponse<object> DeletePurchaseOrder(long id) |
||||
|
{ |
||||
|
return SendRequest<object>(globalContext.BBYWApiHost, |
||||
|
$"api/purchaseOrder/deletePurchaseOrder/{id}", |
||||
|
null, |
||||
|
null, |
||||
|
HttpMethod.Delete); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 预览订单
|
||||
|
/// </summary>
|
||||
|
/// <param name="consignee"></param>
|
||||
|
/// <param name="purchaseSchemeProductSkuList"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public ApiResponse<PreviewOrderResponse> PreviewPurchaseOrder(Consignee consignee, IList<PurchaseSchemeProductSku> purchaseSchemeProductSkuList, Platform purchasePlatform, PurchaseAccount purchaseAccount, PurchaseOrderMode purchaseOrderMode) |
||||
|
{ |
||||
|
return SendRequest<PreviewOrderResponse>(globalContext.BBYWApiHost, "api/purchaseOrder/PreviewPurchaseOrder", new |
||||
|
{ |
||||
|
purchaseOrderMode, |
||||
|
consignee, |
||||
|
CargoParamList = purchaseSchemeProductSkuList.Select(sku => new |
||||
|
{ |
||||
|
ProductId = sku.PurchaseProductId, |
||||
|
SkuId = sku.PurchaseSkuId, |
||||
|
SpecId = sku.PurchaseSkuSpecId, |
||||
|
Quantity = sku.ItemTotal, |
||||
|
BelongSkuId = sku.SkuId |
||||
|
}), |
||||
|
Platform = purchasePlatform, |
||||
|
AppKey = purchaseAccount.AppKey, |
||||
|
AppSecret = purchaseAccount.AppSecret, |
||||
|
AppToken = purchaseAccount.AppToken, |
||||
|
SaveResponseLog = true |
||||
|
}, null, HttpMethod.Post); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建采购单
|
||||
|
/// </summary>
|
||||
|
/// <param name="consignee"></param>
|
||||
|
/// <param name="purchaseSchemeProductSkuList"></param>
|
||||
|
/// <param name="purchasePlatform"></param>
|
||||
|
/// <param name="purchaseAccount"></param>
|
||||
|
/// <param name="purchaseOrderMode"></param>
|
||||
|
/// <param name="tradeMode"></param>
|
||||
|
/// <param name="remark"></param>
|
||||
|
/// <param name="orderId"></param>
|
||||
|
/// <param name="shopId"></param>
|
||||
|
/// <param name="purchaseAccountId"></param>
|
||||
|
/// <param name="buyerAccount"></param>
|
||||
|
/// <param name="sellerAccount"></param>
|
||||
|
/// <param name="purchaserId"></param>
|
||||
|
/// <param name="platformCommissionRatio"></param>
|
||||
|
/// <param name="extensions"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public ApiResponse<object> FastCreateOrder(Consignee consignee, |
||||
|
IList<PurchaseSchemeProductSku> purchaseSchemeProductSkuList, |
||||
|
Platform purchasePlatform, |
||||
|
PurchaseAccount purchaseAccount, |
||||
|
PurchaseOrderMode purchaseOrderMode, |
||||
|
string tradeMode, |
||||
|
string remark, |
||||
|
string orderId, |
||||
|
long shopId, |
||||
|
long purchaseAccountId, |
||||
|
string buyerAccount, |
||||
|
string sellerAccount, |
||||
|
string purchaserId, |
||||
|
decimal platformCommissionRatio, |
||||
|
string extensions) |
||||
|
{ |
||||
|
return SendRequest<object>(globalContext.BBYWApiHost, "api/purchaseOrder/NewFastCreateOrder", new |
||||
|
{ |
||||
|
purchaseOrderMode, |
||||
|
consignee, |
||||
|
CargoParamList = purchaseSchemeProductSkuList.Select(sku => new |
||||
|
{ |
||||
|
ProductId = sku.PurchaseProductId, |
||||
|
SkuId = sku.PurchaseSkuId, |
||||
|
SpecId = sku.PurchaseSkuSpecId, |
||||
|
Quantity = sku.ItemTotal, |
||||
|
BelongSkuId = sku.SkuId |
||||
|
}), |
||||
|
Platform = purchasePlatform, |
||||
|
AppKey = purchaseAccount.AppKey, |
||||
|
AppSecret = purchaseAccount.AppSecret, |
||||
|
AppToken = purchaseAccount.AppToken, |
||||
|
SaveResponseLog = true, |
||||
|
tradeMode, |
||||
|
remark, |
||||
|
orderId, |
||||
|
shopId, |
||||
|
purchaseAccountId, |
||||
|
buyerAccount, |
||||
|
sellerAccount, |
||||
|
purchaserId, |
||||
|
platformCommissionRatio, |
||||
|
extensions |
||||
|
}, null, HttpMethod.Post); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 查询审核采购单
|
||||
|
/// </summary>
|
||||
|
/// <param name="shopIdList"></param>
|
||||
|
/// <param name="startDate"></param>
|
||||
|
/// <param name="endDate"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public ApiResponse<IList<AuditPurchaseOrderResponse>> GetAuditPurchaseOrderList(IList<long> shopIdList, DateTime startDate, DateTime endDate) |
||||
|
{ |
||||
|
return SendRequest<IList<AuditPurchaseOrderResponse>>(globalContext.BBYWApiHost, "Api/PurchaseOrder/GetAuditPurchaseOrderList", new |
||||
|
{ |
||||
|
startDate, |
||||
|
endDate, |
||||
|
shopIdList |
||||
|
}, null, HttpMethod.Post); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Globalization; |
||||
|
using System.Text; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Data; |
||||
|
|
||||
|
namespace BBWYB.Client.Converters |
||||
|
{ |
||||
|
public class PurchaseOrderDelBtnConverter : IMultiValueConverter |
||||
|
{ |
||||
|
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) |
||||
|
{ |
||||
|
long.TryParse(values[0]?.ToString(), out long id); |
||||
|
int.TryParse(values[1]?.ToString(), out int purchaseQuantity); |
||||
|
int.TryParse(values[2]?.ToString(), out int remainingQuantity); |
||||
|
return id == 0 || (id != 0 && purchaseQuantity != 0 && purchaseQuantity == remainingQuantity) ? Visibility.Visible : Visibility.Collapsed; |
||||
|
} |
||||
|
|
||||
|
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Globalization; |
||||
|
using System.Text; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Data; |
||||
|
|
||||
|
namespace BBWYB.Client.Converters |
||||
|
{ |
||||
|
public class PurchaseOrderEditBtnConverter : IMultiValueConverter |
||||
|
{ |
||||
|
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) |
||||
|
{ |
||||
|
bool.TryParse(values[0]?.ToString(), out bool isEdit); |
||||
|
int.TryParse(values[1]?.ToString(), out int purchaseQuantity); |
||||
|
int.TryParse(values[2]?.ToString(), out int remainingQuantity); |
||||
|
return !isEdit && |
||||
|
purchaseQuantity != 0 && |
||||
|
purchaseQuantity == remainingQuantity ? Visibility.Visible : Visibility.Collapsed; |
||||
|
} |
||||
|
|
||||
|
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
using CommunityToolkit.Mvvm.ComponentModel; |
||||
|
|
||||
|
namespace BBWYB.Client.Models |
||||
|
{ |
||||
|
public class Consignee : ObservableObject |
||||
|
{ |
||||
|
private string contactName; |
||||
|
private string address; |
||||
|
private string mobile; |
||||
|
private string telePhone; |
||||
|
private bool isDecode; |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 省
|
||||
|
/// </summary>
|
||||
|
public string Province { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 市
|
||||
|
/// </summary>
|
||||
|
public string City { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 县
|
||||
|
/// </summary>
|
||||
|
public string County { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 镇
|
||||
|
/// </summary>
|
||||
|
public string Town { get; set; } |
||||
|
public string ContactName { get => contactName; set { SetProperty(ref contactName, value); } } |
||||
|
public string Address { get => address; set { SetProperty(ref address, value); } } |
||||
|
public string Mobile { get => mobile; set { SetProperty(ref mobile, value); } } |
||||
|
public string TelePhone { get => telePhone; set { SetProperty(ref telePhone, value); } } |
||||
|
public bool IsDecode { get => isDecode; set { SetProperty(ref isDecode, value); } } |
||||
|
} |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
using BBWYB.Client.Models; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Controls; |
||||
|
|
||||
|
namespace BBWYB.Client.TemplateSelectors |
||||
|
{ |
||||
|
public class PurchaseOrderDataTemplateSelector : DataTemplateSelector |
||||
|
{ |
||||
|
public DataTemplate NormalTemplate { get; set; } |
||||
|
public DataTemplate EditTemplate { get; set; } |
||||
|
|
||||
|
public override DataTemplate SelectTemplate(object item, DependencyObject container) |
||||
|
{ |
||||
|
PurchaseOrder purchaseOrder = (PurchaseOrder)item; |
||||
|
return purchaseOrder.IsEdit ? EditTemplate : NormalTemplate; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,432 @@ |
|||||
|
using BBWYB.Client.APIServices; |
||||
|
using BBWYB.Client.Models; |
||||
|
using BBWYB.Client.Views.Ware; |
||||
|
using BBWYB.Common.Models; |
||||
|
using CommunityToolkit.Mvvm.Input; |
||||
|
using CommunityToolkit.Mvvm.Messaging; |
||||
|
using Newtonsoft.Json.Linq; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text.RegularExpressions; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Input; |
||||
|
|
||||
|
namespace BBWYB.Client.ViewModels |
||||
|
{ |
||||
|
public class BindingPurchaseProductViewModel : BaseVM, IDenpendency |
||||
|
{ |
||||
|
#region Properties
|
||||
|
private GlobalContext globalContext; |
||||
|
private PurchaseService purchaseService; |
||||
|
private PurchaseProductAPIService purchaseProductAPIService; |
||||
|
|
||||
|
private string purchaserName; |
||||
|
private bool isLoading; |
||||
|
|
||||
|
private Platform purchasePlatform; |
||||
|
|
||||
|
|
||||
|
private IDictionary<Platform, string> urlPatternDictionary; |
||||
|
|
||||
|
|
||||
|
public IList<ProductSku> ProductSkuList { get; set; } |
||||
|
|
||||
|
public string PurchaserId { get; set; } |
||||
|
public string PurchaserName { get => purchaserName; set { SetProperty(ref purchaserName, value); } } |
||||
|
public string PurchaserLocation { get; set; } |
||||
|
public bool IsLoading { get => isLoading; set { SetProperty(ref isLoading, value); } } |
||||
|
|
||||
|
public Platform PurchasePlatform { get => purchasePlatform; set { SetProperty(ref purchasePlatform, value); } } |
||||
|
|
||||
|
#endregion
|
||||
|
|
||||
|
#region ICommands
|
||||
|
public ICommand ClosingCommand { get; set; } |
||||
|
|
||||
|
public ICommand AddPurchaseProductCommand { get; set; } |
||||
|
|
||||
|
public ICommand RemovePurchaseSchemeProductCommand { get; set; } |
||||
|
|
||||
|
public ICommand GetPurchaseProductInfoCommand { get; set; } |
||||
|
|
||||
|
public ICommand ConfirmPurchaseProductCommand { get; set; } |
||||
|
|
||||
|
public ICommand EditPurchaseProductCommand { get; set; } |
||||
|
|
||||
|
public ICommand SavePurchaseSchemeCommand { get; set; } |
||||
|
|
||||
|
public ICommand SearchPurchaseSkuNameCommand { get; set; } |
||||
|
|
||||
|
public ICommand ClearPurchaseSkuNameCommand { get; set; } |
||||
|
#endregion
|
||||
|
|
||||
|
#region Methods
|
||||
|
public BindingPurchaseProductViewModel(PurchaseProductAPIService purchaseProductAPIService, PurchaseService purchaseService, GlobalContext globalContext) |
||||
|
{ |
||||
|
this.globalContext = globalContext; |
||||
|
this.purchaseService = purchaseService; |
||||
|
this.purchaseProductAPIService = purchaseProductAPIService; |
||||
|
ClosingCommand = new RelayCommand<System.ComponentModel.CancelEventArgs>(Closing); |
||||
|
AddPurchaseProductCommand = new RelayCommand<ProductSku>(AddPurchaseProduct); |
||||
|
RemovePurchaseSchemeProductCommand = new RelayCommand<PurchaseSchemeProduct>(RemovePurchaseSchemeProduct); |
||||
|
GetPurchaseProductInfoCommand = new RelayCommand<PurchaseSchemeProduct>(GetPurchaseProductInfo); |
||||
|
ConfirmPurchaseProductCommand = new RelayCommand<PurchaseSchemeProduct>(ConfirmPurchaseProduct); |
||||
|
EditPurchaseProductCommand = new RelayCommand<PurchaseSchemeProduct>(EditPurchaseProduct); |
||||
|
SavePurchaseSchemeCommand = new RelayCommand(SavePurchaseScheme); |
||||
|
SearchPurchaseSkuNameCommand = new RelayCommand<PurchaseSchemeProduct>(SearchPurchaseSkuName); |
||||
|
ClearPurchaseSkuNameCommand = new RelayCommand<PurchaseSchemeProduct>(ClearPurchaseSkuName); |
||||
|
urlPatternDictionary = new Dictionary<Platform, string>() |
||||
|
{ |
||||
|
{ Platform.阿里巴巴,@"^(https://detail.1688.com/offer/(\d+).html)[^\s]*" }, |
||||
|
//{ Platform.拳探, @"^(https://qt.qiyue666.com/goods_detail/(\d+))(\?\w*)?$" }
|
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
public void SetData(IList<ProductSku> productSkuList, string purchaserId, string purchaserName, Platform purchasePlatform) |
||||
|
{ |
||||
|
this.ProductSkuList = productSkuList; |
||||
|
//this.Product = product;
|
||||
|
this.PurchaserId = purchaserId; |
||||
|
this.PurchaserName = purchaserName; |
||||
|
this.PurchasePlatform = purchasePlatform; |
||||
|
} |
||||
|
|
||||
|
protected override void Load() |
||||
|
{ |
||||
|
if (!string.IsNullOrEmpty(PurchaserId)) |
||||
|
{ |
||||
|
IsLoading = true; |
||||
|
Task.Factory.StartNew(() => purchaseService.GetPurchaseSchemeList(ProductSkuList.Select(s => s.Id).ToList(), PurchaserId, globalContext.User.Shop.ShopId, purchasePlatform: PurchasePlatform)).ContinueWith(r => |
||||
|
{ |
||||
|
var apiResponse = r.Result; |
||||
|
if (!apiResponse.Success) |
||||
|
{ |
||||
|
App.Current.Dispatcher.BeginInvoke((Action)delegate |
||||
|
{ |
||||
|
MessageBox.Show(apiResponse.Msg, "查询采购方案"); |
||||
|
}); |
||||
|
IsLoading = false; |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
var purchaseSchemeList = apiResponse.Data; |
||||
|
|
||||
|
var waitList = new List<EventWaitHandle>(); |
||||
|
foreach (var sku in ProductSkuList) |
||||
|
{ |
||||
|
//当前SKU下当前采购商的采购方案
|
||||
|
var apiScheme = purchaseSchemeList.FirstOrDefault(s => s.SkuId == sku.Id && s.PurchaserId == PurchaserId); |
||||
|
|
||||
|
if (apiScheme == null) |
||||
|
continue; |
||||
|
|
||||
|
sku.SelectedPurchaseScheme = PurchaseScheme.Convert(apiScheme); |
||||
|
var ewh = new ManualResetEvent(false); |
||||
|
waitList.Add(ewh); |
||||
|
|
||||
|
Task.Factory.StartNew(() => |
||||
|
{ |
||||
|
foreach (var purchaseSchemeProduct in sku.SelectedPurchaseScheme.PurchaseSchemeProductList) |
||||
|
{ |
||||
|
purchaseSchemeProduct.IsEditing = false; |
||||
|
LoadPurchaseProduct(sku.SelectedPurchaseScheme.PurchasePlatform, purchaseSchemeProduct, purchaseSchemeProduct.PurchaseProductId, null, out _); |
||||
|
} |
||||
|
ewh.Set(); |
||||
|
ewh.Dispose(); |
||||
|
}); |
||||
|
} |
||||
|
WaitHandle.WaitAll(waitList.ToArray()); |
||||
|
IsLoading = false; |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public void LoadPurchaseProduct(Platform platform, PurchaseSchemeProduct purchaseSchemeProduct, string purchaseProductId, Func<string, string> checkPurchaserFunc, out string errorMsg) |
||||
|
{ |
||||
|
errorMsg = string.Empty; |
||||
|
App.Current.Dispatcher.Invoke(() => |
||||
|
{ |
||||
|
purchaseSchemeProduct.SearchSkuList.Clear(); |
||||
|
purchaseSchemeProduct.SkuList.Clear(); |
||||
|
purchaseSchemeProduct.PurchaseSchemeProductSkuList.Clear(); |
||||
|
}); |
||||
|
//skuList = LoadPurchaseProductCore(purchaseSchemeProduct.PurchaseProductId, out _, out _, out _, out _, null);
|
||||
|
var data = purchaseProductAPIService.GetProductInfo(platform, |
||||
|
purchaseSchemeProduct.ProductId, |
||||
|
purchaseSchemeProduct.SkuId, |
||||
|
purchaseProductId, |
||||
|
PurchaseOrderMode.批发, |
||||
|
PurchaseProductAPIMode.Spider); |
||||
|
|
||||
|
if (data != null) |
||||
|
{ |
||||
|
if (checkPurchaserFunc != null) |
||||
|
{ |
||||
|
errorMsg = checkPurchaserFunc(data.Value.purchaser.Id); |
||||
|
if (!string.IsNullOrEmpty(errorMsg)) |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if (data.Value.purchaseSchemeProductSkus.Count == 0) |
||||
|
{ |
||||
|
errorMsg = $"商品{purchaseSchemeProduct.PurchaseProductId}缺少sku信息"; |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
PurchaserId = data.Value.purchaser.Id; |
||||
|
PurchaserName = data.Value.purchaser.Name; |
||||
|
PurchaserLocation = data.Value.purchaser.Location; |
||||
|
|
||||
|
App.Current.Dispatcher.BeginInvoke((Action)delegate |
||||
|
{ |
||||
|
foreach (var sku in data.Value.purchaseSchemeProductSkus) |
||||
|
{ |
||||
|
purchaseSchemeProduct.SearchSkuList.Add(sku); |
||||
|
purchaseSchemeProduct.SkuList.Add(sku); |
||||
|
if (purchaseSchemeProduct.SelectedSkuIdList.Any(s => s == sku.PurchaseSkuId)) |
||||
|
{ |
||||
|
sku.IsSelected = true; |
||||
|
purchaseSchemeProduct.PurchaseSchemeProductSkuList.Add(sku); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void AddPurchaseProduct(ProductSku productSku) |
||||
|
{ |
||||
|
if (productSku.PurchaseSchemeList.Count > 4) |
||||
|
{ |
||||
|
MessageBox.Show("该sku的采购方案已达上限(5)"); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if (productSku.SelectedPurchaseScheme == null) |
||||
|
{ |
||||
|
productSku.SelectedPurchaseScheme = new PurchaseScheme() |
||||
|
{ |
||||
|
ProductId = productSku.ProductId, |
||||
|
SkuId = productSku.Id, |
||||
|
PurchasePlatform = PurchasePlatform |
||||
|
}; |
||||
|
} |
||||
|
else if (productSku.SelectedPurchaseScheme.PurchaseSchemeProductList.Count >= 4) |
||||
|
{ |
||||
|
MessageBox.Show("该采购方案的商品数量已达上限(5)"); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
productSku.SelectedPurchaseScheme.PurchaseSchemeProductList.Add(new PurchaseSchemeProduct() |
||||
|
{ |
||||
|
Id = DateTime.Now.ToFileTime(), |
||||
|
IsEditing = true, |
||||
|
ProductId = productSku.ProductId, |
||||
|
SkuId = productSku.Id |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void RemovePurchaseSchemeProduct(PurchaseSchemeProduct purchaseSchemeProduct) |
||||
|
{ |
||||
|
var productSku = ProductSkuList.FirstOrDefault(sku => sku.Id == purchaseSchemeProduct.SkuId); |
||||
|
productSku.SelectedPurchaseScheme.PurchaseSchemeProductList.Remove(purchaseSchemeProduct); |
||||
|
if (!ProductSkuList.Any(s => s.SelectedPurchaseScheme != null && s.SelectedPurchaseScheme.PurchaseSchemeProductList.Count > 0)) |
||||
|
PurchaserId = string.Empty; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 查询
|
||||
|
/// </summary>
|
||||
|
/// <param name="purchaseSchemeProduct"></param>
|
||||
|
private void GetPurchaseProductInfo(PurchaseSchemeProduct purchaseSchemeProduct) |
||||
|
{ |
||||
|
//验证路径是否合法
|
||||
|
if (string.IsNullOrEmpty(purchaseSchemeProduct.PurchaseUrl)) |
||||
|
{ |
||||
|
MessageBox.Show("商品url不能为空"); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
urlPatternDictionary.TryGetValue(PurchasePlatform, out string pattern); |
||||
|
|
||||
|
var match = Regex.Match(purchaseSchemeProduct.PurchaseUrl, pattern); |
||||
|
if (!match.Success) |
||||
|
{ |
||||
|
MessageBox.Show("未能识别的url"); |
||||
|
return; |
||||
|
} |
||||
|
var sku = ProductSkuList.FirstOrDefault(s => s.Id == purchaseSchemeProduct.SkuId); |
||||
|
var purchaseUrl = match.Groups[1].Value; |
||||
|
if (sku.SelectedPurchaseScheme.PurchaseSchemeProductList.Any(p => p.Id != purchaseSchemeProduct.Id && p.PurchaseUrl == purchaseUrl)) |
||||
|
{ |
||||
|
MessageBox.Show("商品链接重复"); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
var purchaseProductId = match.Groups[2].Value; |
||||
|
|
||||
|
IsLoading = true; |
||||
|
|
||||
|
Task.Factory.StartNew(() => |
||||
|
{ |
||||
|
LoadPurchaseProduct(sku.SelectedPurchaseScheme.PurchasePlatform, purchaseSchemeProduct, purchaseProductId, (p) => |
||||
|
{ |
||||
|
if (sku.PurchaseSchemeList.Any(s => s.Id != sku.SelectedPurchaseScheme.Id && s.PurchaserId == p)) |
||||
|
return $"sku{sku.Id}的采购方案中已存在相同的采购商"; //同一个sku中的采购方案不能有相同的采购商
|
||||
|
|
||||
|
if (!string.IsNullOrEmpty(PurchaserId) && p != PurchaserId) //同一批操作的sku必须为相同的采购商
|
||||
|
return "采购商必须相同"; |
||||
|
|
||||
|
return string.Empty; |
||||
|
}, out string errorMsg); |
||||
|
IsLoading = false; |
||||
|
|
||||
|
if (!string.IsNullOrEmpty(errorMsg)) |
||||
|
{ |
||||
|
App.Current.Dispatcher.Invoke(() => MessageBox.Show(errorMsg, "绑定采购商")); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
purchaseSchemeProduct.PurchaseUrl = purchaseUrl; |
||||
|
purchaseSchemeProduct.PurchaseProductId = purchaseProductId; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void ConfirmPurchaseProduct(PurchaseSchemeProduct purchaseSchemeProduct) |
||||
|
{ |
||||
|
if (!purchaseSchemeProduct.SkuList.Any(s => s.IsSelected)) |
||||
|
{ |
||||
|
MessageBox.Show("至少选中一个采购Sku"); |
||||
|
return; |
||||
|
} |
||||
|
purchaseSchemeProduct.PurchaseSchemeProductSkuList.Clear(); |
||||
|
purchaseSchemeProduct.SelectedSkuIdList.Clear(); |
||||
|
foreach (var sku in purchaseSchemeProduct.SkuList) |
||||
|
{ |
||||
|
if (sku.IsSelected) |
||||
|
{ |
||||
|
purchaseSchemeProduct.PurchaseSchemeProductSkuList.Add(sku); |
||||
|
purchaseSchemeProduct.SelectedSkuIdList.Add(sku.PurchaseSkuId); |
||||
|
} |
||||
|
} |
||||
|
purchaseSchemeProduct.IsEditing = false; |
||||
|
|
||||
|
var productSku = ProductSkuList.FirstOrDefault(sku => sku.Id == purchaseSchemeProduct.SkuId); |
||||
|
productSku.SelectedPurchaseScheme.PurchaserId = PurchaserId; |
||||
|
productSku.SelectedPurchaseScheme.PurchaserName = PurchaserName; |
||||
|
productSku.SelectedPurchaseScheme.PurchaserLocation = PurchaserLocation; |
||||
|
productSku.SelectedPurchaseScheme.DefaultCost = productSku.SelectedPurchaseScheme.PurchaseSchemeProductList.Sum(p => p.PurchaseSchemeProductSkuList.Count() == 0 ? 0 : p.PurchaseSchemeProductSkuList.Sum(s => s.Price)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
private void EditPurchaseProduct(PurchaseSchemeProduct purchaseSchemeProduct) |
||||
|
{ |
||||
|
purchaseSchemeProduct.IsEditing = true; |
||||
|
} |
||||
|
|
||||
|
private void SavePurchaseScheme() |
||||
|
{ |
||||
|
if (!ProductSkuList.Any(s => s.SelectedPurchaseScheme != null && s.SelectedPurchaseScheme.PurchaseSchemeProductList.Count != 0)) |
||||
|
{ |
||||
|
MessageBox.Show("没有需要保存的数据,如需删除该采购商所有数据请返回采购商列表进行删除", "提示"); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
var hasNoReady = ProductSkuList.Any(s => s.SelectedPurchaseScheme != null && s.SelectedPurchaseScheme.PurchaseSchemeProductList.Any(p => p.IsEditing)); |
||||
|
if (hasNoReady) |
||||
|
{ |
||||
|
MessageBox.Show("存在未保存的数据", "提示"); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
var addPurchaseSchemeList = ProductSkuList.Where(s => s.SelectedPurchaseScheme != null && |
||||
|
s.SelectedPurchaseScheme.PurchaseSchemeProductList.Count > 0 && |
||||
|
s.SelectedPurchaseScheme.Id == 0) |
||||
|
.Select(s => s.SelectedPurchaseScheme).ToList(); |
||||
|
var editPurchaseSchemeList = ProductSkuList.Where(s => s.SelectedPurchaseScheme != null && |
||||
|
s.SelectedPurchaseScheme.PurchaseSchemeProductList.Count > 0 && |
||||
|
s.SelectedPurchaseScheme.Id != 0) |
||||
|
.Select(s => s.SelectedPurchaseScheme).ToList(); |
||||
|
SuppPurchaseSkuData(addPurchaseSchemeList); |
||||
|
SuppPurchaseSkuData(editPurchaseSchemeList); |
||||
|
|
||||
|
IsLoading = true; |
||||
|
Task.Factory.StartNew(() => |
||||
|
{ |
||||
|
var response = purchaseService.EditPurchaseScheme(addPurchaseSchemeList, editPurchaseSchemeList); |
||||
|
IsLoading = false; |
||||
|
if (response.Success) |
||||
|
{ |
||||
|
App.Current.Dispatcher.Invoke(() => |
||||
|
{ |
||||
|
MessageBox.Show("绑定成功", "提示"); |
||||
|
}); |
||||
|
//关闭窗口
|
||||
|
//Messenger.Default.Send(true, "BindingPurchaseProduct_Close");
|
||||
|
WeakReferenceMessenger.Default.Send(new Message_BindingPurchaseProductClose(true)); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
App.Current.Dispatcher.Invoke(() => |
||||
|
{ |
||||
|
MessageBox.Show(response.Msg, "绑定失败"); |
||||
|
}); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void Closing(System.ComponentModel.CancelEventArgs e) |
||||
|
{ |
||||
|
PurchaserId = PurchaserName = string.Empty; |
||||
|
//clear data
|
||||
|
foreach (var sku in ProductSkuList) |
||||
|
{ |
||||
|
sku.SelectedPurchaseScheme = null; |
||||
|
} |
||||
|
//Product = null;
|
||||
|
e.Cancel = false; |
||||
|
} |
||||
|
|
||||
|
private void SuppPurchaseSkuData(IList<PurchaseScheme> purchaseSchemeList) |
||||
|
{ |
||||
|
foreach (var scheme in purchaseSchemeList) |
||||
|
{ |
||||
|
scheme.ShopId = globalContext.User.Shop.ShopId; |
||||
|
foreach (var purchaseProduct in scheme.PurchaseSchemeProductList) |
||||
|
{ |
||||
|
foreach (var purchaseSku in purchaseProduct.PurchaseSchemeProductSkuList) |
||||
|
{ |
||||
|
purchaseSku.ProductId = scheme.ProductId; |
||||
|
purchaseSku.SkuId = scheme.SkuId; |
||||
|
purchaseSku.SkuPurchaseSchemeId = scheme.Id; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void SearchPurchaseSkuName(PurchaseSchemeProduct purchaseSchemeProduct) |
||||
|
{ |
||||
|
purchaseSchemeProduct.SearchSkuList.Clear(); |
||||
|
if (string.IsNullOrEmpty(purchaseSchemeProduct.SearchPurchaseSkuName)) |
||||
|
{ |
||||
|
foreach (var sku in purchaseSchemeProduct.SkuList) |
||||
|
purchaseSchemeProduct.SearchSkuList.Add(sku); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
var searchList = purchaseSchemeProduct.SkuList.Where(s => s.Title.Contains(purchaseSchemeProduct.SearchPurchaseSkuName)); |
||||
|
foreach (var sku in searchList) |
||||
|
purchaseSchemeProduct.SearchSkuList.Add(sku); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void ClearPurchaseSkuName(PurchaseSchemeProduct purchaseSchemeProduct) |
||||
|
{ |
||||
|
purchaseSchemeProduct.SearchPurchaseSkuName = string.Empty; |
||||
|
SearchPurchaseSkuName(purchaseSchemeProduct); |
||||
|
} |
||||
|
#endregion
|
||||
|
} |
||||
|
} |
@ -0,0 +1,350 @@ |
|||||
|
using BBWYB.Client.APIServices; |
||||
|
using BBWYB.Client.Models; |
||||
|
using BBWYB.Client.Views.Ware; |
||||
|
using BBWYB.Common.Models; |
||||
|
using CommunityToolkit.Mvvm.Input; |
||||
|
using CommunityToolkit.Mvvm.Messaging; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Collections.ObjectModel; |
||||
|
using System.Linq; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Input; |
||||
|
|
||||
|
namespace BBWYB.Client.ViewModels |
||||
|
{ |
||||
|
public class WareManagerViewModel : BaseVM, IDenpendency |
||||
|
{ |
||||
|
#region Properties
|
||||
|
private PurchaseService purchaseService; |
||||
|
private ProductService productService; |
||||
|
private BindingPurchaseProductViewModel bindingPurchaseProduct; |
||||
|
private GlobalContext globalContext; |
||||
|
private bool isLoading; |
||||
|
private int pageIndex = 1; |
||||
|
private int pageSize; |
||||
|
private int productCount; |
||||
|
private string searchProductName; |
||||
|
private string searchProductItem; |
||||
|
private string searchSpu; |
||||
|
private string searchSku; |
||||
|
|
||||
|
public bool IsLoading { get => isLoading; set { SetProperty(ref isLoading, value); } } |
||||
|
|
||||
|
public IList<Product> ProductList { get; set; } |
||||
|
public int PageIndex { get => pageIndex; set { SetProperty(ref pageIndex, value); } } |
||||
|
public int PageSize { get => pageSize; set { SetProperty(ref pageSize, value); } } |
||||
|
public int ProductCount { get => productCount; set { SetProperty(ref productCount, value); } } |
||||
|
|
||||
|
public string SearchProductName { get => searchProductName; set { SetProperty(ref searchProductName, value); } } |
||||
|
public string SearchProductItem { get => searchProductItem; set { SetProperty(ref searchProductItem, value); } } |
||||
|
public string SearchSpu { get => searchSpu; set { SetProperty(ref searchSpu, value); } } |
||||
|
public string SearchSku { get => searchSku; set { SetProperty(ref searchSku, value); } } |
||||
|
#endregion
|
||||
|
|
||||
|
#region Commands
|
||||
|
public ICommand AddPurchaserCommand { get; set; } |
||||
|
public ICommand EditPurchaserCommand { get; set; } |
||||
|
public ICommand DeletePurchaserCommand { get; set; } |
||||
|
public ICommand SearchCommand { get; set; } |
||||
|
public ICommand ProductPageIndexChangedCommand { get; set; } |
||||
|
|
||||
|
public ICommand SwitchPurchasePlatformCommand { get; set; } |
||||
|
#endregion
|
||||
|
|
||||
|
#region Methods
|
||||
|
public WareManagerViewModel(GlobalContext globalContext, BindingPurchaseProductViewModel bindingPurchaseProduct, PurchaseService purchaseService, ProductService productService) |
||||
|
{ |
||||
|
AddPurchaserCommand = new RelayCommand<Product>(AddPurchaser); |
||||
|
EditPurchaserCommand = new RelayCommand<Purchaser>(EditPurchaser); |
||||
|
DeletePurchaserCommand = new RelayCommand<Purchaser>(DeletePurchaser); |
||||
|
SwitchPurchasePlatformCommand = new RelayCommand<object>(SwitchPurchasePlatform); |
||||
|
SearchCommand = new RelayCommand(() => |
||||
|
{ |
||||
|
PageIndex = 1; |
||||
|
Task.Factory.StartNew(() => LoadWare(1)); |
||||
|
}); |
||||
|
ProductPageIndexChangedCommand = new RelayCommand<SJ.Controls.PageArgs>((p) => Task.Factory.StartNew(() => LoadWare(p.PageIndex))); |
||||
|
this.purchaseService = purchaseService; |
||||
|
this.productService = productService; |
||||
|
this.globalContext = globalContext; |
||||
|
this.bindingPurchaseProduct = bindingPurchaseProduct; |
||||
|
ProductList = new ObservableCollection<Product>(); |
||||
|
Task.Factory.StartNew(() => LoadWare(1)); |
||||
|
} |
||||
|
|
||||
|
public override void Refresh() |
||||
|
{ |
||||
|
this.ProductList.Clear(); |
||||
|
this.ProductCount = 0; |
||||
|
PageIndex = 1; |
||||
|
} |
||||
|
|
||||
|
protected override void Load() |
||||
|
{ |
||||
|
Console.WriteLine($"{VMId} {DateTime.Now}"); |
||||
|
} |
||||
|
|
||||
|
private void LoadWare(int pageIndex) |
||||
|
{ |
||||
|
if (!string.IsNullOrEmpty(SearchSpu) && !string.IsNullOrEmpty(SearchSku)) |
||||
|
{ |
||||
|
App.Current.Dispatcher.Invoke(() => MessageBox.Show("SPU和SKU条件不能共存")); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
App.Current.Dispatcher.Invoke(() => ProductList.Clear()); |
||||
|
|
||||
|
IsLoading = true; |
||||
|
|
||||
|
#region 加载JD商品列表
|
||||
|
ApiResponse<ProductListResponse> productApiResponse = null; |
||||
|
if (!string.IsNullOrEmpty(SearchSku)) |
||||
|
{ |
||||
|
var skuResponse = productService.GetProductSkuList(string.Empty, SearchSku); |
||||
|
if (skuResponse.Success) |
||||
|
{ |
||||
|
if (skuResponse.Data.Count == 0) |
||||
|
{ |
||||
|
IsLoading = false; |
||||
|
return; |
||||
|
} |
||||
|
productApiResponse = productService.GetProductList(skuResponse.Data[0].ProductId, string.Empty, string.Empty, pageIndex); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
IsLoading = false; |
||||
|
App.Current.Dispatcher.Invoke(() => MessageBox.Show(skuResponse.Msg, "加载sku")); |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
productApiResponse = productService.GetProductList(SearchSpu, SearchProductName, SearchProductItem, pageIndex); |
||||
|
} |
||||
|
|
||||
|
if (!productApiResponse.Success) |
||||
|
{ |
||||
|
IsLoading = false; |
||||
|
App.Current.Dispatcher.Invoke(() => MessageBox.Show(productApiResponse.Msg, "加载产品")); |
||||
|
return; |
||||
|
} |
||||
|
var productList = productApiResponse.Data.Items; |
||||
|
ProductCount = productApiResponse.Data.Count; |
||||
|
if (ProductCount == 0) |
||||
|
{ |
||||
|
IsLoading = false; |
||||
|
return; |
||||
|
} |
||||
|
#endregion
|
||||
|
|
||||
|
#region 加载JDSKU列表
|
||||
|
var waitList = new List<EventWaitHandle>(); |
||||
|
foreach (var p in productList) |
||||
|
{ |
||||
|
p.CreatePlatformList(); |
||||
|
var ewh = new ManualResetEvent(false); |
||||
|
waitList.Add(ewh); |
||||
|
Task.Factory.StartNew(() => LoadSku(p, ewh)); |
||||
|
} |
||||
|
WaitHandle.WaitAll(waitList.ToArray(), 8000); |
||||
|
#endregion
|
||||
|
|
||||
|
#region 加载采购方案
|
||||
|
var skuList = new List<ProductSku>(); |
||||
|
foreach (var p in productList) |
||||
|
skuList.AddRange(p.SkuList); |
||||
|
LoadPurchaseScheme(skuList); |
||||
|
#endregion
|
||||
|
|
||||
|
App.Current.Dispatcher.BeginInvoke((Action)delegate |
||||
|
{ |
||||
|
foreach (var p in productList) |
||||
|
ProductList.Add(p); |
||||
|
ExtractPurchaser(); |
||||
|
//使滚动条保持顶部
|
||||
|
//Messenger.Default.Send(string.Empty, "WareManager_ProductListScrollToTop");
|
||||
|
WeakReferenceMessenger.Default.Send(new Message_WareManager_ProductListScrollToTop(null)); |
||||
|
}); |
||||
|
|
||||
|
IsLoading = false; |
||||
|
} |
||||
|
|
||||
|
private void LoadSku(Product product, EventWaitHandle ewh) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var skuResponse = productService.GetProductSkuList(product.Id, string.Empty); |
||||
|
if (!skuResponse.Success) |
||||
|
{ |
||||
|
IsLoading = false; |
||||
|
App.Current.Dispatcher.Invoke(() => MessageBox.Show(skuResponse.Msg, "加载sku")); |
||||
|
return; |
||||
|
} |
||||
|
product.SkuList = skuResponse.Data; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
ewh.Set(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 加载采购方案
|
||||
|
/// </summary>
|
||||
|
/// <param name="productList"></param>
|
||||
|
private void LoadPurchaseScheme(IList<ProductSku> skuList, Platform? purchasePlatform = Platform.阿里巴巴) |
||||
|
{ |
||||
|
var response = purchaseService.GetPurchaseSchemeList(skuList.Select(s => s.Id).ToList(), string.Empty, globalContext.User.Shop.ShopId, purchasePlatform: purchasePlatform); |
||||
|
if (!response.Success) |
||||
|
{ |
||||
|
App.Current.Dispatcher.BeginInvoke((Action)delegate { MessageBox.Show(response.Msg, "获取采购方案"); }); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
var schemeList = response.Data; |
||||
|
|
||||
|
App.Current.Dispatcher.Invoke(() => |
||||
|
{ |
||||
|
foreach (var s in skuList) |
||||
|
{ |
||||
|
s.PurchaseSchemeList.Clear(); |
||||
|
var currentSchemeList = schemeList.Where(scheme => scheme.SkuId == s.Id); |
||||
|
if (currentSchemeList.Count() > 0) |
||||
|
foreach (var scheme in currentSchemeList) |
||||
|
s.PurchaseSchemeList.Add(PurchaseScheme.Convert(scheme)); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 提取SKU中的采购商到商品的采购商列表中
|
||||
|
/// </summary>
|
||||
|
private void ExtractPurchaser(string productId = "") |
||||
|
{ |
||||
|
var productList = string.IsNullOrEmpty(productId) ? ProductList : ProductList.Where(p => p.Id == productId); |
||||
|
foreach (var product in productList) |
||||
|
{ |
||||
|
product.PurchaserList.Clear(); |
||||
|
foreach (var sku in product.SkuList) |
||||
|
{ |
||||
|
if (sku.PurchaseSchemeList.Count() > 0) |
||||
|
{ |
||||
|
foreach (var pscheme in sku.PurchaseSchemeList) |
||||
|
{ |
||||
|
var purchaser = product.PurchaserList.FirstOrDefault(purchaser => purchaser.Id == pscheme.PurchaserId); |
||||
|
if (purchaser == null) |
||||
|
{ |
||||
|
purchaser = new Purchaser() { Id = pscheme.PurchaserId, Name = pscheme.PurchaserName, ProductId = product.Id }; |
||||
|
product.PurchaserList.Add(purchaser); |
||||
|
} |
||||
|
purchaser.SkuUseCount++; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void AddPurchaser(Product product) |
||||
|
{ |
||||
|
if (product.PurchaserList.Count >= 5) |
||||
|
{ |
||||
|
MessageBox.Show("一个SPU内最多允许5个采购商"); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
OpenBindingView(product, string.Empty, string.Empty); |
||||
|
} |
||||
|
|
||||
|
private void EditPurchaser(Purchaser purchaser) |
||||
|
{ |
||||
|
var product = ProductList.FirstOrDefault(p => p.Id == purchaser.ProductId); |
||||
|
OpenBindingView(product, purchaser.Id, purchaser.Name); |
||||
|
} |
||||
|
|
||||
|
private void DeletePurchaser(Purchaser purchaser) |
||||
|
{ |
||||
|
if (MessageBox.Show("确认删除该采购商吗?", "提示", MessageBoxButton.OKCancel) != MessageBoxResult.OK) |
||||
|
return; |
||||
|
IsLoading = true; |
||||
|
Task.Factory.StartNew(() => |
||||
|
{ |
||||
|
var response = purchaseService.DeletePurchaser(purchaser.ProductId, purchaser.Id); |
||||
|
IsLoading = false; |
||||
|
if (response.Success) |
||||
|
{ |
||||
|
App.Current.Dispatcher.BeginInvoke((Action)delegate |
||||
|
{ |
||||
|
var product = ProductList.FirstOrDefault(p => p.Id == purchaser.ProductId); |
||||
|
if (product != null) |
||||
|
{ |
||||
|
foreach (var sku in product.SkuList) |
||||
|
{ |
||||
|
var deleteScheme = sku.PurchaseSchemeList.FirstOrDefault(s => s.PurchaserId == purchaser.Id); |
||||
|
if (deleteScheme != null) |
||||
|
sku.PurchaseSchemeList.Remove(deleteScheme); |
||||
|
} |
||||
|
product.PurchaserList.Remove(purchaser); |
||||
|
} |
||||
|
MessageBox.Show("采购商删除成功", "提示"); |
||||
|
}); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
App.Current.Dispatcher.BeginInvoke((Action)delegate |
||||
|
{ |
||||
|
MessageBox.Show(response.Msg, "采购商删除"); |
||||
|
}); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void OpenBindingView(Product product, string purchaserId, string purchaserName) |
||||
|
{ |
||||
|
var skuList = product.SkuList; |
||||
|
bindingPurchaseProduct.SetData(skuList, purchaserId, purchaserName, product.SelectedPurchasePlatformModel); |
||||
|
var bindingView = new BindingPurchaseProduct(); |
||||
|
var r = bindingView.ShowDialog(); |
||||
|
if (r == true) |
||||
|
{ |
||||
|
Console.WriteLine("Refresh PurchaseScheme"); |
||||
|
Task.Factory.StartNew(() => |
||||
|
{ |
||||
|
IsLoading = true; |
||||
|
LoadPurchaseScheme(skuList, product.SelectedPurchasePlatformModel); |
||||
|
IsLoading = false; |
||||
|
App.Current.Dispatcher.BeginInvoke((Action)delegate |
||||
|
{ |
||||
|
ExtractPurchaser(product.Id); |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void SwitchPurchasePlatform(object param) |
||||
|
{ |
||||
|
var paramList = (object[])param; |
||||
|
var productId = paramList[0].ToString(); |
||||
|
var platform = (Platform)paramList[1]; |
||||
|
|
||||
|
var product = ProductList.FirstOrDefault(p => p.Id == productId); |
||||
|
IsLoading = true; |
||||
|
Task.Factory.StartNew(() => LoadPurchaseScheme(product.SkuList, platform)) |
||||
|
.ContinueWith(t => |
||||
|
{ |
||||
|
App.Current.Dispatcher.Invoke(() => ExtractPurchaser(productId)); |
||||
|
IsLoading = false; |
||||
|
}); |
||||
|
} |
||||
|
#endregion
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,339 @@ |
|||||
|
using BBWYB.Client.APIServices; |
||||
|
using BBWYB.Client.Models; |
||||
|
using BBWYB.Client.Views.Ware; |
||||
|
using BBWYB.Common.Extensions; |
||||
|
using BBWYB.Common.Models; |
||||
|
using CommunityToolkit.Mvvm.Input; |
||||
|
using CommunityToolkit.Mvvm.Messaging; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Collections.ObjectModel; |
||||
|
using System.Linq; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Input; |
||||
|
|
||||
|
namespace BBWYB.Client.ViewModels |
||||
|
{ |
||||
|
public class WareStockViewModel : BaseVM, IDenpendency |
||||
|
{ |
||||
|
#region Property
|
||||
|
private PurchaseOrderService purchaseOrderService; |
||||
|
private ProductService productService; |
||||
|
private GlobalContext globalContext; |
||||
|
|
||||
|
private bool isLoading; |
||||
|
private int pageIndex = 1; |
||||
|
private int pageSize; |
||||
|
private int productCount; |
||||
|
private string searchProductItem; |
||||
|
private string searchSpu; |
||||
|
private string searchSku; |
||||
|
private string searchPurchaseOrder; |
||||
|
|
||||
|
public bool IsLoading { get => isLoading; set { SetProperty(ref isLoading, value); } } |
||||
|
public int PageIndex { get => pageIndex; set { SetProperty(ref pageIndex, value); } } |
||||
|
public int PageSize { get => pageSize; set { SetProperty(ref pageSize, value); } } |
||||
|
public int ProductCount { get => productCount; set { SetProperty(ref productCount, value); } } |
||||
|
public string SearchProductItem { get => searchProductItem; set { SetProperty(ref searchProductItem, value); } } |
||||
|
public string SearchSpu { get => searchSpu; set { SetProperty(ref searchSpu, value); } } |
||||
|
public string SearchSku { get => searchSku; set { SetProperty(ref searchSku, value); } } |
||||
|
public string SearchPurchaseOrder { get => searchPurchaseOrder; set { SetProperty(ref searchPurchaseOrder, value); } } |
||||
|
|
||||
|
public IList<Product> ProductList { get; set; } |
||||
|
#endregion
|
||||
|
|
||||
|
#region ICommand
|
||||
|
public ICommand SearchCommand { get; set; } |
||||
|
public ICommand ProductPageIndexChangedCommand { get; set; } |
||||
|
public ICommand AddPurchaserOrderCommand { get; set; } |
||||
|
public ICommand EditPurchaseOrderCommand { get; set; } |
||||
|
public ICommand DeletePurchaseOrderCommand { get; set; } |
||||
|
public ICommand SavePurchaseOrderCommand { get; set; } |
||||
|
public ICommand SwitchStorageTypeCommand { get; set; } |
||||
|
#endregion
|
||||
|
|
||||
|
#region Method
|
||||
|
public WareStockViewModel(GlobalContext globalContext, PurchaseOrderService purchaseOrderService, ProductService productService) |
||||
|
{ |
||||
|
this.globalContext = globalContext; |
||||
|
this.purchaseOrderService = purchaseOrderService; |
||||
|
this.productService = productService; |
||||
|
ProductList = new ObservableCollection<Product>(); |
||||
|
|
||||
|
SearchCommand = new RelayCommand(() => |
||||
|
{ |
||||
|
PageIndex = 1; |
||||
|
Task.Factory.StartNew(() => LoadWare(1)); |
||||
|
}); |
||||
|
ProductPageIndexChangedCommand = new RelayCommand<SJ.Controls.PageArgs>((p) => Task.Factory.StartNew(() => LoadWare(p.PageIndex))); |
||||
|
SwitchStorageTypeCommand = new RelayCommand<StorageModel>(SwitchStorageType); |
||||
|
AddPurchaserOrderCommand = new RelayCommand<Product>(AddPurchaserOrder); |
||||
|
EditPurchaseOrderCommand = new RelayCommand<PurchaseOrder>(po => po.IsEdit = true); |
||||
|
DeletePurchaseOrderCommand = new RelayCommand<PurchaseOrder>(DeletePurchaseOrder); |
||||
|
SavePurchaseOrderCommand = new RelayCommand<PurchaseOrder>(SavePurchaseOrder); |
||||
|
Task.Factory.StartNew(() => LoadWare(1)); |
||||
|
} |
||||
|
|
||||
|
public override void Refresh() |
||||
|
{ |
||||
|
ProductList.Clear(); |
||||
|
ProductCount = 0; |
||||
|
PageSize = 1; |
||||
|
} |
||||
|
private void LoadWare(int pageIndex) |
||||
|
{ |
||||
|
if (!string.IsNullOrEmpty(SearchSpu) && !string.IsNullOrEmpty(SearchSku)) |
||||
|
{ |
||||
|
App.Current.Dispatcher.Invoke(() => MessageBox.Show("SPU和SKU条件不能共存")); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
App.Current.Dispatcher.Invoke(() => ProductList.Clear()); |
||||
|
|
||||
|
IsLoading = true; |
||||
|
|
||||
|
#region 加载JD商品列表
|
||||
|
ApiResponse<ProductListResponse> productApiResponse = null; |
||||
|
if (!string.IsNullOrEmpty(SearchSku)) |
||||
|
{ |
||||
|
var skuResponse = productService.GetProductSkuList(string.Empty, SearchSku); |
||||
|
if (skuResponse.Success) |
||||
|
{ |
||||
|
if (skuResponse.Data.Count == 0) |
||||
|
{ |
||||
|
IsLoading = false; |
||||
|
return; |
||||
|
} |
||||
|
productApiResponse = productService.GetProductList(skuResponse.Data[0].ProductId, string.Empty, string.Empty, pageIndex); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
IsLoading = false; |
||||
|
App.Current.Dispatcher.Invoke(() => MessageBox.Show(skuResponse.Msg, "加载sku")); |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
productApiResponse = productService.GetProductList(SearchSpu, string.Empty, SearchProductItem, pageIndex); |
||||
|
} |
||||
|
|
||||
|
if (!productApiResponse.Success) |
||||
|
{ |
||||
|
IsLoading = false; |
||||
|
App.Current.Dispatcher.Invoke(() => MessageBox.Show(productApiResponse.Msg, "加载产品")); |
||||
|
return; |
||||
|
} |
||||
|
var productList = productApiResponse.Data.Items; |
||||
|
ProductCount = productApiResponse.Data.Count; |
||||
|
if (ProductCount == 0) |
||||
|
{ |
||||
|
IsLoading = false; |
||||
|
return; |
||||
|
} |
||||
|
#endregion
|
||||
|
|
||||
|
#region 加载JDSKU列表
|
||||
|
var waitList = new List<EventWaitHandle>(); |
||||
|
foreach (var p in productList) |
||||
|
{ |
||||
|
var ewh = new ManualResetEvent(false); |
||||
|
waitList.Add(ewh); |
||||
|
Task.Factory.StartNew(() => LoadSku(p, ewh)); |
||||
|
} |
||||
|
WaitHandle.WaitAll(waitList.ToArray(), 8000); |
||||
|
#endregion
|
||||
|
|
||||
|
#region 加载采购单
|
||||
|
LoadPurchaseOrder(productList, StorageType.京仓); |
||||
|
#endregion
|
||||
|
|
||||
|
App.Current.Dispatcher.BeginInvoke((Action)delegate |
||||
|
{ |
||||
|
foreach (var p in productList) |
||||
|
ProductList.Add(p); |
||||
|
//使滚动条保持顶部
|
||||
|
//Messenger.Default.Send(string.Empty, "WareStock_ProductListScrollToTop");
|
||||
|
WeakReferenceMessenger.Default.Send(new Message_WareStock_ProductListScrollToTop(null)); |
||||
|
}); |
||||
|
|
||||
|
IsLoading = false; |
||||
|
} |
||||
|
|
||||
|
private void LoadSku(Product product, EventWaitHandle ewh) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var skuResponse = productService.GetProductSkuList(product.Id, string.Empty); |
||||
|
if (!skuResponse.Success) |
||||
|
{ |
||||
|
IsLoading = false; |
||||
|
App.Current.Dispatcher.Invoke(() => MessageBox.Show(skuResponse.Msg, "加载sku")); |
||||
|
return; |
||||
|
} |
||||
|
foreach (var sku in skuResponse.Data) |
||||
|
{ |
||||
|
sku.StorageList.Add(new StorageModel() |
||||
|
{ |
||||
|
ProductId = product.Id, |
||||
|
SkuId = sku.Id, |
||||
|
StorageType = StorageType.京仓 |
||||
|
}); |
||||
|
sku.StorageList.Add(new StorageModel() |
||||
|
{ |
||||
|
ProductId = product.Id, |
||||
|
SkuId = sku.Id, |
||||
|
StorageType = StorageType.云仓 |
||||
|
}); |
||||
|
sku.StorageList.Add(new StorageModel() |
||||
|
{ |
||||
|
ProductId = product.Id, |
||||
|
SkuId = sku.Id, |
||||
|
StorageType = StorageType.本地自发 |
||||
|
}); |
||||
|
sku.SelectedStorageModel = sku.StorageList[0]; |
||||
|
} |
||||
|
product.SkuList = skuResponse.Data; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
ewh.Set(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void LoadPurchaseOrder(IList<Product> productList, StorageType storageType) |
||||
|
{ |
||||
|
var skuList = new List<ProductSku>(); |
||||
|
foreach (var p in productList) |
||||
|
skuList.AddRange(p.SkuList); |
||||
|
LoadPurchaseOrder(skuList, storageType); |
||||
|
} |
||||
|
|
||||
|
private void LoadPurchaseOrder(IList<ProductSku> skuList, StorageType storageType) |
||||
|
{ |
||||
|
App.Current.Dispatcher.Invoke(() => |
||||
|
{ |
||||
|
foreach (var s in skuList) |
||||
|
s.PurchaseOrderList.Clear(); |
||||
|
}); |
||||
|
var response = purchaseOrderService.GetList(skuList.Select(s => s.Id).ToList(), storageType, globalContext.User.Shop.ShopId); |
||||
|
if (response.Success) |
||||
|
{ |
||||
|
var purchaseOrderList = response.Data; |
||||
|
App.Current.Dispatcher.Invoke(() => |
||||
|
{ |
||||
|
foreach (var s in skuList) |
||||
|
{ |
||||
|
var currentSkuPurchaseOrderList = purchaseOrderList.Where(po => po.SkuId == s.Id).Map<IList<PurchaseOrder>>(); |
||||
|
foreach (var po in currentSkuPurchaseOrderList) |
||||
|
s.PurchaseOrderList.Add(po); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void SwitchStorageType(StorageModel storageModel) |
||||
|
{ |
||||
|
var product = ProductList.FirstOrDefault(p => p.Id == storageModel.ProductId); |
||||
|
var sku = product.SkuList.FirstOrDefault(s => s.Id == storageModel.SkuId); |
||||
|
if (sku.SelectedStorageModel == storageModel) |
||||
|
return; |
||||
|
sku.SelectedStorageModel = storageModel; |
||||
|
IsLoading = true; |
||||
|
Task.Factory.StartNew(() => |
||||
|
{ |
||||
|
LoadPurchaseOrder(new List<ProductSku>() { sku }, storageModel.StorageType); |
||||
|
IsLoading = false; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void AddPurchaserOrder(Product product) |
||||
|
{ |
||||
|
foreach (var sku in product.SkuList) |
||||
|
sku.PurchaseOrderList.Add(new PurchaseOrder |
||||
|
{ |
||||
|
IsEdit = true, |
||||
|
SkuId = sku.Id, |
||||
|
ProductId = product.Id, |
||||
|
UserId = globalContext.User.Id, |
||||
|
StorageType = sku.SelectedStorageModel.StorageType, |
||||
|
PurchaseMethod = PurchaseMethod.线下采购, |
||||
|
CreateTime = DateTime.Now, |
||||
|
ShopId = globalContext.User.Shop.ShopId, |
||||
|
PurchasePlatform = Platform.阿里巴巴 |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void DeletePurchaseOrder(PurchaseOrder purchaseOrder) |
||||
|
{ |
||||
|
var product = ProductList.FirstOrDefault(p => p.Id == purchaseOrder.ProductId); |
||||
|
var sku = product.SkuList.FirstOrDefault(s => s.Id == purchaseOrder.SkuId); |
||||
|
if (purchaseOrder.Id == 0) |
||||
|
{ |
||||
|
sku.PurchaseOrderList.Remove(purchaseOrder); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
if (MessageBox.Show("确定要删除采购单吗?", "确认", MessageBoxButton.OKCancel) != MessageBoxResult.OK) |
||||
|
return; |
||||
|
IsLoading = true; |
||||
|
Task.Factory.StartNew(() => |
||||
|
{ |
||||
|
var response = purchaseOrderService.DeletePurchaseOrder(purchaseOrder.Id); |
||||
|
IsLoading = false; |
||||
|
App.Current.Dispatcher.BeginInvoke((Action)delegate |
||||
|
{ |
||||
|
if (response.Success) |
||||
|
sku.PurchaseOrderList.Remove(purchaseOrder); |
||||
|
else |
||||
|
MessageBox.Show(response.Msg, "删除采购单"); |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void SavePurchaseOrder(PurchaseOrder purchaseOrder) |
||||
|
{ |
||||
|
if (purchaseOrder.PurchasePlatform == null || |
||||
|
string.IsNullOrEmpty(purchaseOrder.PurchaseOrderId) || |
||||
|
purchaseOrder.PurchaseQuantity == 0) |
||||
|
{ |
||||
|
MessageBox.Show("缺少必要信息", "保存采购单"); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if (purchaseOrder.RemainingQuantity > purchaseOrder.PurchaseQuantity) |
||||
|
{ |
||||
|
MessageBox.Show("剩余库存不成超过采购数量", "保存采购单"); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
purchaseOrder.IsEdit = false; |
||||
|
var product = ProductList.FirstOrDefault(p => p.Id == purchaseOrder.ProductId); |
||||
|
var sku = product.SkuList.FirstOrDefault(s => s.Id == purchaseOrder.SkuId); |
||||
|
IsLoading = true; |
||||
|
Task.Factory.StartNew(() => |
||||
|
{ |
||||
|
var response = purchaseOrder.Id == 0 ? purchaseOrderService.AddPurchaseOrder(purchaseOrder) : |
||||
|
purchaseOrderService.EditPurchaseOrder(purchaseOrder); |
||||
|
IsLoading = false; |
||||
|
if (response.Success) |
||||
|
{ |
||||
|
if (purchaseOrder.Id == 0) |
||||
|
LoadPurchaseOrder(new List<ProductSku>() { sku }, purchaseOrder.StorageType.Value); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "保存采购单")); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
#endregion
|
||||
|
} |
||||
|
} |
@ -0,0 +1,268 @@ |
|||||
|
<c:BWindow x:Class="BBWYB.Client.Views.Ware.BindingPurchaseProduct" |
||||
|
xmlns:c="clr-namespace:SJ.Controls;assembly=SJ.Controls" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
|
xmlns:b="http://schemas.microsoft.com/xaml/behaviors" |
||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
|
xmlns:local="clr-namespace:BBWYB.Client.Views.Ware" |
||||
|
mc:Ignorable="d" |
||||
|
Style="{StaticResource bwstyle}" |
||||
|
DataContext="{Binding BindingPurchaseProduct,Source={StaticResource Locator}}" |
||||
|
Title="绑定采购商品" Height="768" Width="665"> |
||||
|
<b:Interaction.Triggers> |
||||
|
<b:EventTrigger EventName="Loaded"> |
||||
|
<b:InvokeCommandAction Command="{Binding LoadCommand}"/> |
||||
|
</b:EventTrigger> |
||||
|
<b:EventTrigger EventName="Closing"> |
||||
|
<b:InvokeCommandAction Command="{Binding ClosingCommand}" PassEventArgsToCommand="True"/> |
||||
|
</b:EventTrigger> |
||||
|
</b:Interaction.Triggers> |
||||
|
<Grid> |
||||
|
<Grid.RowDefinitions> |
||||
|
<RowDefinition Height="30"/> |
||||
|
<RowDefinition/> |
||||
|
<RowDefinition Height="40"/> |
||||
|
</Grid.RowDefinitions> |
||||
|
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"> |
||||
|
<Run Text="{Binding PurchaserName}"/> |
||||
|
<Run Text="绑定采购商品"/> |
||||
|
</TextBlock> |
||||
|
<ListBox x:Name="listbox_skuList" ItemsSource="{Binding ProductSkuList}" |
||||
|
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" |
||||
|
Grid.Row="1" |
||||
|
Foreground="{StaticResource Text.Color}"> |
||||
|
<ListBox.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<Grid Width="{Binding ActualWidth,ElementName=listbox_skuList}"> |
||||
|
<Grid.RowDefinitions> |
||||
|
<RowDefinition Height="30"/> |
||||
|
<RowDefinition/> |
||||
|
<RowDefinition Height="Auto"/> |
||||
|
</Grid.RowDefinitions> |
||||
|
<Border Padding="5,0" |
||||
|
Background="#F2F2F2" |
||||
|
BorderThickness="0,1,0,1" |
||||
|
BorderBrush="{StaticResource Border.Brush}"> |
||||
|
<Grid VerticalAlignment="Center"> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="auto"/> |
||||
|
<ColumnDefinition/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
<TextBlock> |
||||
|
<Run Text="SKU:"/> |
||||
|
<Run Text="{Binding Id}"/> |
||||
|
</TextBlock> |
||||
|
<TextBlock Grid.Column="1" TextTrimming="CharacterEllipsis" Margin="10,0,0,0"> |
||||
|
<Run Text="SKU名称:"/> |
||||
|
<Run Text="{Binding Title}"/> |
||||
|
</TextBlock> |
||||
|
</Grid> |
||||
|
</Border> |
||||
|
<ListBox x:Name="listbox_purchaseSchemeProductList" |
||||
|
ItemsSource="{Binding SelectedPurchaseScheme.PurchaseSchemeProductList}" |
||||
|
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" |
||||
|
Style="{StaticResource NoScrollViewListBoxStyle}" |
||||
|
Grid.Row="1"> |
||||
|
<ListBox.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<Border Width="{Binding ActualWidth,ElementName=listbox_purchaseSchemeProductList,Converter={StaticResource widthConverter},ConverterParameter=10}" |
||||
|
BorderBrush="{StaticResource Border.Brush}" |
||||
|
BorderThickness="1" |
||||
|
Margin="5" |
||||
|
Padding="5,0"> |
||||
|
<Grid> |
||||
|
<Grid.RowDefinitions> |
||||
|
<RowDefinition Height="Auto"/> |
||||
|
<RowDefinition/> |
||||
|
<RowDefinition Height="Auto"/> |
||||
|
</Grid.RowDefinitions> |
||||
|
<Grid> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition /> |
||||
|
<ColumnDefinition Width="80"/> |
||||
|
<ColumnDefinition Width="5"/> |
||||
|
<ColumnDefinition Width="80"/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
<Grid.RowDefinitions> |
||||
|
<RowDefinition Height="40"/> |
||||
|
<RowDefinition Height="auto"/> |
||||
|
</Grid.RowDefinitions> |
||||
|
<TextBlock Text="商品链接:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0"/> |
||||
|
<c:BTextBox Text="{Binding PurchaseUrl}" Grid.Column="1" |
||||
|
IsEnabled="{Binding IsEditing}" |
||||
|
DisableBgColor="{StaticResource TextBox.Disable.BgColor}"/> |
||||
|
<c:BButton Content="查询" Grid.Column="2" Width="80" |
||||
|
Command="{Binding DataContext.GetPurchaseProductInfoCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type c:BWindow}}}" |
||||
|
CommandParameter="{Binding }" |
||||
|
Visibility="{Binding IsEditing,Converter={StaticResource objConverter},ConverterParameter=true:Visible:Collapsed}"/> |
||||
|
<c:BButton Content="修改" Grid.Column="2" Width="80" |
||||
|
Command="{Binding DataContext.EditPurchaseProductCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type c:BWindow}}}" |
||||
|
CommandParameter="{Binding }" |
||||
|
Visibility="{Binding IsEditing,Converter={StaticResource objConverter},ConverterParameter=false:Visible:Collapsed}"/> |
||||
|
<c:BButton Content="删除" Grid.Column="4" Width="80" Background="#EC808D" |
||||
|
Command="{Binding DataContext.RemovePurchaseSchemeProductCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type c:BWindow}}}" |
||||
|
CommandParameter="{Binding }"/> |
||||
|
|
||||
|
|
||||
|
<TextBlock x:Name="lbl_purchaseSkuName" |
||||
|
VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0" |
||||
|
Grid.Row="1" TextBlock.TextAlignment="Right" |
||||
|
Visibility="{Binding IsEditing,Converter={StaticResource objConverter},ConverterParameter=true:Visible:Collapsed}"> |
||||
|
<Run Text="采购SKU"/> |
||||
|
<LineBreak/> |
||||
|
<Run Text="名称:"/> |
||||
|
</TextBlock> |
||||
|
<c:BTextBox Text="{Binding SearchPurchaseSkuName}" Grid.Column="1" |
||||
|
Grid.Row="1" |
||||
|
Visibility="{Binding Visibility,ElementName=lbl_purchaseSkuName}"/> |
||||
|
|
||||
|
<c:BButton Content="筛选" Grid.Column="2" Grid.Row="1" Width="80" |
||||
|
Visibility="{Binding Visibility,ElementName=lbl_purchaseSkuName}" |
||||
|
Command="{Binding DataContext.SearchPurchaseSkuNameCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}}}" CommandParameter="{Binding }"/> |
||||
|
<c:BButton Content="清空" Grid.Column="4" Grid.Row="1" Width="80" |
||||
|
Background="#AAAAAA" |
||||
|
Visibility="{Binding Visibility,ElementName=lbl_purchaseSkuName}" |
||||
|
Command="{Binding DataContext.ClearPurchaseSkuNameCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}}}" CommandParameter="{Binding }"/> |
||||
|
</Grid> |
||||
|
|
||||
|
<ListBox x:Name="listbox_purchaseProductSkuList" |
||||
|
Grid.Row="1" |
||||
|
ItemsSource="{Binding SearchSkuList}" |
||||
|
SelectionMode="Multiple" |
||||
|
Visibility="{Binding IsEditing,Converter={StaticResource objConverter},ConverterParameter=true:Visible:Collapsed}" |
||||
|
Style="{StaticResource NoScrollViewListBoxStyle}"> |
||||
|
<ListBox.ItemContainerStyle> |
||||
|
<Style TargetType="ListBoxItem" BasedOn="{StaticResource NoBgListBoxItemStyle}"> |
||||
|
<Setter Property="ListBoxItem.IsSelected" Value="{Binding IsSelected}"/> |
||||
|
</Style> |
||||
|
</ListBox.ItemContainerStyle> |
||||
|
<ListBox.ItemsPanel> |
||||
|
<ItemsPanelTemplate> |
||||
|
<WrapPanel Orientation="Horizontal" Width="{Binding ActualWidth,ElementName=listbox_purchaseProductSkuList}"/> |
||||
|
</ItemsPanelTemplate> |
||||
|
</ListBox.ItemsPanel> |
||||
|
<ListBox.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<Grid Margin="0,5"> |
||||
|
<Grid.ToolTip> |
||||
|
<StackPanel> |
||||
|
<TextBlock> |
||||
|
<Run Text="SKU属性"/> |
||||
|
<Run Text="{Binding Title}"/> |
||||
|
</TextBlock> |
||||
|
<TextBlock> |
||||
|
<Run Text="SKU"/> |
||||
|
<Run Text="{Binding PurchaseSkuId}"/> |
||||
|
</TextBlock> |
||||
|
</StackPanel> |
||||
|
</Grid.ToolTip> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="16"/> |
||||
|
<ColumnDefinition Width="50"/> |
||||
|
<ColumnDefinition Width="250"/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
<Grid.RowDefinitions> |
||||
|
<RowDefinition/> |
||||
|
<RowDefinition/> |
||||
|
</Grid.RowDefinitions> |
||||
|
<CheckBox IsChecked="{Binding IsSelected}" |
||||
|
Grid.RowSpan="2" |
||||
|
VerticalAlignment="Center" VerticalContentAlignment="Center"/> |
||||
|
<c:BAsyncImage Width="40" DecodePixelWidth="40" |
||||
|
UrlSource="{Binding Logo}" |
||||
|
Grid.Column="1" Grid.RowSpan="2" |
||||
|
BorderThickness="1" |
||||
|
BorderBrush="{StaticResource Border.Brush}"/> |
||||
|
<TextBlock Text="{Binding Title}" Grid.Column="2" VerticalAlignment="Center"/> |
||||
|
<TextBlock Grid.Column="2" Grid.Row="1" VerticalAlignment="Center"> |
||||
|
<Run Text="单价"/> |
||||
|
<Run Text="{Binding Price}"/> |
||||
|
</TextBlock> |
||||
|
</Grid> |
||||
|
</DataTemplate> |
||||
|
</ListBox.ItemTemplate> |
||||
|
</ListBox> |
||||
|
<ListBox ItemsSource="{Binding PurchaseSchemeProductSkuList}" |
||||
|
Grid.Row="1" |
||||
|
Visibility="{Binding IsEditing,Converter={StaticResource objConverter},ConverterParameter=true:Collapsed:Visible}" |
||||
|
x:Name="listbox_selectedPurchaseProductSkuList" |
||||
|
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" |
||||
|
Style="{StaticResource NoScrollViewListBoxStyle}"> |
||||
|
<ListBox.ItemsPanel> |
||||
|
<ItemsPanelTemplate> |
||||
|
<WrapPanel Orientation="Horizontal" Width="{Binding ActualWidth,ElementName=listbox_selectedPurchaseProductSkuList}"/> |
||||
|
</ItemsPanelTemplate> |
||||
|
</ListBox.ItemsPanel> |
||||
|
<ListBox.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<Grid Margin="0,5"> |
||||
|
<Grid.ToolTip> |
||||
|
<StackPanel> |
||||
|
<TextBlock> |
||||
|
<Run Text="SKU属性"/> |
||||
|
<Run Text="{Binding Title}"/> |
||||
|
</TextBlock> |
||||
|
<TextBlock> |
||||
|
<Run Text="SKU"/> |
||||
|
<Run Text="{Binding PurchaseSkuId}"/> |
||||
|
</TextBlock> |
||||
|
</StackPanel> |
||||
|
</Grid.ToolTip> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="50"/> |
||||
|
<ColumnDefinition Width="220"/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
<Grid.RowDefinitions> |
||||
|
<RowDefinition/> |
||||
|
<RowDefinition/> |
||||
|
</Grid.RowDefinitions> |
||||
|
<c:BAsyncImage Width="40" DecodePixelWidth="40" |
||||
|
UrlSource="{Binding Logo}" Grid.RowSpan="2" |
||||
|
BorderThickness="1" |
||||
|
BorderBrush="{StaticResource Border.Brush}"/> |
||||
|
<TextBlock Text="{Binding Title}" Grid.Column="1" VerticalAlignment="Center"/> |
||||
|
<TextBlock Grid.Column="1" Grid.Row="1" VerticalAlignment="Center"> |
||||
|
<Run Text="单价"/> |
||||
|
<Run Text="{Binding Price}"/> |
||||
|
</TextBlock> |
||||
|
</Grid> |
||||
|
</DataTemplate> |
||||
|
</ListBox.ItemTemplate> |
||||
|
</ListBox> |
||||
|
|
||||
|
<c:BButton Content="确定" Grid.Row="2" Width="80" Margin="0,0,0,5" HorizontalAlignment="Right" |
||||
|
Visibility="{Binding IsEditing,Converter={StaticResource objConverter},ConverterParameter=true:Visible:Collapsed}" |
||||
|
Command="{Binding DataContext.ConfirmPurchaseProductCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type c:BWindow}}}" CommandParameter="{Binding }"/> |
||||
|
</Grid> |
||||
|
</Border> |
||||
|
</DataTemplate> |
||||
|
</ListBox.ItemTemplate> |
||||
|
</ListBox> |
||||
|
<c:BButton Grid.Row="2" Background="Transparent" Foreground="{StaticResource PathColor}" Margin="0,10" |
||||
|
Command="{Binding DataContext.AddPurchaseProductCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}}}" |
||||
|
CommandParameter="{Binding }"> |
||||
|
<StackPanel> |
||||
|
<Path Style="{StaticResource path_add}" Width="16"/> |
||||
|
<TextBlock Text="添加链接"/> |
||||
|
</StackPanel> |
||||
|
</c:BButton> |
||||
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" |
||||
|
VerticalAlignment="Center" |
||||
|
Grid.Row="2" Margin="0,0,5,0" |
||||
|
Visibility="{Binding SelectedPurchaseScheme,Converter={StaticResource objConverter},ConverterParameter=#null:Collapsed:Visible}"> |
||||
|
<TextBlock Text="默认成本" VerticalAlignment="Center"/> |
||||
|
<c:BTextBox Text="{Binding SelectedPurchaseScheme.DefaultCost}" Width="60"/> |
||||
|
<TextBlock Text="实际成本" VerticalAlignment="Center"/> |
||||
|
<c:BTextBox Text="{Binding SelectedPurchaseScheme.RealCost}" Width="60"/> |
||||
|
</StackPanel> |
||||
|
</Grid> |
||||
|
</DataTemplate> |
||||
|
</ListBox.ItemTemplate> |
||||
|
</ListBox> |
||||
|
<c:BButton Content="保存" Grid.Row="2" HorizontalAlignment="Right" Width="80" Margin="0,0,5,0" |
||||
|
Command="{Binding SavePurchaseSchemeCommand}"/> |
||||
|
<c:RoundWaitProgress Grid.RowSpan="3" Play="{Binding IsLoading}" WaitText="加载中..."/> |
||||
|
</Grid> |
||||
|
</c:BWindow> |
@ -0,0 +1,50 @@ |
|||||
|
using CommunityToolkit.Mvvm.Messaging; |
||||
|
using CommunityToolkit.Mvvm.Messaging.Messages; |
||||
|
using SJ.Controls; |
||||
|
using System.Windows; |
||||
|
|
||||
|
namespace BBWYB.Client.Views.Ware |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// BindingPurchaseProduct.xaml 的交互逻辑
|
||||
|
/// </summary>
|
||||
|
public partial class BindingPurchaseProduct : BWindow |
||||
|
{ |
||||
|
public BindingPurchaseProduct() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
//Messenger.Default.Register<bool>(this, "BindingPurchaseProduct_Close", (x) =>
|
||||
|
// {
|
||||
|
// this.Dispatcher.Invoke(() =>
|
||||
|
// {
|
||||
|
// this.DialogResult = x;
|
||||
|
// this.Close();
|
||||
|
// });
|
||||
|
// });
|
||||
|
|
||||
|
WeakReferenceMessenger.Default.Register<Message_BindingPurchaseProductClose>(this, (o, x) => |
||||
|
{ |
||||
|
this.Dispatcher.Invoke(() => |
||||
|
{ |
||||
|
this.DialogResult = x.Value; |
||||
|
this.Close(); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
this.Unloaded += BindingPurchaseProduct_Unloaded; |
||||
|
} |
||||
|
|
||||
|
private void BindingPurchaseProduct_Unloaded(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
//Messenger.Default.Unregister(this);
|
||||
|
WeakReferenceMessenger.Default.UnregisterAll(this); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public class Message_BindingPurchaseProductClose : ValueChangedMessage<bool> |
||||
|
{ |
||||
|
public Message_BindingPurchaseProductClose(bool value) : base(value) |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,332 @@ |
|||||
|
<Page x:Class="BBWYB.Client.Views.Ware.WareManager" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
|
xmlns:b="http://schemas.microsoft.com/xaml/behaviors" |
||||
|
xmlns:local="clr-namespace:BBWYB.Client.Views.Ware" |
||||
|
xmlns:c="clr-namespace:SJ.Controls;assembly=SJ.Controls" |
||||
|
xmlns:ctr="clr-namespace:BBWYB.Client.Converters" |
||||
|
mc:Ignorable="d" |
||||
|
d:DesignHeight="1080" d:DesignWidth="1920" |
||||
|
Title="WareManager" |
||||
|
DataContext="{Binding WareManager,Source={StaticResource Locator}}"> |
||||
|
<b:Interaction.Triggers> |
||||
|
<b:EventTrigger EventName="Loaded"> |
||||
|
<b:InvokeCommandAction Command="{Binding LoadCommand}"/> |
||||
|
</b:EventTrigger> |
||||
|
</b:Interaction.Triggers> |
||||
|
<Page.Resources> |
||||
|
<ctr:ItemHeightConverter x:Key="itemHeightConverter"/> |
||||
|
<ctr:MultiParameterTransferConverter x:Key="mptConverter"/> |
||||
|
</Page.Resources> |
||||
|
<Grid> |
||||
|
<c:RoundWaitProgress Play="{Binding IsLoading}" Panel.ZIndex="999"/> |
||||
|
<Grid Margin="5,0"> |
||||
|
<Grid.RowDefinitions> |
||||
|
<RowDefinition Height="40"/> |
||||
|
<RowDefinition Height="5"/> |
||||
|
<RowDefinition Height="30"/> |
||||
|
<RowDefinition/> |
||||
|
<RowDefinition Height="30"/> |
||||
|
</Grid.RowDefinitions> |
||||
|
<StackPanel Orientation="Horizontal" Background="{StaticResource Border.Background}"> |
||||
|
<TextBlock Text="商品名称" VerticalAlignment="Center" Margin="5,0,0,0"/> |
||||
|
<c:BTextBox Width="150" Margin="5,0,0,0" Text="{Binding SearchProductName}" WaterRemark="模糊搜索"/> |
||||
|
<TextBlock Text="货号" VerticalAlignment="Center" Margin="5,0,0,0"/> |
||||
|
<c:BTextBox Width="150" Margin="5,0,0,0" Text="{Binding SearchProductItem}" WaterRemark="精确匹配"/> |
||||
|
<TextBlock Text="SPU" VerticalAlignment="Center" Margin="5,0,0,0"/> |
||||
|
<c:BTextBox Width="150" Margin="5,0,0,0" Text="{Binding SearchSpu}" WaterRemark="精确匹配"/> |
||||
|
<TextBlock Text="SKU" VerticalAlignment="Center" Margin="5,0,0,0"/> |
||||
|
<c:BTextBox Width="150" Margin="5,0,0,0" Text="{Binding SearchSku}" WaterRemark="精确匹配"/> |
||||
|
<c:BButton Content="搜索" Padding="10,0" Margin="5,0,0,0" |
||||
|
Command="{Binding SearchCommand}"/> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<Border Grid.Row="2" BorderBrush="{StaticResource Border.Brush}" BorderThickness="1,1,1,0" |
||||
|
Background="#F2F2F2"> |
||||
|
<Grid> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="300"/> |
||||
|
<ColumnDefinition Width="80"/> |
||||
|
<ColumnDefinition/> |
||||
|
<ColumnDefinition/> |
||||
|
<ColumnDefinition/> |
||||
|
<ColumnDefinition/> |
||||
|
<ColumnDefinition Width="50"/> |
||||
|
<ColumnDefinition Width="170"/> |
||||
|
<ColumnDefinition Width="110"/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
<TextBlock Text="商品信息" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="采购平台" Grid.Column="1" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="商品1" Grid.Column="2" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="商品2" Grid.Column="3" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="商品3" Grid.Column="4" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="商品4" Grid.Column="5" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="毛利" Grid.Column="6" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="采购商" Grid.Column="7" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="操作" Grid.Column="8" Style="{StaticResource middleTextBlock}"/> |
||||
|
|
||||
|
|
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="1"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="2"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="3"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="4"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="5"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="6"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="7"/> |
||||
|
|
||||
|
</Grid> |
||||
|
</Border> |
||||
|
|
||||
|
<ListBox x:Name="listbox_productList" |
||||
|
Grid.Row="3" |
||||
|
ItemsSource="{Binding ProductList}" |
||||
|
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" |
||||
|
Foreground="{StaticResource Text.Color}" |
||||
|
BorderThickness="1,1,1,0" |
||||
|
BorderBrush="{StaticResource Border.Brush}"> |
||||
|
<ListBox.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<Grid Width="{Binding ActualWidth,ElementName=listbox_productList}"> |
||||
|
<Grid.RowDefinitions> |
||||
|
<RowDefinition Height="30"/> |
||||
|
<RowDefinition/> |
||||
|
</Grid.RowDefinitions> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition/> |
||||
|
<ColumnDefinition Width="280"/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
|
||||
|
<Grid Background="#F2F2F2" Grid.ColumnSpan="2"> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock VerticalAlignment="Center" Margin="5,0,0,0"> |
||||
|
<Run Text="SPU:"/> |
||||
|
<Run Text="{Binding Id}"/> |
||||
|
</TextBlock> |
||||
|
<TextBlock VerticalAlignment="Center" Margin="5,0,0,0"> |
||||
|
<Run Text="货号:"/> |
||||
|
<Run Text="{Binding ProductItemNum}"/> |
||||
|
</TextBlock> |
||||
|
</StackPanel> |
||||
|
<c:BButton HorizontalAlignment="Right" Content="添加采购商" Width="110" |
||||
|
Command="{Binding DataContext.AddPurchaserCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}}}" CommandParameter="{Binding }"/> |
||||
|
</Grid> |
||||
|
|
||||
|
<ListBox x:Name="listbox_sku" Grid.Row="1" ItemsSource="{Binding SkuList}" |
||||
|
Style="{StaticResource NoScrollViewListBoxStyle}" |
||||
|
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" |
||||
|
Foreground="{StaticResource Text.Color}" |
||||
|
BorderThickness="0,1,0,0" |
||||
|
BorderBrush="{StaticResource Border.Brush}"> |
||||
|
<ListBox.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<Border BorderThickness="0,0,0,0" BorderBrush="{StaticResource Border.Brush}" |
||||
|
Width="{Binding ActualWidth,ElementName=listbox_sku}"> |
||||
|
<Grid Height="150"> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="300"/> |
||||
|
<ColumnDefinition Width="80"/> |
||||
|
<ColumnDefinition/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
<!--SKU信息--> |
||||
|
<Grid> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="90"/> |
||||
|
<ColumnDefinition/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
|
||||
|
<c:BAsyncImage UrlSource="{Binding Logo}" Width="80" DecodePixelWidth="80" |
||||
|
VerticalAlignment="Top" Margin="0,5,0,0"/> |
||||
|
|
||||
|
<StackPanel Grid.Column="1" Orientation="Vertical" Margin="0,5,0,0"> |
||||
|
<TextBlock> |
||||
|
<Run Text="售价:" /> |
||||
|
<Run Text="{Binding Price}"/> |
||||
|
</TextBlock> |
||||
|
<TextBlock> |
||||
|
<Run Text="SKU:" /> |
||||
|
<Run Text="{Binding Id}"/> |
||||
|
</TextBlock> |
||||
|
<TextBlock TextWrapping="Wrap"> |
||||
|
<Run Text="SKU名称:" /> |
||||
|
<Run Text="{Binding Title}"/> |
||||
|
</TextBlock> |
||||
|
</StackPanel> |
||||
|
</Grid> |
||||
|
|
||||
|
<!--采购方案--> |
||||
|
<ListBox x:Name="listbox_purchaseSchemeList" ItemsSource="{Binding PurchaseSchemeList}" |
||||
|
Grid.Column="2" |
||||
|
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" |
||||
|
BorderThickness="1,0" |
||||
|
BorderBrush="{StaticResource Border.Brush}" |
||||
|
Style="{StaticResource NoScrollViewListBoxStyle}"> |
||||
|
<ListBox.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<Grid Width="{Binding ActualWidth,ElementName= listbox_purchaseSchemeList}" |
||||
|
Height="30"> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="0.15*"/> |
||||
|
<ColumnDefinition Width="0.1*"/> |
||||
|
<ColumnDefinition Width="0.15*"/> |
||||
|
<ColumnDefinition Width="0.1*"/> |
||||
|
<ColumnDefinition Width="0.15*"/> |
||||
|
<ColumnDefinition Width="0.1*"/> |
||||
|
<ColumnDefinition Width="0.15*"/> |
||||
|
<ColumnDefinition Width="0.1*"/> |
||||
|
<ColumnDefinition Width="50"/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
<TextBlock Text="{Binding PurchaseProductId1}" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Grid.Column="1" Style="{StaticResource middleTextBlock}" |
||||
|
Foreground="{StaticResource Text.Link.Color}"> |
||||
|
<Run Text="Sku*"/> |
||||
|
<Run Text="{Binding PurchaseProductSkuCount1}"/> |
||||
|
</TextBlock> |
||||
|
<TextBlock Text="{Binding PurchaseProductId2}" Grid.Column="2" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Grid.Column="3" Style="{StaticResource middleTextBlock}" Foreground="{StaticResource Text.Link.Color}" |
||||
|
Visibility="{Binding PurchaseProductSkuCount2,Converter={StaticResource objConverter},ConverterParameter=0:Collapsed:Visible}"> |
||||
|
<Run Text="Sku*"/> |
||||
|
<Run Text="{Binding PurchaseProductSkuCount2}"/> |
||||
|
</TextBlock> |
||||
|
|
||||
|
<TextBlock Text="{Binding PurchaseProductId3}" Grid.Column="4" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Grid.Column="5" Style="{StaticResource middleTextBlock}" Foreground="{StaticResource Text.Link.Color}" |
||||
|
Visibility="{Binding PurchaseProductSkuCount3,Converter={StaticResource objConverter},ConverterParameter=0:Collapsed:Visible}"> |
||||
|
<Run Text="Sku*"/> |
||||
|
<Run Text="{Binding PurchaseProductSkuCount3}"/> |
||||
|
</TextBlock> |
||||
|
|
||||
|
<TextBlock Text="{Binding PurchaseProductId4}" Grid.Column="6" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Grid.Column="7" Style="{StaticResource middleTextBlock}" Foreground="{StaticResource Text.Link.Color}" |
||||
|
Visibility="{Binding PurchaseProductSkuCount4,Converter={StaticResource objConverter},ConverterParameter=0:Collapsed:Visible}"> |
||||
|
<Run Text="Sku*"/> |
||||
|
<Run Text="{Binding PurchaseProductSkuCount4}"/> |
||||
|
</TextBlock> |
||||
|
<Border Grid.Column="8"> |
||||
|
<!--毛利率--> |
||||
|
</Border> |
||||
|
|
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="1"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="2"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="3"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="4"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="5"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="6"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="7"/> |
||||
|
<Border Height="1" Grid.ColumnSpan="9" Background="{StaticResource Border.Brush}" VerticalAlignment="Bottom"/> |
||||
|
</Grid> |
||||
|
</DataTemplate> |
||||
|
</ListBox.ItemTemplate> |
||||
|
</ListBox> |
||||
|
|
||||
|
<Border Height="1" VerticalAlignment="Bottom" Background="{StaticResource Border.Brush}"/> |
||||
|
<Border Grid.Column="2" Height="1" VerticalAlignment="Bottom" Background="{StaticResource Border.Brush}"/> |
||||
|
</Grid> |
||||
|
</Border> |
||||
|
|
||||
|
</DataTemplate> |
||||
|
</ListBox.ItemTemplate> |
||||
|
</ListBox> |
||||
|
|
||||
|
<ListBox x:Name="listbox_purchasePlatform" ItemsSource="{Binding PurchasePlatformList}" |
||||
|
SelectedItem="{Binding SelectedPurchasePlatformModel,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" |
||||
|
Style="{StaticResource NoScrollViewListBoxStyle}" |
||||
|
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" |
||||
|
Grid.Row="1" |
||||
|
Width="80" |
||||
|
HorizontalAlignment="Left" |
||||
|
Margin="300,0,0,0" BorderThickness="1,0,0,1" BorderBrush="{StaticResource Border.Brush}"> |
||||
|
<ListBox.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<Grid x:Name="grid_purchasePlatform" Width="{Binding ActualWidth,ElementName=listbox_purchasePlatform,Converter={StaticResource widthConverter},ConverterParameter=7}" Margin="5,5,5,0" Height="25" |
||||
|
Background="{StaticResource Button.Normal.Background}"> |
||||
|
<TextBlock x:Name="txt_Platform" Text="{Binding }" HorizontalAlignment="Center" VerticalAlignment="Center" |
||||
|
Foreground="{StaticResource Text.Color}"/> |
||||
|
<b:Interaction.Triggers> |
||||
|
<b:EventTrigger EventName="MouseLeftButtonDown"> |
||||
|
<b:InvokeCommandAction Command="{Binding DataContext.SwitchPurchasePlatformCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}"> |
||||
|
<b:InvokeCommandAction.CommandParameter> |
||||
|
<MultiBinding Converter="{StaticResource mptConverter}"> |
||||
|
<Binding Path="DataContext.Id" RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1}"/> |
||||
|
<Binding Path="."/> |
||||
|
</MultiBinding> |
||||
|
</b:InvokeCommandAction.CommandParameter> |
||||
|
</b:InvokeCommandAction> |
||||
|
</b:EventTrigger> |
||||
|
</b:Interaction.Triggers> |
||||
|
</Grid> |
||||
|
<DataTemplate.Triggers> |
||||
|
<DataTrigger Binding="{Binding IsSelected,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}}}" |
||||
|
Value="True"> |
||||
|
<Setter TargetName="grid_purchasePlatform" Property="Background" Value="{StaticResource Button.Selected.Background}"/> |
||||
|
<Setter TargetName="txt_Platform" Property="Foreground" Value="White"/> |
||||
|
</DataTrigger> |
||||
|
</DataTemplate.Triggers> |
||||
|
</DataTemplate> |
||||
|
</ListBox.ItemTemplate> |
||||
|
</ListBox> |
||||
|
|
||||
|
<ListBox x:Name="listbox_purchaser" ItemsSource="{Binding PurchaserList}" |
||||
|
Grid.Row="1" Grid.Column="1" |
||||
|
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" |
||||
|
Style="{StaticResource NoScrollViewListBoxStyle}" |
||||
|
BorderBrush="{StaticResource Border.Brush}" |
||||
|
BorderThickness="0,1"> |
||||
|
<ListBox.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<Border Width="{Binding ActualWidth,ElementName=listbox_purchaser}" |
||||
|
Height="{Binding SkuUseCount,Converter={StaticResource itemHeightConverter},ConverterParameter=30}" |
||||
|
BorderBrush="{StaticResource Border.Brush}" |
||||
|
BorderThickness="0,0,0,1"> |
||||
|
<Grid> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition/> |
||||
|
<ColumnDefinition Width="110"/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
<Border BorderBrush="{StaticResource Border.Brush}" BorderThickness="0,0,1,0"> |
||||
|
<TextBlock Text="{Binding Name}" |
||||
|
VerticalAlignment="Center" |
||||
|
HorizontalAlignment="Center" |
||||
|
ToolTip="{Binding Name}"/> |
||||
|
</Border> |
||||
|
|
||||
|
<Grid Grid.Column="1"> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="0.65*"/> |
||||
|
<ColumnDefinition Width="0.35*"/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
<c:BButton Content="编辑采购商" Style="{StaticResource LinkButton}" |
||||
|
Command="{Binding DataContext.EditPurchaserCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" |
||||
|
CommandParameter="{Binding }"/> |
||||
|
<c:BButton Content="删除" Grid.Column="1" Style="{StaticResource LinkButton}" |
||||
|
Command="{Binding DataContext.DeletePurchaserCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" |
||||
|
CommandParameter="{Binding }"/> |
||||
|
</Grid> |
||||
|
</Grid> |
||||
|
</Border> |
||||
|
|
||||
|
</DataTemplate> |
||||
|
</ListBox.ItemTemplate> |
||||
|
</ListBox> |
||||
|
|
||||
|
</Grid> |
||||
|
</DataTemplate> |
||||
|
</ListBox.ItemTemplate> |
||||
|
</ListBox> |
||||
|
|
||||
|
<c:PageControl PageIndex="{Binding PageIndex}" |
||||
|
PageSize="5" |
||||
|
RecordCount="{Binding ProductCount}" |
||||
|
Grid.Row="4"> |
||||
|
<b:Interaction.Triggers> |
||||
|
<b:EventTrigger EventName="OnPageIndexChanged"> |
||||
|
<b:InvokeCommandAction Command="{Binding ProductPageIndexChangedCommand}" PassEventArgsToCommand="True"/> |
||||
|
</b:EventTrigger> |
||||
|
</b:Interaction.Triggers> |
||||
|
</c:PageControl> |
||||
|
</Grid> |
||||
|
</Grid> |
||||
|
</Page> |
@ -0,0 +1,50 @@ |
|||||
|
using CommunityToolkit.Mvvm.Messaging; |
||||
|
using CommunityToolkit.Mvvm.Messaging.Messages; |
||||
|
using SJ.Controls.Extensions; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Controls; |
||||
|
|
||||
|
namespace BBWYB.Client.Views.Ware |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// WareManager.xaml 的交互逻辑
|
||||
|
/// </summary>
|
||||
|
public partial class WareManager : Page |
||||
|
{ |
||||
|
private ScrollViewer scrollviewer_ProductList; |
||||
|
|
||||
|
public WareManager() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
this.Loaded += WareManager_Loaded; |
||||
|
this.Unloaded += WareManager_Unloaded; |
||||
|
//Messenger.Default.Register<string>(this, "WareManager_ProductListScrollToTop", (x) =>
|
||||
|
//{
|
||||
|
// scrollviewer_ProductList.Dispatcher.Invoke(() => scrollviewer_ProductList.ScrollToTop());
|
||||
|
//});
|
||||
|
|
||||
|
WeakReferenceMessenger.Default.Register<Message_WareManager_ProductListScrollToTop>(this, (o, x) => |
||||
|
{ |
||||
|
scrollviewer_ProductList.Dispatcher.Invoke(() => scrollviewer_ProductList.ScrollToTop()); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void WareManager_Unloaded(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
//Messenger.Default.Unregister(this);
|
||||
|
WeakReferenceMessenger.Default.UnregisterAll(this); |
||||
|
} |
||||
|
|
||||
|
private void WareManager_Loaded(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
scrollviewer_ProductList = listbox_productList.FindFirstVisualChild<ScrollViewer>(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public class Message_WareManager_ProductListScrollToTop : ValueChangedMessage<object> |
||||
|
{ |
||||
|
public Message_WareManager_ProductListScrollToTop(object value) : base(value) |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,423 @@ |
|||||
|
<Page x:Class="BBWYB.Client.Views.Ware.WareStock" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
|
xmlns:local="clr-namespace:BBWYB.Client.Views.Ware" |
||||
|
xmlns:b="http://schemas.microsoft.com/xaml/behaviors" |
||||
|
xmlns:sys="clr-namespace:System;assembly=mscorlib" |
||||
|
mc:Ignorable="d" |
||||
|
d:DesignHeight="450" d:DesignWidth="1300" |
||||
|
DataContext="{Binding WareStock,Source={StaticResource Locator}}" |
||||
|
xmlns:c="clr-namespace:SJ.Controls;assembly=SJ.Controls" |
||||
|
xmlns:ts="clr-namespace:BBWYB.Client.TemplateSelectors" |
||||
|
xmlns:clientModel="clr-namespace:BBWYB.Client.Models" |
||||
|
xmlns:ctr="clr-namespace:BBWYB.Client.Converters" |
||||
|
Title="WareStock"> |
||||
|
<b:Interaction.Triggers> |
||||
|
<b:EventTrigger EventName="Loaded"> |
||||
|
<b:InvokeCommandAction Command="{Binding LoadCommand}"/> |
||||
|
</b:EventTrigger> |
||||
|
</b:Interaction.Triggers> |
||||
|
<Page.Resources> |
||||
|
<ObjectDataProvider x:Key="platformProvider" MethodName="GetValues" ObjectType="{x:Type sys:Enum}"> |
||||
|
<ObjectDataProvider.MethodParameters> |
||||
|
<x:Type TypeName="clientModel:Platform"/> |
||||
|
</ObjectDataProvider.MethodParameters> |
||||
|
</ObjectDataProvider> |
||||
|
<ctr:PurchaseOrderDelBtnConverter x:Key="poDelConverter"/> |
||||
|
<ctr:PurchaseOrderEditBtnConverter x:Key="poEditConverter"/> |
||||
|
|
||||
|
<DataTemplate x:Key="purchaseOrderTemplate_normal"> |
||||
|
<Grid Width="{Binding ActualWidth,ElementName= listbox_purchaseOrderList}" |
||||
|
Height="30"> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="80"/> |
||||
|
<ColumnDefinition Width="1*"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="50"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="80"/> |
||||
|
<ColumnDefinition Width="70"/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
<TextBlock Text="{Binding PurchasePlatform}" Style="{StaticResource middleTextBlock}"/> |
||||
|
|
||||
|
<TextBlock Text="{Binding PurchaseOrderId}" Grid.Column="1" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="{Binding SingleSkuAmount,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Column="2" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="{Binding SingleFreight,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Column="3" Style="{StaticResource middleTextBlock}"/> |
||||
|
|
||||
|
<TextBlock Text="{Binding SingleFirstFreight}" Grid.Column="4" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="{Binding SingleInStorageAmount}" Grid.Column="5" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="{Binding SingleOutStorageAmount}" Grid.Column="6" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="{Binding SingleRefundInStorageAmount}" Grid.Column="7" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="{Binding SingleConsumableAmount,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Column="8" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="{Binding SingleStorageAmount,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Column="9" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="{Binding SingleDeliveryFreight}" Grid.Column="10" Style="{StaticResource middleTextBlock}"/> |
||||
|
|
||||
|
<TextBlock Text="{Binding PurchaseQuantity,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Column="11" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="{Binding RemainingQuantity,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Column="12" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="{Binding UnitCost,Mode=OneWay}" Grid.Column="13" Style="{StaticResource middleTextBlock}" Foreground="Gray"/> |
||||
|
<TextBlock Text="{Binding CreateTime,StringFormat=yyyy-MM-dd}" Grid.Column="14" Style="{StaticResource middleTextBlock}"/> |
||||
|
|
||||
|
<StackPanel Grid.Column="15" HorizontalAlignment="Center" Orientation="Horizontal"> |
||||
|
<c:BButton Content="编辑" Style="{StaticResource LinkButton}" |
||||
|
Command="{Binding DataContext.EditPurchaseOrderCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" |
||||
|
CommandParameter="{Binding }"> |
||||
|
</c:BButton> |
||||
|
|
||||
|
<c:BButton Content="删除" Style="{StaticResource LinkButton}" Margin="5,0,0,0" |
||||
|
Command="{Binding DataContext.DeletePurchaseOrderCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" CommandParameter="{Binding }"> |
||||
|
</c:BButton> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="1"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="2"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="3"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="4"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="5"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="6"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="7"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="8"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="9"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="10"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="11"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="12"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="13"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="14"/> |
||||
|
<Border Height="1" Grid.ColumnSpan="16" Background="{StaticResource Border.Brush}" VerticalAlignment="Bottom"/> |
||||
|
</Grid> |
||||
|
</DataTemplate> |
||||
|
<DataTemplate x:Key="purchaseOrderTemplate_edit"> |
||||
|
<Grid Width="{Binding ActualWidth,ElementName= listbox_purchaseOrderList}" |
||||
|
Height="30"> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="80"/> |
||||
|
<ColumnDefinition Width="1*"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="50"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="80"/> |
||||
|
<ColumnDefinition Width="70"/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
<!--<c:BTextBox Text="{Binding PurchasePlatform}"/>--> |
||||
|
<ComboBox ItemsSource="{Binding Source={StaticResource platformProvider}}" |
||||
|
SelectedItem="{Binding PurchasePlatform}" |
||||
|
BorderThickness="0" |
||||
|
VerticalContentAlignment="Center" |
||||
|
FocusVisualStyle="{x:Null}"/> |
||||
|
|
||||
|
<c:BTextBox Text="{Binding PurchaseOrderId}" Grid.Column="1" BorderThickness="0"/> |
||||
|
<c:BTextBox Text="{Binding SingleSkuAmount,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource inputNumberConverter}}" |
||||
|
Grid.Column="2" BorderThickness="0"/> |
||||
|
<c:BTextBox Text="{Binding SingleFreight,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource inputNumberConverter}}" Grid.Column="3" BorderThickness="0"/> |
||||
|
|
||||
|
<c:BTextBox Text="{Binding SingleFirstFreight,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource inputNumberConverter}}" Grid.Column="4" BorderThickness="0"/> |
||||
|
<c:BTextBox Text="{Binding SingleInStorageAmount,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource inputNumberConverter}}" Grid.Column="5" BorderThickness="0"/> |
||||
|
<c:BTextBox Text="{Binding SingleOutStorageAmount,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource inputNumberConverter}}" Grid.Column="6" BorderThickness="0"/> |
||||
|
<c:BTextBox Text="{Binding SingleRefundInStorageAmount,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource inputNumberConverter}}" Grid.Column="7" BorderThickness="0"/> |
||||
|
<c:BTextBox Text="{Binding SingleConsumableAmount,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource inputNumberConverter}}" Grid.Column="8" BorderThickness="0"/> |
||||
|
<c:BTextBox Text="{Binding SingleStorageAmount,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource inputNumberConverter}}" Grid.Column="9" BorderThickness="0"/> |
||||
|
<c:BTextBox Text="{Binding SingleDeliveryFreight,Converter={StaticResource inputNumberConverter}}" Grid.Column="10" BorderThickness="0"/> |
||||
|
|
||||
|
<c:BTextBox Text="{Binding PurchaseQuantity,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Column="11" BorderThickness="0"/> |
||||
|
<c:BTextBox Text="{Binding RemainingQuantity,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Column="12" BorderThickness="0"/> |
||||
|
<TextBlock Text="{Binding UnitCost,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" Grid.Column="13" Style="{StaticResource middleTextBlock}" Foreground="Gray"/> |
||||
|
<TextBlock Text="{Binding CreateTime,StringFormat=yyyy-MM-dd}" Grid.Column="14" Style="{StaticResource middleTextBlock}" Foreground="Gray"/> |
||||
|
|
||||
|
<StackPanel Grid.Column="15" HorizontalAlignment="Center" Orientation="Horizontal"> |
||||
|
<c:BButton Content="保存" Style="{StaticResource LinkButton}" |
||||
|
Command="{Binding DataContext.SavePurchaseOrderCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" |
||||
|
CommandParameter="{Binding }" /> |
||||
|
<c:BButton Content="删除" Style="{StaticResource LinkButton}" Margin="5,0,0,0" |
||||
|
Command="{Binding DataContext.DeletePurchaseOrderCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" CommandParameter="{Binding }"> |
||||
|
|
||||
|
</c:BButton> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="1"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="2"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="3"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="4"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="5"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="6"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="7"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="8"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="9"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="10"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="11"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="12"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="13"/> |
||||
|
<Border Height="1" Grid.ColumnSpan="16" Background="{StaticResource Border.Brush}" VerticalAlignment="Bottom"/> |
||||
|
</Grid> |
||||
|
</DataTemplate> |
||||
|
</Page.Resources> |
||||
|
<Grid> |
||||
|
<c:RoundWaitProgress Play="{Binding IsLoading}" Panel.ZIndex="999"/> |
||||
|
<Grid Margin="5,0"> |
||||
|
<Grid.RowDefinitions> |
||||
|
<RowDefinition Height="40"/> |
||||
|
<RowDefinition Height="5"/> |
||||
|
<RowDefinition Height="30"/> |
||||
|
<RowDefinition/> |
||||
|
<RowDefinition Height="30"/> |
||||
|
</Grid.RowDefinitions> |
||||
|
<StackPanel Orientation="Horizontal" Background="{StaticResource Border.Background}"> |
||||
|
<TextBlock Text="SPU" VerticalAlignment="Center" Margin="5,0,0,0"/> |
||||
|
<c:BTextBox Width="150" Margin="5,0,0,0" Text="{Binding SearchSpu}" WaterRemark="精确匹配"/> |
||||
|
<TextBlock Text="SKU" VerticalAlignment="Center" Margin="5,0,0,0"/> |
||||
|
<c:BTextBox Width="150" Margin="5,0,0,0" Text="{Binding SearchSku}" WaterRemark="精确匹配"/> |
||||
|
<TextBlock Text="货号" VerticalAlignment="Center" Margin="5,0,0,0"/> |
||||
|
<c:BTextBox Width="150" Margin="5,0,0,0" Text="{Binding SearchProductItem}" WaterRemark="精确匹配"/> |
||||
|
<TextBlock Text="采购单号" VerticalAlignment="Center" Margin="5,0,0,0"/> |
||||
|
<c:BTextBox Width="150" Margin="5,0,0,0" Text="{Binding SearchPurchaseOrder}" WaterRemark="精确匹配"/> |
||||
|
<c:BButton Content="搜索" Padding="10,0" Margin="5,0,0,0" |
||||
|
Command="{Binding SearchCommand}"/> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<Border Grid.Row="2" BorderBrush="{StaticResource Border.Brush}" BorderThickness="1,1,1,0" |
||||
|
Background="#F2F2F2"> |
||||
|
<Grid> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="300"/> |
||||
|
<ColumnDefinition Width="80"/> |
||||
|
<ColumnDefinition Width="80"/> |
||||
|
<ColumnDefinition Width="1*"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="50"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="60"/> |
||||
|
<ColumnDefinition Width="80"/> |
||||
|
<ColumnDefinition Width="70"/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
<TextBlock Text="商品信息" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="仓储平台" Grid.Column="1" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="采购平台" Grid.Column="2" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="采购订单号" Grid.Column="3" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="采购单价" Grid.Column="4" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Grid.Column="5" Style="{StaticResource middleTextBlock}" TextAlignment="Center"> |
||||
|
<Run Text="采购运"/> |
||||
|
<LineBreak/> |
||||
|
<Run Text="单价"/> |
||||
|
</TextBlock> |
||||
|
<TextBlock Text="头程单价" Grid.Column="6" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="入仓单价" Grid.Column="7" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="出仓单价" Grid.Column="8" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Grid.Column="9" Style="{StaticResource middleTextBlock}" TextAlignment="Center"> |
||||
|
<Run Text="退货"/> |
||||
|
<LineBreak/> |
||||
|
<Run Text="入仓单价"/> |
||||
|
</TextBlock> |
||||
|
<TextBlock Text="耗材单价" Grid.Column="10" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="仓储单价" Grid.Column="11" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Grid.Column="12" Style="{StaticResource middleTextBlock}" TextAlignment="Center"> |
||||
|
<Run Text="销售运"/> |
||||
|
<LineBreak/> |
||||
|
<Run Text="单价"/> |
||||
|
</TextBlock> |
||||
|
<TextBlock Text="库存" Grid.Column="13" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="剩余库存" Grid.Column="14" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="均摊单价" Grid.Column="15" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="采购时间" Grid.Column="16" Style="{StaticResource middleTextBlock}"/> |
||||
|
<TextBlock Text="操作" Grid.Column="17" Style="{StaticResource middleTextBlock}"/> |
||||
|
|
||||
|
|
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="1"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="2"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="3"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="4"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="5"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="6"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="7"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="8"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="9"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="10"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="11"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="12"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="13"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="14"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="15"/> |
||||
|
<Border Width="1" HorizontalAlignment="Right" Background="{StaticResource Border.Brush}" Grid.Column="16"/> |
||||
|
</Grid> |
||||
|
</Border> |
||||
|
|
||||
|
<ListBox x:Name="listbox_productList" |
||||
|
Grid.Row="3" |
||||
|
ItemsSource="{Binding ProductList}" |
||||
|
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" |
||||
|
Foreground="{StaticResource Text.Color}" |
||||
|
BorderThickness="1,1,1,0" |
||||
|
BorderBrush="{StaticResource Border.Brush}"> |
||||
|
<ListBox.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<Grid Width="{Binding ActualWidth,ElementName=listbox_productList}"> |
||||
|
<Grid.RowDefinitions> |
||||
|
<RowDefinition Height="30"/> |
||||
|
<RowDefinition/> |
||||
|
</Grid.RowDefinitions> |
||||
|
|
||||
|
<Grid Background="#F2F2F2" Grid.ColumnSpan="2"> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock VerticalAlignment="Center" Margin="5,0,0,0"> |
||||
|
<Run Text="SPU:"/> |
||||
|
<Run Text="{Binding Id}"/> |
||||
|
</TextBlock> |
||||
|
<TextBlock VerticalAlignment="Center" Margin="5,0,0,0"> |
||||
|
<Run Text="货号:"/> |
||||
|
<Run Text="{Binding ProductItemNum}"/> |
||||
|
</TextBlock> |
||||
|
</StackPanel> |
||||
|
<c:BButton HorizontalAlignment="Right" Content="采购库存" Width="110" |
||||
|
Command="{Binding DataContext.AddPurchaserOrderCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}}}" CommandParameter="{Binding }"/> |
||||
|
</Grid> |
||||
|
<!--<Border Grid.ColumnSpan="2" BorderBrush="{StaticResource Border.Brush}" BorderThickness="0,0,0,1"/>--> |
||||
|
|
||||
|
<ListBox x:Name="listbox_sku" Grid.Row="1" ItemsSource="{Binding SkuList}" |
||||
|
Style="{StaticResource NoScrollViewListBoxStyle}" |
||||
|
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" |
||||
|
Foreground="{StaticResource Text.Color}" |
||||
|
BorderThickness="0,1,0,0" |
||||
|
BorderBrush="{StaticResource Border.Brush}"> |
||||
|
<ListBox.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource Border.Brush}" |
||||
|
Width="{Binding ActualWidth,ElementName=listbox_sku}"> |
||||
|
<Grid Height="150"> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="299"/> |
||||
|
<!--350--> |
||||
|
<ColumnDefinition Width="80"/> |
||||
|
<ColumnDefinition/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
<!--SKU信息--> |
||||
|
<Grid> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="90"/> |
||||
|
<ColumnDefinition/> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
|
||||
|
<c:BAsyncImage UrlSource="{Binding Logo}" Width="80" DecodePixelWidth="80" |
||||
|
VerticalAlignment="Top" Margin="0,5,0,0"/> |
||||
|
|
||||
|
<StackPanel Grid.Column="1" Orientation="Vertical" Margin="0,5,0,0"> |
||||
|
<TextBlock> |
||||
|
<Run Text="售价:" /> |
||||
|
<Run Text="{Binding Price}"/> |
||||
|
</TextBlock> |
||||
|
<TextBlock> |
||||
|
<Run Text="SKU:" /> |
||||
|
<Run Text="{Binding Id}"/> |
||||
|
</TextBlock> |
||||
|
<TextBlock TextWrapping="Wrap"> |
||||
|
<Run Text="SKU名称:" /> |
||||
|
<Run Text="{Binding Title}"/> |
||||
|
</TextBlock> |
||||
|
</StackPanel> |
||||
|
</Grid> |
||||
|
|
||||
|
<!--仓储平台--> |
||||
|
<ListBox x:Name="listbox_storageType" Grid.Column="1" |
||||
|
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" |
||||
|
Style="{StaticResource NoScrollViewListBoxStyle}" |
||||
|
BorderBrush="{StaticResource Border.Brush}" |
||||
|
BorderThickness="1,0,0,0" |
||||
|
ItemsSource="{Binding StorageList}" |
||||
|
SelectedItem="{Binding SelectedStorageModel}"> |
||||
|
<ListBox.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<Grid x:Name="grid_storageType" Width="{Binding ActualWidth,ElementName=listbox_storageType,Converter={StaticResource widthConverter},ConverterParameter=7}" Margin="5,5,5,0" Height="25" |
||||
|
Background="{StaticResource Button.Normal.Background}"> |
||||
|
<TextBlock x:Name="txt_storageType" Text="{Binding StorageType}" HorizontalAlignment="Center" VerticalAlignment="Center" |
||||
|
Foreground="{StaticResource Text.Color}"/> |
||||
|
<b:Interaction.Triggers> |
||||
|
<b:EventTrigger EventName="MouseLeftButtonDown"> |
||||
|
<b:InvokeCommandAction Command="{Binding DataContext.SwitchStorageTypeCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Page}}}" |
||||
|
CommandParameter="{Binding }"/> |
||||
|
</b:EventTrigger> |
||||
|
</b:Interaction.Triggers> |
||||
|
</Grid> |
||||
|
<DataTemplate.Triggers> |
||||
|
<DataTrigger Binding="{Binding IsSelected,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}}}" |
||||
|
Value="True"> |
||||
|
<Setter TargetName="grid_storageType" Property="Background" Value="{StaticResource Button.Selected.Background}"/> |
||||
|
<Setter TargetName="txt_storageType" Property="Foreground" Value="White"/> |
||||
|
</DataTrigger> |
||||
|
</DataTemplate.Triggers> |
||||
|
</DataTemplate> |
||||
|
</ListBox.ItemTemplate> |
||||
|
</ListBox> |
||||
|
|
||||
|
|
||||
|
<!--采购订单--> |
||||
|
<ListBox x:Name="listbox_purchaseOrderList" ItemsSource="{Binding PurchaseOrderList}" |
||||
|
Grid.Column="2" |
||||
|
BorderThickness="1,0" |
||||
|
BorderBrush="{StaticResource Border.Brush}" |
||||
|
Style="{StaticResource NoScrollViewListBoxStyle}"> |
||||
|
<!-- ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}"--> |
||||
|
<!--<ListBox.ItemTemplateSelector> |
||||
|
<ts:PurchaseOrderDataTemplateSelector NormalTemplate="{StaticResource purchaseOrderTemplate_normal}" |
||||
|
EditTemplate="{StaticResource purchaseOrderTemplate_edit}"/> |
||||
|
</ListBox.ItemTemplateSelector>--> |
||||
|
<ListBox.ItemContainerStyle> |
||||
|
<Style BasedOn="{StaticResource NoBgListBoxItemStyle}" TargetType="ListBoxItem"> |
||||
|
<Setter Property="ContentTemplate" Value="{StaticResource purchaseOrderTemplate_normal}"/> |
||||
|
<Style.Triggers> |
||||
|
<DataTrigger Binding="{Binding IsEdit}" Value="True"> |
||||
|
<Setter Property="ContentTemplate" Value="{StaticResource purchaseOrderTemplate_edit}"/> |
||||
|
</DataTrigger> |
||||
|
</Style.Triggers> |
||||
|
</Style> |
||||
|
</ListBox.ItemContainerStyle> |
||||
|
</ListBox> |
||||
|
</Grid> |
||||
|
</Border> |
||||
|
</DataTemplate> |
||||
|
</ListBox.ItemTemplate> |
||||
|
</ListBox> |
||||
|
</Grid> |
||||
|
</DataTemplate> |
||||
|
</ListBox.ItemTemplate> |
||||
|
</ListBox> |
||||
|
|
||||
|
<c:PageControl PageIndex="{Binding PageIndex}" |
||||
|
PageSize="5" |
||||
|
RecordCount="{Binding ProductCount}" |
||||
|
Grid.Row="4"> |
||||
|
<b:Interaction.Triggers> |
||||
|
<b:EventTrigger EventName="OnPageIndexChanged"> |
||||
|
<b:InvokeCommandAction Command="{Binding ProductPageIndexChangedCommand}" PassEventArgsToCommand="True"/> |
||||
|
</b:EventTrigger> |
||||
|
</b:Interaction.Triggers> |
||||
|
</c:PageControl> |
||||
|
</Grid> |
||||
|
</Grid> |
||||
|
</Page> |
@ -0,0 +1,48 @@ |
|||||
|
using CommunityToolkit.Mvvm.Messaging; |
||||
|
using CommunityToolkit.Mvvm.Messaging.Messages; |
||||
|
using SJ.Controls.Extensions; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Controls; |
||||
|
|
||||
|
namespace BBWYB.Client.Views.Ware |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// WareStock.xaml 的交互逻辑
|
||||
|
/// </summary>
|
||||
|
public partial class WareStock : Page |
||||
|
{ |
||||
|
private ScrollViewer scrollviewer_ProductList; |
||||
|
public WareStock() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
this.Loaded += WareStock_Loaded; |
||||
|
this.Unloaded += WareStock_Unloaded; |
||||
|
//Messenger.Default.Register<string>(this, "WareStock_ProductListScrollToTop", (x) =>
|
||||
|
//{
|
||||
|
// scrollviewer_ProductList.Dispatcher.Invoke(() => scrollviewer_ProductList.ScrollToTop());
|
||||
|
//});
|
||||
|
WeakReferenceMessenger.Default.Register<Message_WareStock_ProductListScrollToTop>(this, (o, x) => |
||||
|
{ |
||||
|
scrollviewer_ProductList.Dispatcher.Invoke(() => scrollviewer_ProductList.ScrollToTop()); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void WareStock_Unloaded(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
//Messenger.Default.Unregister(this);
|
||||
|
WeakReferenceMessenger.Default.UnregisterAll(this); |
||||
|
} |
||||
|
|
||||
|
private void WareStock_Loaded(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
scrollviewer_ProductList = listbox_productList.FindFirstVisualChild<ScrollViewer>(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public class Message_WareStock_ProductListScrollToTop : ValueChangedMessage<object> |
||||
|
{ |
||||
|
public Message_WareStock_ProductListScrollToTop(object value) : base(value) |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net6.0</TargetFramework> |
||||
|
<ImplicitUsings>enable</ImplicitUsings> |
||||
|
<Nullable>enable</Nullable> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
</Project> |
Loading…
Reference in new issue