终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

69 lines
2.9 KiB

  1. using BPASmartClient.FoodStationTest.Model;
  2. using BPASmartClient.Helper;
  3. using Microsoft.Toolkit.Mvvm.ComponentModel;
  4. using Microsoft.Toolkit.Mvvm.Input;
  5. using System;
  6. using System.Collections.ObjectModel;
  7. using System.Linq;
  8. namespace BPASmartClient.FoodStationTest.ViewModel
  9. {
  10. public class RecipeInfosViewModel : ObservableObject
  11. {
  12. public RecipeInfosViewModel()
  13. {
  14. ActionManage.GetInstance.CancelRegister("RecipeInfo");
  15. ActionManage.GetInstance.Register(new Action<object>((o) =>
  16. {
  17. if (o != null && o is RemoteRecipeData rm)
  18. {
  19. RecipeName = rm.RecipeName;
  20. RecipeCode = rm.RecipeCode;
  21. TrayCode = rm.TrayCode;
  22. foreach (var item in rm.RawMaterial)
  23. {
  24. //RawMaterialsInfo.Add(item);
  25. var res = Json<DevicePar>.Data.rawMaterialStockBin.FirstOrDefault(p => p.RawMaterialLocation == item.RawMaterialLocation);
  26. if (res != null && !string.IsNullOrEmpty(res.RawMaterialName))
  27. {
  28. var temp = Json<DevicePar>.Data.BomMaterial.FirstOrDefault(p => p.MaterialCode == res.RawMaterialName);
  29. if (temp != null && !string.IsNullOrEmpty(temp.MaterialName))
  30. {
  31. item.RawMaterialName = temp.MaterialName;
  32. }
  33. }
  34. RawMaterialsInfo.Add(new RemoteRecipeRawMaterial()
  35. {
  36. RawMaterialType = item.RawMaterialType,
  37. RawMaterialName = item.RawMaterialName,
  38. RawMaterialWeight = item.RawMaterialWeight,
  39. RawMaterialLocation = item.RawMaterialLocation,
  40. RawMaterialBarrelNum = item.RawMaterialBarrelNum,
  41. });
  42. }
  43. }
  44. }), "RecipeInfo");
  45. ReturnPage = new RelayCommand(() =>
  46. {
  47. ActionManage.GetInstance.Send("CloseRecipeInfosView");
  48. });
  49. }
  50. public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } }
  51. private string _mRecipeName;
  52. public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
  53. private string _mRecipeCode;
  54. public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } }
  55. private int _mTrayCode;
  56. public RelayCommand ReturnPage { get; set; }
  57. public ObservableCollection<RemoteRecipeRawMaterial> RawMaterialsInfo { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();
  58. }
  59. }