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

RecipeReceiveViewModel.cs 4.3 KiB

vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
vor 2 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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<RawMaterialModel> RawMaterials { get; set; } = new ObservableCollection<RawMaterialModel>();
  26. public RecipeReceiveViewModel()
  27. {
  28. Json<LocaPar>.Read();
  29. Recipes = Json<LocaPar>.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<LocaPar>.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<LocaPar>.Data.Recipes.Clear();
  87. Json<LocaPar>.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<LocaPar>.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<RecipeModel> Recipes { get; set; } = new ObservableCollection<RecipeModel>();
  104. }
  105. }