using BPASmartClient.CustomResource.Pages.Model; using BPASmartClient.CustomResource.UserControls; using BPASmartClient.CustomResource.UserControls.MessageShow; using BPASmartClient.FoodStationTest.Model; using BPASmartClient.FoodStationTest.View; using BPA.Helper; using BPA.Helper; using System.Collections.ObjectModel; using System.Linq; namespace BPASmartClient.FoodStationTest.ViewModel { public class RecipeSettingsViewModel : NotifyBase { public RecipeSettingsViewModel() { Recipes = Json.Data.Recipes; NewMaterital = new BPARelayCommand(() => { NewMaterialView newMateritalView = new NewMaterialView(); newMateritalView.ShowDialog(); }); NewRecipe = new BPARelayCommand(() => { NewRecipeView nrv = new NewRecipeView(); nrv.ShowDialog(); MessageNotify.GetInstance.ShowUserLog("新建配方"); }); SaveRecipe = new BPARelayCommand(() => { Json.Save(); MessageNotify.GetInstance.ShowUserLog("保存配方"); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方保存成功!"); }); RemoveCommand = new BPARelayCommand((o) => { if (o is string str) { var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipCode == str); if (res != null) Json.Data.Recipes.Remove(res); MessageNotify.GetInstance.ShowUserLog($"删除名称——{res.RecipeName}"); } }); DetailsCommand = new BPARelayCommand((o) => { if (o != null && o is string str) { ActionManage.GetInstance.CancelRegister("Details"); NewRecipeView nrv = new NewRecipeView(); var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipCode == str); ActionManage.GetInstance.Send("Details", res); nrv.ShowDialog(); MessageNotify.GetInstance.ShowUserLog($"编辑配方名称——{res.RecipeName}"); } }); } public BPARelayCommand NewMaterital { get; set; } public BPARelayCommand NewRecipe { get; set; } public BPARelayCommand SaveRecipe { get; set; } public BPARelayCommand EditCommand { get; set; } public BPARelayCommand DetailsCommand { get; set; } public BPARelayCommand RemoveCommand { get; set; } public ObservableCollection Recipes { get; set; } } }