终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

78 lines
2.8 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.CustomResource.UserControls;
  3. using BPASmartClient.CustomResource.UserControls.MessageShow;
  4. using BPASmartClient.FoodStationTest.Model;
  5. using BPASmartClient.FoodStationTest.View;
  6. using BPASmartClient.Helper;
  7. using Microsoft.Toolkit.Mvvm.ComponentModel;
  8. using Microsoft.Toolkit.Mvvm.Input;
  9. using System.Collections.ObjectModel;
  10. using System.Linq;
  11. namespace BPASmartClient.FoodStationTest.ViewModel
  12. {
  13. public class RecipeSettingsViewModel : ObservableObject
  14. {
  15. public RecipeSettingsViewModel()
  16. {
  17. Recipes = Json<LocalPar>.Data.Recipes;
  18. NewMaterital = new RelayCommand(() =>
  19. {
  20. NewMaterialView newMateritalView = new NewMaterialView();
  21. newMateritalView.ShowDialog();
  22. });
  23. NewRecipe = new RelayCommand(() =>
  24. {
  25. NewRecipeView nrv = new NewRecipeView();
  26. nrv.ShowDialog();
  27. MessageNotify.GetInstance.ShowUserLog("新建配方");
  28. });
  29. SaveRecipe = new RelayCommand(() =>
  30. {
  31. Json<LocalPar>.Save();
  32. MessageNotify.GetInstance.ShowUserLog("保存配方");
  33. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方保存成功!");
  34. });
  35. RemoveCommand = new RelayCommand<object>((o) =>
  36. {
  37. if (o is string str)
  38. {
  39. var res = Json<LocalPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str);
  40. if (res != null)
  41. Json<LocalPar>.Data.Recipes.Remove(res);
  42. MessageNotify.GetInstance.ShowUserLog($"删除名称——{res.RecipeName}");
  43. }
  44. });
  45. DetailsCommand = new RelayCommand<object>((o) =>
  46. {
  47. if (o != null && o is string str)
  48. {
  49. ActionManage.GetInstance.CancelRegister("Details");
  50. NewRecipeView nrv = new NewRecipeView();
  51. var res = Json<LocalPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str);
  52. ActionManage.GetInstance.Send("Details", res);
  53. nrv.ShowDialog();
  54. MessageNotify.GetInstance.ShowUserLog($"编辑配方名称——{res.RecipeName}");
  55. }
  56. });
  57. }
  58. public RelayCommand NewMaterital { get; set; }
  59. public RelayCommand NewRecipe { get; set; }
  60. public RelayCommand SaveRecipe { get; set; }
  61. public RelayCommand<object> EditCommand { get; set; }
  62. public RelayCommand<object> DetailsCommand { get; set; }
  63. public RelayCommand<object> RemoveCommand { get; set; }
  64. public ObservableCollection<RecipeModel> Recipes { get; set; }
  65. }
  66. }