终端一体化运控平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

RecipeViewModel.cs 2.3 KiB

pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. }