|
- using BPA.Helper;
- using BPASmartClient.Model.大炒;
- using BPASmartClient.MorkBF.Model;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
-
- namespace BPASmartClient.MorkBF.ViewModel
- {
- //[INotifyPropertyChanged]
- partial class FoodManagerViewModel : NotifyBase
- {
- /// <summary>
- /// 菜品步骤
- /// </summary>
- public ObservableCollection<FryPotProcess> FryPotProcesses { get; set; } = new ObservableCollection<FryPotProcess>();
-
- public ObservableCollection<FryAction> FryAction { get; set; } = new ObservableCollection<FryAction>();
-
- public ObservableCollection<int> Gear { get; set; } = new ObservableCollection<int>() { 0, 1, 2, 3, 4, 5 };
-
- public ObservableCollection<int> PotPostion { get; set; } = new ObservableCollection<int>() { 1, 2, 3, 4 };
-
- //[ObservableProperty]
- //private string _goodName;
-
-
- public string GoodName { get { return _goodName; } set { _goodName = value; OnPropertyChanged(); } }
- private string _goodName;
-
-
- //[BPARelayCommand]
- private void Add()
- {
- FryPotProcesses.Add(new FryPotProcess() { FryTime = FryPotProcesses.Count + 1 });
- }
-
- //[BPARelayCommand]
- private void Save()
- {
- if (string.IsNullOrEmpty(GoodName)) return;
-
-
- if (Global.GLoFryMessage != null)
- {
- var res = Json<LocalFryPotMessage>.Data.FryPotMessage.FirstOrDefault(p => p.GoodKey == Global.GLoFryMessage.GoodKey);
- if (res != null)
- {
- res.GoodName = GoodName;
- res.fryPotProcesses = FryPotProcesses.ToList();
- }
- }
- else
- {
- if (Json<LocalFryPotMessage>.Data.FryPotMessage.FirstOrDefault(p => p.GoodName == _goodName) != null) return;
- Json<LocalFryPotMessage>.Data.FryPotMessage.Add(new FryPotMessages
- {
- GoodName = GoodName,
- GoodKey = new Guid().ToString(),
- fryPotProcesses = FryPotProcesses.ToList()
- });
- }
- Json<LocalFryPotMessage>.Save();
- ActionManage.GetInstance.Send("更新菜单");
- ActionManage.GetInstance.Send("FoodManagerViewClose");
- }
-
- //[BPARelayCommand]
- private void Delete(object o)
- {
- if (o == null) return;
- if (o is FryPotProcess value)
- {
-
- foreach (var item in FryPotProcesses)
- {
- if (item.FryTime > value.FryTime)
- {
- Application.Current?.Dispatcher.Invoke(new Action(() =>
- {
- item.FryTime -= 1;
- }));
- }
- }
- FryPotProcesses.Remove(value);
- }
- }
-
-
-
- public FoodManagerViewModel()
- {
- foreach (var item in Enum.GetValues(typeof(FryAction)))
- {
- FryAction.Add((FryAction)item);
- }
-
- if (Global.GLoFryMessage != null)//编辑
- {
- GoodName = Global.GLoFryMessage.GoodName;
- FryPotProcesses = new ObservableCollection<FryPotProcess>(Global.GLoFryMessage.fryPotProcesses);
- }
- }
- }
- }
|