|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using System.Collections.Concurrent;
- using System.Collections.ObjectModel;
- using System.Windows;
- using BPASmartClient.Helper;
- using Microsoft.Toolkit.Mvvm.Input;
- using BPASmartClient.JXJFoodSmallStation.Model;
- using BPASmartClient.JXJFoodSmallStation.View;
- using BPASmartClient.CustomResource.UserControls;
- using BPASmartClient.CustomResource.UserControls.Model;
- using BPASmartClient.CustomResource.UserControls.Enum;
- using System.Windows.Media;
- using BPASmartClient.CustomResource.UserControls.MessageShow;
- using BPASmartClient.CustomResource.Pages.Model;
-
- namespace BPASmartClient.JXJFoodSmallStation.ViewModel
- {
- public class RecipeSettingsViewModel : ObservableObject
- {
- public RecipeSettingsViewModel()
- {
- //Json<LocaPar>.Read();
- Recipes = Json<LocaPar>.Data.Recipes;
- NewRecipe = new RelayCommand(() =>
- {
- NewRecipeView nrv = new NewRecipeView();
- nrv.ShowDialog();
- MessageLog.GetInstance.ShowUserLog("新建配方");
- });
- SaveRecipe = new RelayCommand(() =>
- {
- Json<LocaPar>.Save();
- MessageLog.GetInstance.ShowUserLog("保存配方");
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方保存成功!");
- });
- RemoveCommand = new RelayCommand<object>((o) =>
- {
- if (o is string str)
- {
- var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str);
- if (res != null) Json<LocaPar>.Data.Recipes.Remove(res);
- MessageLog.GetInstance.ShowUserLog($"删除名称——{res.RecipeName}");
- }
- });
-
- DetailsCommand = new RelayCommand<object>((o) =>
- {
- if (o != null && o is string str)
- {
- ActionManage.GetInstance.CancelRegister("Details");
- NewRecipeView nrv = new NewRecipeView();
- var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str);
- ActionManage.GetInstance.Send("Details",res);
- nrv.ShowDialog();
- MessageLog.GetInstance.ShowUserLog($"编辑配方名称——{res.RecipeName}");
- }
- });
- }
-
- public RelayCommand NewRecipe { get; set; }
-
- public RelayCommand SaveRecipe { get; set; }
-
- public RelayCommand<object> EditCommand { get; set; }
-
- public RelayCommand<object> DetailsCommand { get; set; }
-
- public RelayCommand<object> RemoveCommand { get; set; }
-
- public ObservableCollection<RecipeModel> Recipes { get; set; }
- }
- }
|