终端一体化运控平台
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

51 lines
2.2 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.RawMaterial;
  6. using BPASmartClient.Helper;
  7. using Microsoft.Toolkit.Mvvm.ComponentModel;
  8. using Microsoft.Toolkit.Mvvm.Input;
  9. using System;
  10. using System.Collections.ObjectModel;
  11. using System.Linq;
  12. namespace BPASmartClient.FoodStationTest.ViewModel
  13. {
  14. public class StockBinRawMaterialViewModel : ObservableObject
  15. {
  16. public StockBinRawMaterialViewModel()
  17. {
  18. RawMaterialInfo = Json<DevicePar>.Data.rawMaterialStockBin;
  19. RemoveCommand = new RelayCommand<Object>((loc) =>
  20. {
  21. if (loc is int pos)
  22. {
  23. var res = RawMaterialInfo.FirstOrDefault(p => p.RawMaterialLocation == pos);
  24. if (res != null)
  25. RawMaterialInfo.Remove(res);
  26. }
  27. });
  28. SaveRawMaterialPara = new RelayCommand(() =>
  29. {
  30. Json<DevicePar>.Save();
  31. ProcessControl.GetInstance.StockBinNameWithPos();
  32. foreach (var item in Json<DevicePar>.Data.rawMaterialStockBin)
  33. {
  34. MessageNotify.GetInstance.ShowUserLog($"料仓位置:" + item.RawMaterialLocation + ",物料编码:" + item.RawMaterialName);
  35. }
  36. MessageNotify.GetInstance.ShowUserLog($"原料与料仓对应关系保存成功");
  37. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功");
  38. });
  39. UpdateRawMaterial = new RelayCommand(() =>
  40. {
  41. RawMaterialInfo.Add(new RawMaterialStockBin() { RawMaterialCount = (short)(RawMaterialInfo.Count + 1) });
  42. });
  43. }
  44. public ObservableCollection<RawMaterialStockBin> RawMaterialInfo { get; set; } = new ObservableCollection<RawMaterialStockBin>();
  45. public RelayCommand<Object> RemoveCommand { get; set; }
  46. public RelayCommand SaveRawMaterialPara { get; set; }
  47. public RelayCommand UpdateRawMaterial { get; set; }
  48. }
  49. }