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

110 строки
3.5 KiB

  1. using BPA.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 : NotifyBase
  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. public string GoodName { get { return _goodName; } set { _goodName = value; OnPropertyChanged(); } }
  26. private string _goodName;
  27. //[BPARelayCommand]
  28. private void Add()
  29. {
  30. FryPotProcesses.Add(new FryPotProcess() { FryTime = FryPotProcesses.Count + 1 });
  31. }
  32. //[BPARelayCommand]
  33. private void Save()
  34. {
  35. if (string.IsNullOrEmpty(GoodName)) return;
  36. if (Global.GLoFryMessage != null)
  37. {
  38. var res = Json<LocalFryPotMessage>.Data.FryPotMessage.FirstOrDefault(p => p.GoodKey == Global.GLoFryMessage.GoodKey);
  39. if (res != null)
  40. {
  41. res.GoodName = GoodName;
  42. res.fryPotProcesses = FryPotProcesses.ToList();
  43. }
  44. }
  45. else
  46. {
  47. if (Json<LocalFryPotMessage>.Data.FryPotMessage.FirstOrDefault(p => p.GoodName == _goodName) != null) return;
  48. Json<LocalFryPotMessage>.Data.FryPotMessage.Add(new FryPotMessages
  49. {
  50. GoodName = GoodName,
  51. GoodKey = new Guid().ToString(),
  52. fryPotProcesses = FryPotProcesses.ToList()
  53. });
  54. }
  55. Json<LocalFryPotMessage>.Save();
  56. ActionManage.GetInstance.Send("更新菜单");
  57. ActionManage.GetInstance.Send("FoodManagerViewClose");
  58. }
  59. //[BPARelayCommand]
  60. private void Delete(object o)
  61. {
  62. if (o == null) return;
  63. if (o is FryPotProcess value)
  64. {
  65. foreach (var item in FryPotProcesses)
  66. {
  67. if (item.FryTime > value.FryTime)
  68. {
  69. Application.Current?.Dispatcher.Invoke(new Action(() =>
  70. {
  71. item.FryTime -= 1;
  72. }));
  73. }
  74. }
  75. FryPotProcesses.Remove(value);
  76. }
  77. }
  78. public FoodManagerViewModel()
  79. {
  80. foreach (var item in Enum.GetValues(typeof(FryAction)))
  81. {
  82. FryAction.Add((FryAction)item);
  83. }
  84. if (Global.GLoFryMessage != null)//编辑
  85. {
  86. GoodName = Global.GLoFryMessage.GoodName;
  87. FryPotProcesses = new ObservableCollection<FryPotProcess>(Global.GLoFryMessage.fryPotProcesses);
  88. }
  89. }
  90. }
  91. }