终端一体化运控平台
Não pode escolher mais do que 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.
 
 
 

76 linhas
3.3 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.JXJFoodBigStation.Model;
  6. using BPASmartClient.JXJFoodBigStation.Model.HK_PLC;
  7. using Microsoft.Toolkit.Mvvm.ComponentModel;
  8. using Microsoft.Toolkit.Mvvm.Input;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Collections.ObjectModel;
  12. using System.ComponentModel;
  13. using System.Linq;
  14. using System.Reflection;
  15. using System.Text;
  16. using System.Threading;
  17. using System.Threading.Tasks;
  18. namespace BPASmartClient.JXJFoodBigStation.ViewModel
  19. {
  20. public class BomOfMaterialViewModel : ObservableObject
  21. {
  22. public BomOfMaterialViewModel()
  23. {
  24. RawMaterialInfo = Json<BomMaterial>.Data.RawMaterials;
  25. /*if (RawMaterialInfo.Count ==0)
  26. {
  27. Json<BomMaterial>.Data.RawMaterials.Clear();
  28. ProcessControl.GetInstance.RawMaterialNameWithCode();//原料的名称和编码对应 :西门子mes定义的物料编码
  29. foreach (var item in GVL_BigStation.RawMaterialsNameCode)
  30. {
  31. Json<BomMaterial>.Data.RawMaterials.Add(new RawMaterial() { RawMaterialCount = Json<BomMaterial>.Data.RawMaterials.Count + 1, RawMaterialName = item.Key, RawMaterialChineseName = item.Value });
  32. }
  33. RawMaterialInfo = Json<BomMaterial>.Data.RawMaterials;
  34. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"读取程序的Bom清单");
  35. }*/
  36. AddMaterial = new RelayCommand(() =>
  37. {
  38. RawMaterialInfo.Add(new RawMaterial()
  39. {
  40. RawMaterialCount = Json<BomMaterial>.Data.RawMaterials.Count +1 ,
  41. });
  42. });
  43. SaveMaterials = new RelayCommand(() =>
  44. {
  45. if (MessageNotify.GetInstance.ShowDialog("请确认是否保存!") == true)
  46. {
  47. Json<BomMaterial>.Save();
  48. MessageNotify.GetInstance.ShowUserLog($"Mes物料清单保存成功");
  49. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功");
  50. }
  51. });
  52. RemoveCommand = new RelayCommand<int>((Count) =>
  53. {
  54. if (Count is int cnt)
  55. {
  56. var res = RawMaterialInfo.FirstOrDefault(p => p.RawMaterialCount == cnt);
  57. if (res != null)
  58. {
  59. if (MessageNotify.GetInstance.ShowDialog("请确认是否删除!") == true)
  60. {
  61. RawMaterialInfo.Remove(res);
  62. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"删除成功");
  63. }
  64. }
  65. }
  66. });
  67. }
  68. public ObservableCollection<RawMaterial> RawMaterialInfo { get; set; } = new ObservableCollection<RawMaterial>();
  69. public RelayCommand AddMaterial { get; set; }
  70. public RelayCommand SaveMaterials { get; set; }
  71. public RelayCommand<int> RemoveCommand { get; set; }
  72. }
  73. }