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
{
///
/// 全部页面
///
public ObservableCollection pageList { get; set; } = new ObservableCollection();
///
/// 用户权限页面
///
public ObservableCollection userPageList { get; set; } = new ObservableCollection();
public ObservableCollection UserNames { get; set; } = new ObservableCollection();
[ObservableProperty]
private string _currentUserName;
///
/// 保存
///
[RelayCommand]
private void SaveUserPower()
{
Globle.GlobleData.EditUser = null;
ActionManage.GetInstance.Send("ChangeMianContent", string.Empty);
}
///
/// 取消
///
[RelayCommand]
private void Cancel()
{
ActionManage.GetInstance.Send("ChangeMianContent", string.Empty);
}
///
/// 添加全部界面
///
[RelayCommand]
private void AddAllPage()
{
userPageList.Clear();
foreach(var item in pageList)
{
userPageList.Add(item);
}
}
///
/// 删除全部界面
///
[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.Data.UserManagers)
{
UserNames.Add(item.UserName);
}
if (Globle.GlobleData.EditUser != null)
{
CurrentUserName = Globle.GlobleData.EditUser.UserName;
}
}
}
public class pageName
{
public string Name { get; set; }
}
}