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

55 lines
2.1 KiB

  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.ObjectModel;
  8. using BPASmartClient.CustomResource.Pages.Model;
  9. namespace BPASmartClient.SmallBatchingSystem.ViewModels
  10. {
  11. public class GrindArenaceousViewModel : BaseModel
  12. {
  13. public GrindArenaceousViewModel()
  14. {
  15. ActionManage.GetInstance.Register(new Action<object>((o) =>
  16. {
  17. if (o != null && o is RecipeStatus recipe)
  18. {
  19. int index = Array.FindIndex(Recipes.ToArray(), p => p.RawMaterialName == recipe.RawMaterialName);
  20. if (index >= 0 && index < Recipes.Count)
  21. {
  22. Recipes.ElementAt(index).Status = recipe.Status;
  23. Recipes.ElementAt(index).IsChecked = true;
  24. }
  25. }
  26. }), "StatusNotify", true);
  27. ActionManage.GetInstance.Register(new Action<object>((o) =>
  28. {
  29. if (o != null && o is RecipeInfo recipe)
  30. {
  31. RecipeName = recipe.RecipeName;
  32. recipe.SiloInfoModels.ToList()?.ForEach(x =>
  33. {
  34. Recipes.Add(new RecipeStatus() { RawMaterialName = x.SiloName, Status = "等待配料" });
  35. });
  36. }
  37. }), "OpenRecipeStatusMotion", true);
  38. CancelCommand = new BPARelayCommand(() =>
  39. {
  40. if (MessageNotify.GetInstance.ShowDialog($"是否取消配方制作,取消后设备将终止配料过程!", DialogType.Warning))
  41. {
  42. Control.GetInstance.IsCancel = true; ActionManage.GetInstance.Send("GrindArenaceousCancel");
  43. }
  44. });
  45. }
  46. public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } }
  47. private string _mRecipeName;
  48. public ObservableCollection<RecipeStatus> Recipes { get; set; } = new ObservableCollection<RecipeStatus>();
  49. }
  50. }