终端一体化运控平台
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

64 Zeilen
2.6 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.Pages.Model;
  9. using BPASmartClient.CustomResource.UserControls;
  10. using BPASmartClient.CustomResource.UserControls.MessageShow;
  11. using BPASmartClient.SmallBatchingSystem.Views;
  12. using Microsoft.Toolkit.Mvvm.ComponentModel;
  13. using Microsoft.Toolkit.Mvvm.Input;
  14. namespace BPASmartClient.SmallBatchingSystem.ViewModels
  15. {
  16. public class RecipeViewModel : BaseModel
  17. {
  18. public RecipeViewModel()
  19. {
  20. AddCommand = new RelayCommand(() =>
  21. {
  22. NewRecipeView newOutletView = new NewRecipeView();
  23. newOutletView.ShowDialog();
  24. });
  25. SaveCommand = new RelayCommand(() => { Json<ConfigInfoModel>.Save(); Control.GetInstance.NotifyPrompt("配方保存成功"); });
  26. RecipeInfoModels = Json<ConfigInfoModel>.Data.Recipes;
  27. RemoveCommand = new RelayCommand<object>((o) =>
  28. {
  29. if (!string.IsNullOrEmpty(o?.ToString()))
  30. {
  31. var res = Json<ConfigInfoModel>.Data.Recipes.FirstOrDefault(p => p.RecipeName == o.ToString());
  32. if (res != null)
  33. {
  34. if (MessageNotify.GetInstance.ShowDialog($"是否删除【{res.RecipeName}】配方,删除后数据将永久丢失!无法找回", DialogType.Warning))
  35. {
  36. Json<ConfigInfoModel>.Data.Recipes.Remove(res);
  37. Control.GetInstance.NotifyPrompt($"{res.RecipeName} 删除成功");
  38. Control.GetInstance.OperationLog($"{res.RecipeName} 删除成功");
  39. }
  40. }
  41. }
  42. });
  43. DetailsCommand = new RelayCommand<object>((o) =>
  44. {
  45. if (!string.IsNullOrEmpty(o?.ToString()))
  46. {
  47. var res = Json<ConfigInfoModel>.Data.Recipes.FirstOrDefault(p => p.RecipeName == o.ToString());
  48. if (res != null)
  49. {
  50. NewRecipeView newOutletView = new NewRecipeView();
  51. ActionManage.GetInstance.Send("OpenNewRecipe", res);
  52. newOutletView.ShowDialog();
  53. Control.GetInstance.OperationLog($"{res.RecipeName} 编辑完成");
  54. }
  55. }
  56. });
  57. }
  58. public ObservableCollection<RecipeInfo> RecipeInfoModels { get; set; }
  59. }
  60. }