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

115 regels
4.3 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.Toolkit.Mvvm.ComponentModel;
  7. using System.Collections.Concurrent;
  8. using System.Collections.ObjectModel;
  9. using System.Windows;
  10. using BPASmartClient.Helper;
  11. using Microsoft.Toolkit.Mvvm.Input;
  12. using BPASmartClient.JXJFoodBigStation.Model;
  13. using BPASmartClient.JXJFoodBigStation.View;
  14. using BPASmartClient.CustomResource.UserControls;
  15. using BPASmartClient.CustomResource.UserControls.Model;
  16. using BPASmartClient.CustomResource.UserControls.Enum;
  17. using System.Windows.Media;
  18. using BPASmartClient.CustomResource.UserControls.MessageShow;
  19. using BPASmartClient.CustomResource.Pages.Model;
  20. using BPASmartClient.JXJFoodBigStation.Model.Siemens;
  21. namespace BPASmartClient.JXJFoodBigStation.ViewModel
  22. {
  23. public class RecipeReceiveViewModel : ObservableObject
  24. {
  25. public ObservableCollection<RawMaterial> RawMaterials { get; set; } = new ObservableCollection<RawMaterial>();
  26. public RecipeReceiveViewModel()
  27. {
  28. Json<LocalRecipe>.Read();
  29. Recipes = Json<LocalRecipe>.Data.Recipes;
  30. DetailsCommand = new RelayCommand<object>((o) =>
  31. {
  32. if (o != null && o is string num)
  33. {
  34. ActionManage.GetInstance.CancelRegister("RecipeInfo");
  35. RecipeInfosView nrv = new RecipeInfosView();
  36. var res = Json<LocalRecipe>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == num);
  37. ActionManage.GetInstance.Send("RecipeInfo", res);
  38. nrv.Show();
  39. MessageLog.GetInstance.ShowUserLog($"查看配方——{res.RecipeName}");
  40. }
  41. });
  42. NewRecipe = new RelayCommand(() => {
  43. RecipeInfosView nrv = new RecipeInfosView();
  44. nrv.ShowDialog();
  45. });
  46. //模拟配方
  47. //NewSimulateRecipe = new RelayCommand(() =>
  48. //{
  49. // RawMaterials.Clear();
  50. // string recipeName = "配方" + (Json<LocaPar>.Data.Recipes.Count + 1) + "";
  51. //go:
  52. // string recipeCode = new Random().Next(10000, 99999).ToString();
  53. // foreach (var item in Recipes)
  54. // {
  55. // if (item.RecipeCode == recipeCode)
  56. // {
  57. // goto go;
  58. // }
  59. // }
  60. // int trayCode = new Random().Next(1,6);
  61. // for (int i = 1; i < 13; i++)
  62. // {
  63. // int a = new Random().Next(1, 5);
  64. // if (a == 3)
  65. // {
  66. // a = 1;
  67. // }
  68. // RawMaterials.Add(new RawMaterialModel()
  69. // {
  70. // RawMaterialWeight = new Random().Next(10, 1000),
  71. // RawMaterialBarrelNum = a,
  72. // RawMaterialLocation = i,
  73. // });
  74. // }
  75. // Json<LocaPar>.Data.Recipes.Add(new RecipeModel()
  76. // {
  77. // RecipeName = recipeName,
  78. // RecipeCode = recipeCode,
  79. // TrayCode = trayCode,
  80. // RawMaterial = RawMaterials,
  81. // });
  82. // Json<LocaPar>.Save();
  83. //});
  84. ClearAllRecipe = new RelayCommand(() =>
  85. {
  86. Json<LocalRecipe>.Data.Recipes.Clear();
  87. Json<LocalRecipe>.Save();
  88. });
  89. RemoveCommand = new RelayCommand<string>((recipeCode) => {
  90. var res = Recipes.FirstOrDefault(p=>p.RecipeCode==recipeCode);
  91. if (res != null)
  92. {
  93. Recipes.Remove(res);
  94. Json<LocalRecipe>.Save();
  95. }
  96. });
  97. }
  98. public RelayCommand<object> DetailsCommand { get; set; }
  99. public RelayCommand NewSimulateRecipe { get; set; }
  100. public RelayCommand ClearAllRecipe { get; set; }
  101. public RelayCommand NewRecipe { get; set; }
  102. public RelayCommand<string> RemoveCommand { get; set; }
  103. public ObservableCollection<RecipeData> Recipes { get; set; } = new ObservableCollection<RecipeData>();
  104. }
  105. }