终端一体化运控平台
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

78 řádky
3.5 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. MessageNotify.GetInstance.ShowUserLog("新增一条物料数据。");
  43. });
  44. SaveMaterials = new RelayCommand(() =>
  45. {
  46. if (MessageNotify.GetInstance.ShowDialog("请确认是否保存!") == true)
  47. {
  48. Json<BomMaterial>.Save();
  49. MessageNotify.GetInstance.ShowUserLog($"Mes物料清单保存成功");
  50. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功");
  51. }
  52. });
  53. RemoveCommand = new RelayCommand<int>((Count) =>
  54. {
  55. if (Count is int cnt)
  56. {
  57. var res = RawMaterialInfo.FirstOrDefault(p => p.RawMaterialCount == cnt);
  58. if (res != null)
  59. {
  60. if (MessageNotify.GetInstance.ShowDialog("请确认是否删除!") == true)
  61. {
  62. RawMaterialInfo.Remove(res);
  63. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"删除成功");
  64. MessageNotify.GetInstance.ShowUserLog($"删除一条物料数据,物料为:【{res.RawMaterialName}】:{res.RawMaterialChineseName}。");
  65. }
  66. }
  67. }
  68. });
  69. }
  70. public ObservableCollection<RawMaterial> RawMaterialInfo { get; set; } = new ObservableCollection<RawMaterial>();
  71. public RelayCommand AddMaterial { get; set; }
  72. public RelayCommand SaveMaterials { get; set; }
  73. public RelayCommand<int> RemoveCommand { get; set; }
  74. }
  75. }