终端一体化运控平台
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

78 строки
2.9 KiB

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