终端一体化运控平台
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

RecipeSettingsViewModel.cs 4.2 KiB

2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using BPA.Helper;
  7. using System.Collections.Concurrent;
  8. using System.Collections.ObjectModel;
  9. using System.Windows;
  10. using BPA.Helper;
  11. using BPASmartClient.DosingSystem.View;
  12. using BPASmartClient.CustomResource.UserControls;
  13. using BPASmartClient.CustomResource.UserControls.Model;
  14. using BPASmartClient.CustomResource.UserControls.Enum;
  15. using System.Windows.Media;
  16. using BPASmartClient.CustomResource.UserControls.MessageShow;
  17. using BPASmartClient.CustomResource.Pages.Model;
  18. using BPASmartClient.Model;
  19. namespace BPASmartClient.DosingSystem.ViewModel
  20. {
  21. public class RecipeSettingsViewModel : NotifyBase
  22. {
  23. public RecipeSettingsViewModel()
  24. {
  25. Recipes = Json<LocaPar>.Data.Recipes;
  26. NewMaterital = new BPARelayCommand(() =>
  27. {
  28. NewMaterialView newMateritalView = new NewMaterialView();
  29. newMateritalView.ShowDialog();
  30. });
  31. NewRecipe = new BPARelayCommand(() =>
  32. {
  33. NewRecipeView nrv = new NewRecipeView();
  34. nrv.ShowDialog();
  35. MessageNotify.GetInstance.ShowUserLog("新建配方");
  36. });
  37. SaveRecipe = new BPARelayCommand(() =>
  38. {
  39. Json<LocaPar>.Save();
  40. MessageNotify.GetInstance.ShowUserLog("保存配方");
  41. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方保存成功!");
  42. });
  43. RemoveCommand = new BPARelayCommand<object>((o) =>
  44. {
  45. if (!string.IsNullOrEmpty(o?.ToString()))
  46. {
  47. if (MessageNotify.GetInstance.ShowDialog($"是否删除【{o.ToString()}】配方,删除后数据将永久丢失!无法找回", DialogType.Warning))
  48. {
  49. var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipeName == o.ToString());
  50. if (res.IsEnable)
  51. {
  52. if (res != null) Json<LocaPar>.Data.Recipes.Remove(res);
  53. Json<LocaPar>.Save();
  54. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方删除成功!");
  55. MessageNotify.GetInstance.ShowUserLog($"删除配方 {res.RecipeName}");
  56. }
  57. else
  58. {
  59. NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"删除【{o.ToString()}】配方失败,配方正在使用!");
  60. }
  61. }
  62. }
  63. });
  64. DetailsCommand = new BPARelayCommand<object>((o) =>
  65. {
  66. if (!string.IsNullOrEmpty(o?.ToString()))
  67. {
  68. var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipeName == o.ToString());
  69. if (res != null)
  70. {
  71. if (res.IsEnable)
  72. {
  73. NewRecipeView nrv = new NewRecipeView();
  74. ActionManage.GetInstance.Send("Details", res);
  75. nrv.ShowDialog();
  76. }
  77. else
  78. {
  79. NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"编辑【{o.ToString()}】配方失败,配方正在使用!");
  80. }
  81. }
  82. //MessageLog.GetInstance.ShowUserLog($"编辑配方名称——{res.RecipeName}");
  83. }
  84. });
  85. }
  86. public BPARelayCommand NewMaterital { get; set; }
  87. public BPARelayCommand NewRecipe { get; set; }
  88. public BPARelayCommand SaveRecipe { get; set; }
  89. public BPARelayCommand<object> EditCommand { get; set; }
  90. public BPARelayCommand<object> DetailsCommand { get; set; }
  91. public BPARelayCommand<object> RemoveCommand { get; set; }
  92. public ObservableCollection<RecipeModel> Recipes { get; set; }
  93. }
  94. }