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