终端一体化运控平台
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

105 строки
3.3 KiB

  1. using BPASmartClient.Helper;
  2. using BPASmartClient.Model.大炒;
  3. using BPASmartClient.MorkBF.Model;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Collections.ObjectModel;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. namespace BPASmartClient.MorkBF.ViewModel
  12. {
  13. [INotifyPropertyChanged]
  14. partial class FoodManagerViewModel
  15. {
  16. /// <summary>
  17. /// 菜品步骤
  18. /// </summary>
  19. public ObservableCollection<FryPotProcess> FryPotProcesses { get; set; } = new ObservableCollection<FryPotProcess>();
  20. public ObservableCollection<FryAction> FryAction { get; set; } = new ObservableCollection<FryAction>();
  21. public ObservableCollection<int> Gear { get; set; } = new ObservableCollection<int>() { 0,1, 2, 3, 4, 5 };
  22. public ObservableCollection<int> PotPostion { get; set; } = new ObservableCollection<int>() { 1, 2,3, 4 };
  23. [ObservableProperty]
  24. private string _goodName;
  25. [RelayCommand]
  26. private void Add()
  27. {
  28. FryPotProcesses.Add(new FryPotProcess() { FryTime = FryPotProcesses.Count + 1 });
  29. }
  30. [RelayCommand]
  31. private void Save()
  32. {
  33. if (string.IsNullOrEmpty(GoodName)) return;
  34. if (Global.GLoFryMessage != null)
  35. {
  36. var res = Json<LocalFryPotMessage>.Data.FryPotMessage.FirstOrDefault(p => p.GoodKey == Global.GLoFryMessage.GoodKey);
  37. if (res != null)
  38. {
  39. res.GoodName = GoodName;
  40. res.fryPotProcesses = FryPotProcesses.ToList();
  41. }
  42. }
  43. else
  44. {
  45. if (Json<LocalFryPotMessage>.Data.FryPotMessage.FirstOrDefault(p => p.GoodName == _goodName) != null) return;
  46. Json<LocalFryPotMessage>.Data.FryPotMessage.Add(new FryPotMessages
  47. {
  48. GoodName = GoodName,
  49. GoodKey = new Guid().ToString(),
  50. fryPotProcesses = FryPotProcesses.ToList()
  51. });
  52. }
  53. Json<LocalFryPotMessage>.Save();
  54. ActionManage.GetInstance.Send("更新菜单");
  55. ActionManage.GetInstance.Send("FoodManagerViewClose");
  56. }
  57. [RelayCommand]
  58. private void Delete(object o)
  59. {
  60. if (o == null) return;
  61. if (o is FryPotProcess value)
  62. {
  63. foreach (var item in FryPotProcesses)
  64. {
  65. if (item.FryTime > value.FryTime)
  66. {
  67. Application.Current?.Dispatcher.Invoke(new Action(() =>
  68. {
  69. item.FryTime -= 1;
  70. }));
  71. }
  72. }
  73. FryPotProcesses.Remove(value);
  74. }
  75. }
  76. public FoodManagerViewModel()
  77. {
  78. foreach(var item in Enum.GetValues(typeof(FryAction)))
  79. {
  80. FryAction.Add((FryAction)item);
  81. }
  82. if (Global.GLoFryMessage != null)//编辑
  83. {
  84. GoodName = Global.GLoFryMessage.GoodName;
  85. FryPotProcesses = new ObservableCollection<FryPotProcess>(Global.GLoFryMessage.fryPotProcesses);
  86. }
  87. }
  88. }
  89. }