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

109 строки
3.3 KiB

  1. using BPASmart.Model;
  2. using BPASmart.RecipeManagement.View;
  3. using BPASmartClient.Helper;
  4. using BPASmartClient.RecipeManagement.View;
  5. using Microsoft.Toolkit.Mvvm.ComponentModel;
  6. using Microsoft.Toolkit.Mvvm.Input;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Collections.ObjectModel;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. namespace BPASmart.RecipeManagement.ViewModel
  14. {
  15. public class RecipeManagerViewModel : ObservableObject
  16. {
  17. public ObservableCollection<Recipes> RecipeList { get; set; } = Json<LocalRecipes>.Data.locaRecipes;
  18. /// <summary>
  19. /// 创建配方
  20. /// </summary>
  21. public RelayCommand CreateRecipeCommand { get; set; }
  22. public RelayCommand<object> EditRecipeCommand { get; set; }
  23. public RelayCommand<object> DeleteRecipeCommand { get; set; }
  24. /// <summary>
  25. /// 配方工艺
  26. /// </summary>
  27. public RelayCommand<object> PecipeSettingCommand { get; set; }
  28. /// <summary>
  29. /// 配方下发
  30. /// </summary>
  31. public RelayCommand<object> PecipeStartCommand { get; set; }
  32. private void EditRecipe(object o)
  33. {
  34. if (o == null) return;
  35. if (o is int item && item >= 0)
  36. {
  37. Globle.GlobleData.ChangeRecipes = new Recipes();
  38. Globle.GlobleData.ChangeRecipes = RecipeList[item];
  39. RecipesConfigure recipesConfigure = new RecipesConfigure();
  40. recipesConfigure.ShowDialog();
  41. }
  42. }
  43. private void DeleteRecipe(object o)
  44. {
  45. if (o == null) return;
  46. if (o is int i && i >= 0)
  47. {
  48. RecipeList.RemoveAt(i);
  49. Json<LocalRecipes>.Save();
  50. }
  51. }
  52. private void PecipeSetting(object o)
  53. {
  54. if (o == null) return;
  55. if (o is string id)
  56. {
  57. var res = Json<LocalRecipes>.Data.locaRecipes.FirstOrDefault(p => p.ID == id);
  58. if (res != null)
  59. {
  60. Globle.GlobleData.recipeTechnologyProcess = null;
  61. Globle.GlobleData.recipeTechnologyProcess = res;
  62. TechnologyProcess technologyProcess = new TechnologyProcess();
  63. technologyProcess.ShowDialog();
  64. }
  65. }
  66. }
  67. private void PecipeStart(object o)
  68. {
  69. if (o == null) return;
  70. if (o is string id)
  71. {
  72. var res = Json<LocalRecipes>.Data.locaRecipes.FirstOrDefault(p => p.ID == id);
  73. if (res != null)
  74. {
  75. //下发配方
  76. }
  77. }
  78. }
  79. public RecipeManagerViewModel()
  80. {
  81. CreateRecipeCommand = new RelayCommand(() =>
  82. {
  83. Globle.GlobleData.ChangeRecipes = null;
  84. RecipesConfigure recipesConfigure = new RecipesConfigure();
  85. recipesConfigure.ShowDialog();
  86. });
  87. EditRecipeCommand = new RelayCommand<object>(EditRecipe);
  88. DeleteRecipeCommand = new RelayCommand<object>(DeleteRecipe);
  89. PecipeSettingCommand = new RelayCommand<object>(PecipeSetting);
  90. PecipeStartCommand = new RelayCommand<object>(PecipeStart);
  91. }
  92. }
  93. }