|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmart.UserManagement.ViewModel
- {
- [INotifyPropertyChanged]
- partial class EditPowerViewModel
- {
- /// <summary>
- /// 全部页面
- /// </summary>
- public ObservableCollection<pageName> pageList { get; set; } = new ObservableCollection<pageName>();
- /// <summary>
- /// 用户权限页面
- /// </summary>
- public ObservableCollection<pageName> userPageList { get; set; } = new ObservableCollection<pageName>();
-
- public ObservableCollection<string> UserNames { get; set; } = new ObservableCollection<string>();
-
- [ObservableProperty]
- private string _currentUserName;
- /// <summary>
- /// 保存
- /// </summary>
- [RelayCommand]
- private void SaveUserPower()
- {
-
- Globle.GlobleData.EditUser = null;
- ActionManage.GetInstance.Send("ChangeMianContent", string.Empty);
- }
- /// <summary>
- /// 取消
- /// </summary>
- [RelayCommand]
- private void Cancel()
- {
- ActionManage.GetInstance.Send("ChangeMianContent", string.Empty);
- }
-
- /// <summary>
- /// 添加全部界面
- /// </summary>
- [RelayCommand]
- private void AddAllPage()
- {
- userPageList.Clear();
- foreach(var item in pageList)
- {
- userPageList.Add(item);
- }
- }
- /// <summary>
- /// 删除全部界面
- /// </summary>
- [RelayCommand]
- private void DeleteAllPage()
- {
- userPageList.Clear();
- }
- [RelayCommand]
- private void AddPage(object o)
- {
- if (o == null) return;
- if (o is string materail)
- {
- var res = pageList.FirstOrDefault(p => p.Name == materail);
- if (userPageList.FirstOrDefault(p => p.Name == res.Name) == null)
- {
- userPageList.Add(res);
- }
- }
- }
- [RelayCommand]
- private void DeletePage(object o)
- {
- if (o == null) return;
- if (o is string materail)
- {
- var res = userPageList.FirstOrDefault(p => p.Name == materail);
- userPageList.Remove(res);
- }
- }
-
- public EditPowerViewModel()
- {
- pageList.Add(new pageName { Name = "主界面" });
- pageList.Add(new pageName { Name = "控制界面" });
- pageList.Add(new pageName { Name = "调试界面" });
- pageList.Add(new pageName { Name = "日志界面" });
- pageList.Add(new pageName { Name = "参数界面"});
- pageList.Add(new pageName { Name = "调试界面" });
- pageList.Add(new pageName { Name = "日志界面" });
- pageList.Add(new pageName { Name = "参数界面" });
-
- foreach(var item in Json<LocalUser>.Data.UserManagers)
- {
- UserNames.Add(item.UserName);
- }
- if (Globle.GlobleData.EditUser != null)
- {
- CurrentUserName = Globle.GlobleData.EditUser.UserName;
- }
- }
- }
-
- public class pageName
- {
- public string Name { get; set; }
- }
- }
|