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

118 regels
3.3 KiB

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