终端一体化运控平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

86 linhas
3.8 KiB

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