using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using BPA.Helper; using System.Collections.ObjectModel; using BPA.Helper; using BPASmartClient.JXJFoodSmallStation.Model; using BPASmartClient.CustomResource.Pages.Model; namespace BPASmartClient.JXJFoodSmallStation.ViewModel { public class RecipeInfosViewModel : NotifyBase { public RecipeInfosViewModel() { ActionManage.GetInstance.CancelRegister("RecipeInfo"); ActionManage.GetInstance.Register(new Action((o) => { if (o != null && o is RecipeData rm) { RecipeName = rm.RecipeName; RecipeCode = rm.RecipeCode; TrayCode = rm.TrayCode; foreach (var item in rm.RawMaterial) { //RawMaterialsInfo.Add(item); var res = Json.Data.rawMaterialStockBin.FirstOrDefault(p => p.RawMaterialLocation == item.RawMaterialLocation); if (res != null && !string.IsNullOrEmpty(res.RawMaterialName)) { var temp = Json.Data.BomMaterial.FirstOrDefault(p => p.MaterialCode == res.RawMaterialName); if (temp != null && !string.IsNullOrEmpty(temp.MaterialName)) { item.RawMaterialName = temp.MaterialName; } } RawMaterialsInfo.Add(new RemoteRecipeRawMaterial() { RawMaterialType = item.RawMaterialType, RawMaterialName = item.RawMaterialName, RawMaterialWeight = item.RawMaterialWeight, RawMaterialLocation = item.RawMaterialLocation, RawMaterialBarrelNum = item.RawMaterialBarrelNum, }); } foreach (var item1 in rm.WindSend) { // RawMaterialsInfo.Add(new RemoteRecipeRawMaterial() { RawMaterialName= item1.RawMaterialName, RawMaterialLocation= item1.Location,RawMaterialBarrelNum= item1.RawMaterialBarrelNum,RawMaterialWeight= item1.RawMaterialWeight,RawMaterialType=item1.RawMaterialType}); var res = Json.Data.windSendRawMaterial.FirstOrDefault(p => p.Location == item1.Location); if (res != null) { item1.RawMaterialName = res.RawMaterialChineseName; } RawMaterialsInfo.Add(new RemoteRecipeRawMaterial() { RawMaterialType = item1.RawMaterialType, RawMaterialName = item1.RawMaterialName, RawMaterialWeight = item1.RawMaterialWeight, RawMaterialLocation = item1.Location, RawMaterialBarrelNum = item1.RawMaterialBarrelNum, }); } } }), "RecipeInfo"); ReturnPage = new BPARelayCommand(() => { ActionManage.GetInstance.Send("CloseRecipeInfosView"); }); } public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } private string _mRecipeName; public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } } private string _mRecipeCode; public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } } private int _mTrayCode; public BPARelayCommand ReturnPage { get; set; } public ObservableCollection RawMaterialsInfo { get; set; } = new ObservableCollection(); } }