终端一体化运控平台
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.
 
 
 

60 lines
2.3 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using BPA.Helper;
  8. using BPASmartClient.CustomResource.UserControls;
  9. using BPASmartClient.CustomResource.UserControls.MessageShow;
  10. using BPASmartClient.SmallBatchingSystem.Views;
  11. using Microsoft.Toolkit.Mvvm.ComponentModel;
  12. using Microsoft.Toolkit.Mvvm.Input;
  13. namespace BPASmartClient.SmallBatchingSystem.ViewModels
  14. {
  15. public class RecipeViewModel : BaseModel
  16. {
  17. public RecipeViewModel()
  18. {
  19. AddCommand = new RelayCommand(() =>
  20. {
  21. NewRecipeView newOutletView = new NewRecipeView();
  22. newOutletView.ShowDialog();
  23. });
  24. SaveCommand = new RelayCommand(() => { Json<ConfigInfoModel>.Save(); Control.GetInstance.NotifyPrompt("配方保存成功"); });
  25. RecipeInfoModels = Json<ConfigInfoModel>.Data.Recipes;
  26. RemoveCommand = new RelayCommand<object>((o) =>
  27. {
  28. if (!string.IsNullOrEmpty(o?.ToString()))
  29. {
  30. var res = Json<ConfigInfoModel>.Data.Recipes.FirstOrDefault(p => p.RecipeName == o.ToString());
  31. if (res != null)
  32. {
  33. Json<ConfigInfoModel>.Data.Recipes.Remove(res);
  34. Control.GetInstance.NotifyPrompt($"{res.RecipeName} 删除成功");
  35. Control.GetInstance.OperationLog($"{res.RecipeName} 删除成功");
  36. }
  37. }
  38. });
  39. DetailsCommand = new RelayCommand<object>((o) =>
  40. {
  41. if (!string.IsNullOrEmpty(o?.ToString()))
  42. {
  43. var res = Json<ConfigInfoModel>.Data.Recipes.FirstOrDefault(p => p.RecipeName == o.ToString());
  44. if (res != null)
  45. {
  46. NewRecipeView newOutletView = new NewRecipeView();
  47. ActionManage.GetInstance.Send("OpenNewRecipe", res);
  48. newOutletView.ShowDialog();
  49. Control.GetInstance.OperationLog($"{res.RecipeName} 编辑完成");
  50. }
  51. }
  52. });
  53. }
  54. public ObservableCollection<RecipeInfo> RecipeInfoModels { get; set; }
  55. }
  56. }