|
- using BPASmartClient.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;
-
- namespace BPASmartClient.MorkBF.ViewModel
- {
- [INotifyPropertyChanged]
- partial class FoodManagerViewModel
- {
- /// <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;
-
- [RelayCommand]
- private void Add()
- {
- FryPotProcesses.Add(new FryPotProcess() { FryTime = FryPotProcesses.Count + 1 });
- }
-
- [RelayCommand]
- 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");
- }
-
- [RelayCommand]
- private void Delete(object o)
- {
- if (o == null) return;
- if (o is FryPotProcess value)
- {
- FryPotProcesses.Remove(value);
- }
- ActionManage.GetInstance.Send("更新菜单");
-
- }
-
-
-
- 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);
- }
- }
- }
- }
|