终端一体化运控平台
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

78 líneas
3.6 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.CustomResource.UserControls;
  3. using BPASmartClient.CustomResource.UserControls.MessageShow;
  4. using BPASmartClient.FoodStationTest.Model;
  5. using BPASmartClient.FoodStationTest.Model.Bom;
  6. using BPASmartClient.Helper;
  7. using Microsoft.Toolkit.Mvvm.ComponentModel;
  8. using Microsoft.Toolkit.Mvvm.Input;
  9. using System.Collections.ObjectModel;
  10. using System.Linq;
  11. namespace BPASmartClient.FoodStationTest.ViewModel
  12. {
  13. public class BomOfMaterialViewModel : ObservableObject
  14. {
  15. public BomOfMaterialViewModel()
  16. {
  17. RawMaterialInfo = Json<DevicePar>.Data.BomMaterial;
  18. AddMaterial = new RelayCommand(() =>
  19. {
  20. RawMaterialInfo.Add(new BomMaterial()
  21. {
  22. Count = Json<DevicePar>.Data.BomMaterial.Count + 1,
  23. });
  24. });
  25. SaveMaterials = new RelayCommand(() =>
  26. {
  27. if (MessageNotify.GetInstance.ShowDialog("请确认是否保存!") == true)
  28. {
  29. Json<DevicePar>.Save();
  30. MessageNotify.GetInstance.ShowUserLog($"西门子物料清单保存成功");
  31. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功");
  32. }
  33. });
  34. GetBomMaterialData = new RelayCommand(() =>
  35. {
  36. Json<DevicePar>.Data.BomMaterial.Clear();
  37. ProcessControl.GetInstance.RawMaterialNameWithCode();//原料的名称和编码对应 :西门子mes定义的物料编码
  38. foreach (var item in GVL_SmallStation.GetInstance.RawMaterialsNameCode)
  39. {
  40. Json<DevicePar>.Data.BomMaterial.Add(new BomMaterial() { Count = Json<DevicePar>.Data.BomMaterial.Count + 1, MaterialCode = item.Key, MaterialName = item.Value });
  41. }
  42. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"读取程序的Bom清单");
  43. });
  44. DeleteAllMaterial = new RelayCommand(() =>
  45. {
  46. if (MessageNotify.GetInstance.ShowDialog("请确认是否删除所有原料数据!") == true)
  47. {
  48. Json<DevicePar>.Data.BomMaterial.Clear();
  49. MessageNotify.GetInstance.ShowUserLog($"西门子物料清单删除完成");
  50. }
  51. });
  52. RemoveCommand = new RelayCommand<int>((Count) =>
  53. {
  54. if (Count is int cnt)
  55. {
  56. var res = RawMaterialInfo.FirstOrDefault(p => p.Count == cnt);
  57. if (res != null)
  58. {
  59. if (MessageNotify.GetInstance.ShowDialog($"请确认是否删除[{res.MaterialCode}],[{res.MaterialName}]!") == true)
  60. {
  61. RawMaterialInfo.Remove(res);
  62. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"删除成功");
  63. }
  64. }
  65. }
  66. });
  67. }
  68. public ObservableCollection<BomMaterial> RawMaterialInfo { get; set; } = new ObservableCollection<BomMaterial>();
  69. public RelayCommand AddMaterial { get; set; }
  70. public RelayCommand SaveMaterials { get; set; }
  71. public RelayCommand<int> RemoveCommand { get; set; }
  72. public RelayCommand GetBomMaterialData { get; set; }
  73. public RelayCommand DeleteAllMaterial { get; set; }
  74. }
  75. }