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
{
///
/// 菜品步骤
///
public ObservableCollection FryPotProcesses { get; set; } = new ObservableCollection();
public ObservableCollection FryAction { get; set; } = new ObservableCollection();
public ObservableCollection Gear { get; set; } = new ObservableCollection() { 0,1, 2, 3, 4, 5 };
public ObservableCollection PotPostion { get; set; } = new ObservableCollection() { 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.Data.FryPotMessage.FirstOrDefault(p => p.GoodKey == Global.GLoFryMessage.GoodKey);
if (res != null)
{
res.GoodName = GoodName;
res.fryPotProcesses = FryPotProcesses.ToList();
}
}
else
{
if (Json.Data.FryPotMessage.FirstOrDefault(p => p.GoodName == _goodName) != null) return;
Json.Data.FryPotMessage.Add(new FryPotMessages
{
GoodName = GoodName,
GoodKey = new Guid().ToString(),
fryPotProcesses = FryPotProcesses.ToList()
});
}
Json.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(Global.GLoFryMessage.fryPotProcesses);
}
}
}
}