终端一体化运控平台
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

116 satır
3.4 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace BPASmart.UserManagement.ViewModel
  8. {
  9. [INotifyPropertyChanged]
  10. partial class EditPowerViewModel
  11. {
  12. /// <summary>
  13. /// 全部页面
  14. /// </summary>
  15. public ObservableCollection<pageName> pageList { get; set; } = new ObservableCollection<pageName>();
  16. /// <summary>
  17. /// 用户权限页面
  18. /// </summary>
  19. public ObservableCollection<pageName> userPageList { get; set; } = new ObservableCollection<pageName>();
  20. public ObservableCollection<string> UserNames { get; set; } = new ObservableCollection<string>();
  21. [ObservableProperty]
  22. private string _currentUserName;
  23. /// <summary>
  24. /// 保存
  25. /// </summary>
  26. [RelayCommand]
  27. private void SaveUserPower()
  28. {
  29. Globle.GlobleData.EditUser = null;
  30. ActionManage.GetInstance.Send("ChangeMianContent", string.Empty);
  31. }
  32. /// <summary>
  33. /// 取消
  34. /// </summary>
  35. [RelayCommand]
  36. private void Cancel()
  37. {
  38. ActionManage.GetInstance.Send("ChangeMianContent", string.Empty);
  39. }
  40. /// <summary>
  41. /// 添加全部界面
  42. /// </summary>
  43. [RelayCommand]
  44. private void AddAllPage()
  45. {
  46. userPageList.Clear();
  47. foreach(var item in pageList)
  48. {
  49. userPageList.Add(item);
  50. }
  51. }
  52. /// <summary>
  53. /// 删除全部界面
  54. /// </summary>
  55. [RelayCommand]
  56. private void DeleteAllPage()
  57. {
  58. userPageList.Clear();
  59. }
  60. [RelayCommand]
  61. private void AddPage(object o)
  62. {
  63. if (o == null) return;
  64. if (o is string materail)
  65. {
  66. var res = pageList.FirstOrDefault(p => p.Name == materail);
  67. if (userPageList.FirstOrDefault(p => p.Name == res.Name) == null)
  68. {
  69. userPageList.Add(res);
  70. }
  71. }
  72. }
  73. [RelayCommand]
  74. private void DeletePage(object o)
  75. {
  76. if (o == null) return;
  77. if (o is string materail)
  78. {
  79. var res = userPageList.FirstOrDefault(p => p.Name == materail);
  80. userPageList.Remove(res);
  81. }
  82. }
  83. public EditPowerViewModel()
  84. {
  85. pageList.Add(new pageName { Name = "主界面" });
  86. pageList.Add(new pageName { Name = "控制界面" });
  87. pageList.Add(new pageName { Name = "调试界面" });
  88. pageList.Add(new pageName { Name = "日志界面" });
  89. pageList.Add(new pageName { Name = "参数界面"});
  90. pageList.Add(new pageName { Name = "调试界面" });
  91. pageList.Add(new pageName { Name = "日志界面" });
  92. pageList.Add(new pageName { Name = "参数界面" });
  93. foreach(var item in Json<LocalUser>.Data.UserManagers)
  94. {
  95. UserNames.Add(item.UserName);
  96. }
  97. if (Globle.GlobleData.EditUser != null)
  98. {
  99. CurrentUserName = Globle.GlobleData.EditUser.UserName;
  100. }
  101. }
  102. }
  103. public class pageName
  104. {
  105. public string Name { get; set; }
  106. }
  107. }