终端一体化运控平台
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

95 líneas
3.0 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. namespace BPASmartClient.MorkBF.ViewModel
  11. {
  12. [INotifyPropertyChanged]
  13. partial class FoodManagerViewModel
  14. {
  15. /// <summary>
  16. /// 菜品步骤
  17. /// </summary>
  18. public ObservableCollection<FryPotProcess> FryPotProcesses { get; set; } = new ObservableCollection<FryPotProcess>();
  19. public ObservableCollection<FryAction> FryAction { get; set; } = new ObservableCollection<FryAction>();
  20. public ObservableCollection<int> Gear { get; set; } = new ObservableCollection<int>() { 0,1, 2, 3, 4, 5 };
  21. public ObservableCollection<int> PotPostion { get; set; } = new ObservableCollection<int>() { 1, 2,3, 4 };
  22. [ObservableProperty]
  23. private string _goodName;
  24. [RelayCommand]
  25. private void Add()
  26. {
  27. FryPotProcesses.Add(new FryPotProcess() { FryTime = FryPotProcesses.Count + 1 });
  28. }
  29. [RelayCommand]
  30. private void Save()
  31. {
  32. if (string.IsNullOrEmpty(GoodName)) return;
  33. if (Global.GLoFryMessage != null)
  34. {
  35. var res = Json<LocalFryPotMessage>.Data.FryPotMessage.FirstOrDefault(p => p.GoodKey == Global.GLoFryMessage.GoodKey);
  36. if (res != null)
  37. {
  38. res.GoodName = GoodName;
  39. res.fryPotProcesses = FryPotProcesses.ToList();
  40. }
  41. }
  42. else
  43. {
  44. if (Json<LocalFryPotMessage>.Data.FryPotMessage.FirstOrDefault(p => p.GoodName == _goodName) != null) return;
  45. Json<LocalFryPotMessage>.Data.FryPotMessage.Add(new FryPotMessages
  46. {
  47. GoodName = GoodName,
  48. GoodKey = new Guid().ToString(),
  49. fryPotProcesses = FryPotProcesses.ToList()
  50. });
  51. }
  52. Json<LocalFryPotMessage>.Save();
  53. ActionManage.GetInstance.Send("更新菜单");
  54. ActionManage.GetInstance.Send("FoodManagerViewClose");
  55. }
  56. [RelayCommand]
  57. private void Delete(object o)
  58. {
  59. if (o == null) return;
  60. if (o is FryPotProcess value)
  61. {
  62. FryPotProcesses.Remove(value);
  63. }
  64. ActionManage.GetInstance.Send("更新菜单");
  65. }
  66. public FoodManagerViewModel()
  67. {
  68. foreach(var item in Enum.GetValues(typeof(FryAction)))
  69. {
  70. FryAction.Add((FryAction)item);
  71. }
  72. if (Global.GLoFryMessage != null)//编辑
  73. {
  74. GoodName = Global.GLoFryMessage.GoodName;
  75. FryPotProcesses = new ObservableCollection<FryPotProcess>(Global.GLoFryMessage.fryPotProcesses);
  76. }
  77. }
  78. }
  79. }