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

78 lines
2.3 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.CustomResource.Pages.View;
  3. using Microsoft.Toolkit.Mvvm.Input;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Collections.ObjectModel;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace BPASmartClient.CustomResource.Pages.ViewModel
  11. {
  12. public class UserManagerViewModel
  13. {
  14. /// <summary>
  15. /// datagrid绑定
  16. /// </summary>
  17. public ObservableCollection<UserInfo> userManager { get; set; } = Global.userManager.userInfos;
  18. public RelayCommand<object> ChangePasswardCommand { get; set; }
  19. public RelayCommand AddNewUserCommand { get; set; }
  20. public RelayCommand<object> DeleteUserCommand { get; set; }
  21. public RelayCommand<object> EditUserConfigCommand { get; set; }
  22. private void ChangePassward(object o)
  23. {
  24. if (o != null && o is UserInfo infos)
  25. {
  26. Global.changeUserInfo = infos;
  27. PasswordChangeView passwordChangeView = new PasswordChangeView();
  28. passwordChangeView.ShowDialog();
  29. }
  30. }
  31. private void DeleteUser(object o)
  32. {
  33. if (o != null && o is UserInfo infos)
  34. {
  35. var res = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == infos.UserName);
  36. if (res != null) Global.userManager.userInfos.Remove(res);
  37. Config.GetInstance.SaveUser();
  38. }
  39. }
  40. private void EditUserConfig(object o)
  41. {
  42. if (o != null && o is UserInfo infos)
  43. {
  44. Global.changeUserInfo = null;
  45. Global.changeUserInfo = infos;
  46. UserConfigView userConfigView = new UserConfigView();
  47. userConfigView.ShowDialog();
  48. }
  49. }
  50. public UserManagerViewModel()
  51. {
  52. ChangePasswardCommand = new RelayCommand<object>(ChangePassward);
  53. AddNewUserCommand = new RelayCommand(() =>
  54. {
  55. AddNewUser addNewUser = new AddNewUser();
  56. addNewUser.ShowDialog();
  57. });
  58. DeleteUserCommand = new RelayCommand<object>(DeleteUser);
  59. EditUserConfigCommand = new RelayCommand<object>(EditUserConfig);
  60. }
  61. }
  62. }