终端一体化运控平台
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

64 строки
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 BPA.Helper;
  13. namespace BPASmartClient.SmallBatchingSystem.ViewModels
  14. {
  15. public class RecipeViewModel : BaseModel
  16. {
  17. public RecipeViewModel()
  18. {
  19. AddCommand = new BPARelayCommand(() =>
  20. {
  21. NewRecipeView newOutletView = new NewRecipeView();
  22. newOutletView.ShowDialog();
  23. });
  24. SaveCommand = new BPARelayCommand(() => { Json<ConfigInfoModel>.Save(); Control.GetInstance.NotifyPrompt("配方保存成功"); });
  25. RecipeInfoModels = Json<ConfigInfoModel>.Data.Recipes;
  26. RemoveCommand = new BPARelayCommand<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. if (MessageNotify.GetInstance.ShowDialog($"是否删除【{res.RecipeName}】配方,删除后数据将永久丢失!无法找回", DialogType.Warning))
  34. {
  35. Json<ConfigInfoModel>.Data.Recipes.Remove(res);
  36. Control.GetInstance.NotifyPrompt($"{res.RecipeName} 删除成功");
  37. Control.GetInstance.OperationLog($"{res.RecipeName} 删除成功");
  38. }
  39. }
  40. }
  41. });
  42. DetailsCommand = new BPARelayCommand<object>((o) =>
  43. {
  44. if (!string.IsNullOrEmpty(o?.ToString()))
  45. {
  46. var res = Json<ConfigInfoModel>.Data.Recipes.FirstOrDefault(p => p.RecipeName == o.ToString());
  47. if (res != null)
  48. {
  49. NewRecipeView newOutletView = new NewRecipeView();
  50. ActionManage.GetInstance.Send("OpenNewRecipe", res);
  51. newOutletView.ShowDialog();
  52. Control.GetInstance.OperationLog($"{res.RecipeName} 编辑完成");
  53. }
  54. }
  55. });
  56. }
  57. public ObservableCollection<RecipeInfo> RecipeInfoModels { get; set; }
  58. }
  59. }