终端一体化运控平台
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

88 lignes
3.2 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.DosingSystem.Model;
  13. using BPASmartClient.DosingSystem.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. using BPASmartClient.Model;
  21. namespace BPASmartClient.DosingSystem.ViewModel
  22. {
  23. public class RecipeSettingsViewModel : ObservableObject
  24. {
  25. public RecipeSettingsViewModel()
  26. {
  27. //Json<LocaPar>.Read();
  28. Recipes = Json<LocaPar>.Data.Recipes;
  29. NewMaterital = new RelayCommand(() =>
  30. {
  31. NewMaterialView newMateritalView = new NewMaterialView();
  32. newMateritalView.ShowDialog();
  33. });
  34. NewRecipe = new RelayCommand(() =>
  35. {
  36. NewRecipeView nrv = new NewRecipeView();
  37. nrv.ShowDialog();
  38. MessageLog.GetInstance.ShowUserLog("新建配方");
  39. });
  40. SaveRecipe = new RelayCommand(() =>
  41. {
  42. Json<LocaPar>.Save();
  43. MessageLog.GetInstance.ShowUserLog("保存配方");
  44. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方保存成功!");
  45. });
  46. RemoveCommand = new RelayCommand<object>((o) =>
  47. {
  48. if (o is string str)
  49. {
  50. var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str);
  51. if (res != null) Json<LocaPar>.Data.Recipes.Remove(res);
  52. MessageLog.GetInstance.ShowUserLog($"删除名称——{res.RecipeName}");
  53. }
  54. });
  55. DetailsCommand = new RelayCommand<object>((o) =>
  56. {
  57. if (o != null && o is string str)
  58. {
  59. ActionManage.GetInstance.CancelRegister("Details");
  60. NewRecipeView nrv = new NewRecipeView();
  61. var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str);
  62. ActionManage.GetInstance.Send("Details",res);
  63. nrv.ShowDialog();
  64. MessageLog.GetInstance.ShowUserLog($"编辑配方名称——{res.RecipeName}");
  65. }
  66. });
  67. }
  68. public RelayCommand NewMaterital { get; set; }
  69. public RelayCommand NewRecipe { get; set; }
  70. public RelayCommand SaveRecipe { get; set; }
  71. public RelayCommand<object> EditCommand { get; set; }
  72. public RelayCommand<object> DetailsCommand { get; set; }
  73. public RelayCommand<object> RemoveCommand { get; set; }
  74. public ObservableCollection<RecipeModel> Recipes { get; set; }
  75. }
  76. }