终端一体化运控平台
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.
 
 
 

63 lines
2.4 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using BPA.Helper;
  7. using BPASmartClient.SmallBatchingSystem.Views;
  8. using System.Collections.ObjectModel;
  9. using BPA.Helper;
  10. using BPASmartClient.CustomResource.Pages.Model;
  11. namespace BPASmartClient.SmallBatchingSystem.ViewModels
  12. {
  13. public class SiloManagementViewModel : BaseModel
  14. {
  15. public SiloManagementViewModel()
  16. {
  17. AddCommand = new BPARelayCommand(() =>
  18. {
  19. NewSiloView newSiloView = new NewSiloView();
  20. newSiloView.ShowDialog();
  21. });
  22. SaveCommand = new BPARelayCommand(() => { Json<ConfigInfoModel>.Save(); });
  23. SiloInfoModels = Json<ConfigInfoModel>.Data.SiloInfoModels;
  24. RemoveCommand = new BPARelayCommand<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. if (MessageNotify.GetInstance.ShowDialog($"是否删除【{res.SiloName}】原料,删除后数据将永久丢失!无法找回", DialogType.Warning))
  32. {
  33. Json<ConfigInfoModel>.Data.SiloInfoModels.Remove(res);
  34. Control.GetInstance.NotifyPrompt($"{res.SiloName} 删除成功");
  35. Control.GetInstance.OperationLog($"{res.SiloName} 删除成功");
  36. }
  37. }
  38. }
  39. });
  40. DetailsCommand = new BPARelayCommand<object>((o) =>
  41. {
  42. if (!string.IsNullOrEmpty(o?.ToString()))
  43. {
  44. var res = Json<ConfigInfoModel>.Data.SiloInfoModels.FirstOrDefault(p => p.SiloName == o.ToString());
  45. if (res != null)
  46. {
  47. NewSiloView newSiloView = new NewSiloView();
  48. ActionManage.GetInstance.Send("OpenNewSilo", res);
  49. newSiloView.ShowDialog();
  50. Control.GetInstance.OperationLog($"{res.SiloName} 编辑完成");
  51. }
  52. }
  53. });
  54. }
  55. public ObservableCollection<SiloInfoModel> SiloInfoModels { get; set; }
  56. }
  57. }