终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

59 lines
2.2 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.Toolkit.Mvvm.ComponentModel;
  7. using Microsoft.Toolkit.Mvvm.Input;
  8. using BPASmartClient.SmallBatchingSystem.Views;
  9. using System.Collections.ObjectModel;
  10. using BPA.Helper;
  11. namespace BPASmartClient.SmallBatchingSystem.ViewModels
  12. {
  13. public class SiloManagementViewModel : BaseModel
  14. {
  15. public SiloManagementViewModel()
  16. {
  17. AddCommand = new RelayCommand(() =>
  18. {
  19. NewSiloView newSiloView = new NewSiloView();
  20. newSiloView.ShowDialog();
  21. });
  22. SaveCommand = new RelayCommand(() => { Json<ConfigInfoModel>.Save(); });
  23. SiloInfoModels = Json<ConfigInfoModel>.Data.SiloInfoModels;
  24. RemoveCommand = new RelayCommand<object>((o) =>
  25. {
  26. if (!string.IsNullOrEmpty(o?.ToString()))
  27. {
  28. var res = Json<ConfigInfoModel>.Data.SiloInfoModels.FirstOrDefault(p => p.SiloName == o.ToString());
  29. if (res != null)
  30. {
  31. Json<ConfigInfoModel>.Data.SiloInfoModels.Remove(res);
  32. Control.GetInstance.NotifyPrompt($"{res.SiloName} 删除成功");
  33. Control.GetInstance.OperationLog($"{res.SiloName} 删除成功");
  34. }
  35. }
  36. });
  37. DetailsCommand = new RelayCommand<object>((o) =>
  38. {
  39. if (!string.IsNullOrEmpty(o?.ToString()))
  40. {
  41. var res = Json<ConfigInfoModel>.Data.SiloInfoModels.FirstOrDefault(p => p.SiloName == o.ToString());
  42. if (res != null)
  43. {
  44. NewSiloView newSiloView = new NewSiloView();
  45. ActionManage.GetInstance.Send("OpenNewSilo", res);
  46. newSiloView.ShowDialog();
  47. Control.GetInstance.OperationLog($"{res.SiloName} 编辑完成");
  48. }
  49. }
  50. });
  51. }
  52. public ObservableCollection<SiloInfoModel> SiloInfoModels { get; set; }
  53. }
  54. }