using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Text; using System.Linq; namespace BBWYB.Client.Models { /// /// 采购商品 /// public class PurchaseSchemeProduct : NotifyObject { private string purchaseUrl; private string purchaseProductId; private bool isEditing; private string searchPurchaseSkuName; /// /// 采购商品和采购方案的关系Id /// public long Id { get; set; } public string ProductId { get; set; } public string SkuId { get; set; } public string PurchaseUrl { get => purchaseUrl; set { Set(ref purchaseUrl, value); } } public string PurchaseProductId { get => purchaseProductId; set => purchaseProductId = value; } public bool IsEditing { get => isEditing; set { SearchPurchaseSkuName = string.Empty; Set(ref isEditing, value); } } public IList SkuList { get; set; } public IList SearchSkuList { get; set; } public IList PurchaseSchemeProductSkuList { get; set; } public List SelectedSkuIdList { get; set; } public int PurchaseSkuCount { get { return SelectedSkuIdList.Count(); } } public string SearchPurchaseSkuName { get => searchPurchaseSkuName; set { Set(ref searchPurchaseSkuName, value); } } public PurchaseSchemeProduct() { SkuList = new ObservableCollection(); SearchSkuList = new ObservableCollection(); PurchaseSchemeProductSkuList = new ObservableCollection(); SelectedSkuIdList = new List(); } /// /// /// /// /// 是否转换方案中已选的sku /// public static PurchaseSchemeProduct Convert(PurchaseSchemeProductResponse apiModel) { var model = new PurchaseSchemeProduct() { Id = apiModel.Id, ProductId = apiModel.ProductId, SkuId = apiModel.SkuId, PurchaseProductId = apiModel.PurchaseProductId, PurchaseUrl = apiModel.PurchaseUrl }; model.SelectedSkuIdList.AddRange(apiModel.PurchaseSchemeProductSkuList.Select(s => s.PurchaseSkuId)); return model; } } }