终端一体化运控平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

117 rindas
3.2 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. foreach (var item in Json<LocalRecipe>.Data.SelectedRecipes)
  19. {
  20. SelectRecipes.Add(item);
  21. }
  22. if (Json<LocalRecipe>.Data.Recipes != null)
  23. {
  24. foreach (var item in Json<LocalRecipe>.Data.Recipes)
  25. {
  26. AllRecipes.Add(new RecipeDataWithCheck()
  27. {
  28. Recipe = item,
  29. IsSelected = SelectRecipes.Any(p => p.RecipeCode == item.RecipeCode)
  30. });
  31. }
  32. }
  33. ConfirmCommand = new(() =>
  34. {
  35. RefreshSelected();
  36. ActionManage.GetInstance.Send("CloseSelectRecipesView");
  37. });
  38. CancelCommand = new(() =>
  39. {
  40. ActionManage.GetInstance.Send("CloseSelectRecipesView");
  41. });
  42. AllSelectCommand = new(() =>
  43. {
  44. foreach (var item in AllRecipes)
  45. {
  46. item.IsSelected = true;
  47. }
  48. });
  49. AllCancelCommand = new(() =>
  50. {
  51. foreach (var item in AllRecipes)
  52. {
  53. item.IsSelected = false;
  54. }
  55. });
  56. }
  57. private void RefreshSelected()
  58. {
  59. SelectRecipes.Clear();
  60. foreach (var item in AllRecipes)
  61. {
  62. if (item.IsSelected==true)
  63. {
  64. SelectRecipes.Add(item.Recipe);
  65. }
  66. }
  67. }
  68. public ObservableCollection<RecipeDataWithCheck> AllRecipes {get; set; }
  69. public static ObservableCollection<RecipeData> SelectRecipes { get; set; } = new ObservableCollection<RecipeData>();
  70. /// <summary>
  71. /// 取消筛选,即关闭本窗口。
  72. /// </summary>
  73. public BPARelayCommand CancelCommand { get; set; }
  74. /// <summary>
  75. /// 全选。
  76. /// </summary>
  77. public BPARelayCommand AllSelectCommand { get; set; }
  78. /// <summary>
  79. /// 全部取消选择。
  80. /// </summary>
  81. public BPARelayCommand AllCancelCommand { get; set; }
  82. /// <summary>
  83. /// 确认选择。
  84. /// </summary>
  85. public BPARelayCommand ConfirmCommand { get; set; }
  86. /// <summary>
  87. /// 一个配方数据的包装类。
  88. /// </summary>
  89. internal class RecipeDataWithCheck:NotifyBase
  90. {
  91. public RecipeData Recipe { get; set; }
  92. private bool _IsSelected;
  93. public bool IsSelected
  94. {
  95. get { return _IsSelected; }
  96. set { _IsSelected = value; OnPropertyChanged(); }
  97. }
  98. }
  99. }
  100. }