终端一体化运控平台
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

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