终端一体化运控平台
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.
 
 
 

117 rivejä
3.3 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPA.Helper;
  3. using BPASmartClient.JXJFoodSmallStation.Model;
  4. using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
  5. using BPA.Helper;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Collections.ObjectModel;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace BPASmartClient.JXJFoodSmallStation.ViewModel
  13. {
  14. internal class SelectRecipesViewModel:NotifyBase
  15. {
  16. public SelectRecipesViewModel()
  17. {
  18. AllRecipes = new();
  19. SelectRecipes.Clear();
  20. foreach (var item in Json<LocalRecipeDataColl>.Data.SelectedRecipes)
  21. {
  22. SelectRecipes.Add(item);
  23. }
  24. if (Json<LocalRecipeDataColl>.Data.RemoteRecipes != null)
  25. {
  26. foreach (var item in Json<LocalRecipeDataColl>.Data.RemoteRecipes)
  27. {
  28. AllRecipes.Add(new RecipeDataWithCheck()
  29. {
  30. Recipe = item,
  31. IsSelected = SelectRecipes.Any(p => p.RecipeCode == item.RecipeCode)
  32. });
  33. }
  34. }
  35. ConfirmCommand = new(() =>
  36. {
  37. RefreshSelected();
  38. ActionManage.GetInstance.Send("CloseSelectRecipesView");
  39. });
  40. CancelCommand = new(() =>
  41. {
  42. ActionManage.GetInstance.Send("CloseSelectRecipesView");
  43. });
  44. AllSelectCommand = new(() =>
  45. {
  46. foreach (var item in AllRecipes)
  47. {
  48. item.IsSelected = true;
  49. }
  50. });
  51. AllCancelCommand = new(() =>
  52. {
  53. foreach (var item in AllRecipes)
  54. {
  55. item.IsSelected = false;
  56. }
  57. });
  58. }
  59. private void RefreshSelected()
  60. {
  61. SelectRecipes.Clear();
  62. foreach (var item in AllRecipes)
  63. {
  64. if (item.IsSelected==true)
  65. {
  66. SelectRecipes.Add(item.Recipe);
  67. }
  68. }
  69. }
  70. public ObservableCollection<RecipeDataWithCheck> AllRecipes {get; set; }
  71. public static ObservableCollection<RecipeData> SelectRecipes { get; set; } = new ObservableCollection<RecipeData>();
  72. /// <summary>
  73. /// 取消筛选,即关闭本窗口。
  74. /// </summary>
  75. public BPARelayCommand CancelCommand { get; set; }
  76. /// <summary>
  77. /// 全选。
  78. /// </summary>
  79. public BPARelayCommand AllSelectCommand { get; set; }
  80. /// <summary>
  81. /// 全部取消选择。
  82. /// </summary>
  83. public BPARelayCommand AllCancelCommand { get; set; }
  84. /// <summary>
  85. /// 确认选择。
  86. /// </summary>
  87. public BPARelayCommand ConfirmCommand { get; set; }
  88. internal class RecipeDataWithCheck:NotifyBase
  89. {
  90. public RecipeData Recipe { get; set; }
  91. private bool _IsSelected;
  92. public bool IsSelected
  93. {
  94. get { return _IsSelected; }
  95. set { _IsSelected = value; OnPropertyChanged(); }
  96. }
  97. }
  98. }
  99. }