瀏覽代碼

用户权限管理控制

样式分支
pry 2 年之前
父節點
當前提交
ec683bd2fe
共有 4 個檔案被更改,包括 77 行新增32 行删除
  1. +2
    -2
      BPASmartClient.CustomResource/Pages/Model/MenuManage.cs
  2. +1
    -1
      BPASmartClient.CustomResource/Pages/Model/UserInfo.cs
  3. +53
    -14
      BPASmartClient.CustomResource/Pages/ViewModel/LoginViewModel.cs
  4. +21
    -15
      DosingSystem/App.xaml.cs

+ 2
- 2
BPASmartClient.CustomResource/Pages/Model/MenuManage.cs 查看文件

@@ -75,7 +75,7 @@ namespace BPASmartClient.CustomResource.Pages.Model
/// 主菜单的显示隐藏设置
/// </summary>
public Visibility MainMenuVisibility { get { return _mMainMenuVisibility; } set { _mMainMenuVisibility = value; OnPropertyChanged(); } }
private Visibility _mMainMenuVisibility;
private Visibility _mMainMenuVisibility = Visibility.Visible;

/// <summary>
/// 子菜单集合
@@ -114,7 +114,7 @@ namespace BPASmartClient.CustomResource.Pages.Model
/// 子菜单的显示隐藏设置
/// </summary>
public Visibility SubMenuVisibility { get { return _mSubMenuVisibility; } set { _mSubMenuVisibility = value; OnPropertyChanged(); } }
private Visibility _mSubMenuVisibility = Visibility.Collapsed;
private Visibility _mSubMenuVisibility = Visibility.Visible;





+ 1
- 1
BPASmartClient.CustomResource/Pages/Model/UserInfo.cs 查看文件

@@ -22,7 +22,7 @@ namespace BPASmartClient.CustomResource.Pages.Model
private Permission _perimission;

public string UserName { get { return _userName; } set { _userName = value; OnPropertyChanged(); } }
private string _userName ;
private string _userName;

public string Password { get { return _password; } set { _password = value; OnPropertyChanged(); } }
private string _password;


+ 53
- 14
BPASmartClient.CustomResource/Pages/ViewModel/LoginViewModel.cs 查看文件

@@ -85,25 +85,52 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
Global.userInfo.LastLogInTime = DateTime.Now.ToString();
res.LastLogInTime = DateTime.Now.ToString();
Config.GetInstance.SaveUser();

//permission权限
for (int i = 0; i < MenuManage.GetInstance.menuModels.Count; i++)
if (res.userTreeViewModels != null)
{
if (MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuPermission.Contains(res.permission))
MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Visible;
else
MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Collapsed;

if (MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.FirstOrDefault(p => p.SubMenuPermission.Contains(res.permission)) == null)
MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Collapsed;

for (int m = 0; m < MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.Count; m++)
VisibilityState(Visibility.Collapsed);
for (int i = 0; i < res.userTreeViewModels?.Count; i++)
{
if (MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuPermission.Contains(res.permission))
MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = Visibility.Visible;
else
MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = Visibility.Collapsed;
var menName = res.userTreeViewModels.ElementAt(i).Name;//获取子菜单的名称

var res1 = MenuManage.GetInstance.menuModels.FirstOrDefault(p => p.subMenumodels.FirstOrDefault(s => s.SubMenuName.Equals(menName)) != null);//通过子菜单获取主菜单的信息
if (res1 != null)
{
res1.MainMenuVisibility = Visibility.Visible;
var res2 = res1.subMenumodels.FirstOrDefault(p => p.SubMenuName.Equals(menName));
if (res2 != null) res2.SubMenuVisibility = Visibility.Visible;
}
}
}
else
{
VisibilityState(Visibility.Visible);
}





//permission权限
//for (int i = 0; i < MenuManage.GetInstance.menuModels.Count; i++)
//{
// if (MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuPermission.Contains(res.permission))
// MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Visible;
// else
// MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Collapsed;

// if (MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.FirstOrDefault(p => p.SubMenuPermission.Contains(res.permission)) == null)
// MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Collapsed;

// for (int m = 0; m < MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.Count; m++)
// {
// if (MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuPermission.Contains(res.permission))
// MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = Visibility.Visible;
// else
// MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = Visibility.Collapsed;
// }
//}

////分配后的权限
//if (res.permission == Enums.Permission.管理员)
@@ -149,6 +176,18 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
}
}

private void VisibilityState(Visibility tempVisibility)
{
for (int i = 0; i < MenuManage.GetInstance.menuModels.Count; i++)
{
MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = tempVisibility;
for (int m = 0; m < MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.Count; m++)
{
MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = tempVisibility;
}
}
}

public RelayCommand LoginCommand { get; set; }

public RelayCommand ExitCommand { get; set; }


+ 21
- 15
DosingSystem/App.xaml.cs 查看文件

@@ -62,7 +62,7 @@ namespace BPASmartClient.DosingSystem
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "配方管理",
SubMenuPermission = new Permission[] { Permission.管理员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.RecipeSettingsView"
});
@@ -70,7 +70,7 @@ namespace BPASmartClient.DosingSystem
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "配方下发",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.RecipeControlView"
});
@@ -78,6 +78,7 @@ namespace BPASmartClient.DosingSystem
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "&#xe683;",
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
MainMenuName = "配方管理",
Alias = "Recipe Management",
subMenumodels = RecipeManage,
@@ -89,7 +90,7 @@ namespace BPASmartClient.DosingSystem
ParSet.Add(new SubMenumodel()
{
SubMenuName = "原料参数设置",
SubMenuPermission = new Permission[] { Permission.管理员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.DeviceMaterialParView"
});
@@ -97,7 +98,7 @@ namespace BPASmartClient.DosingSystem
ParSet.Add(new SubMenumodel()
{
SubMenuName = "设备参数设置",
SubMenuPermission = new Permission[] { Permission.管理员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.CommParSetView"
});
@@ -113,6 +114,7 @@ namespace BPASmartClient.DosingSystem
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "&#xe62d;",
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
MainMenuName = "参数设置",
Alias = "Parameter Set",
subMenumodels = ParSet,
@@ -124,7 +126,7 @@ namespace BPASmartClient.DosingSystem
ManualControl.Add(new SubMenumodel()
{
SubMenuName = "气缸手动控制",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.ManualControlView"
});
@@ -132,7 +134,7 @@ namespace BPASmartClient.DosingSystem
ManualControl.Add(new SubMenumodel()
{
SubMenuName = "输送带手动控制",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.ConveyerBeltManualView"
});
@@ -147,6 +149,7 @@ namespace BPASmartClient.DosingSystem
{
MainMenuIcon = "&#xe622;",
MainMenuName = "手动控制",
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
Alias = "Parameter Set",
subMenumodels = ManualControl,
});
@@ -157,7 +160,7 @@ namespace BPASmartClient.DosingSystem
InfoLog.Add(new SubMenumodel()
{
SubMenuName = "操作日志",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.UserLogView"
});
@@ -165,7 +168,7 @@ namespace BPASmartClient.DosingSystem
InfoLog.Add(new SubMenumodel()
{
SubMenuName = "运行日志",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.RunLogView"
});
@@ -173,7 +176,7 @@ namespace BPASmartClient.DosingSystem
InfoLog.Add(new SubMenumodel()
{
SubMenuName = "报警记录",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.AlarmView"
});
@@ -181,7 +184,7 @@ namespace BPASmartClient.DosingSystem
InfoLog.Add(new SubMenumodel()
{
SubMenuName = "调试日志",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.DebugLogView"
});
@@ -198,6 +201,7 @@ namespace BPASmartClient.DosingSystem
{
MainMenuIcon = "&#xe668;",
MainMenuName = "消息日志",
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
Alias = "Message Log",
subMenumodels = InfoLog,
});
@@ -208,7 +212,7 @@ namespace BPASmartClient.DosingSystem
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "原料设备列表",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.DeviceListView"
});
@@ -216,7 +220,7 @@ namespace BPASmartClient.DosingSystem
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "设备状态",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.HardwareStatusView"
});
@@ -225,6 +229,7 @@ namespace BPASmartClient.DosingSystem
{
MainMenuIcon = "&#xe603;",
MainMenuName = "设备监控",
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
Alias = "Device Monitor",
subMenumodels = DeviceMonitor,
});
@@ -235,7 +240,7 @@ namespace BPASmartClient.DosingSystem
UserManager.Add(new SubMenumodel()
{
SubMenuName = "用户登录",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.SubPagLoginView"
});
@@ -243,14 +248,14 @@ namespace BPASmartClient.DosingSystem
UserManager.Add(new SubMenumodel()
{
SubMenuName = "密码修改",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.PasswordChangeView"
});
UserManager.Add(new SubMenumodel()
{
SubMenuName = "用户管理",
SubMenuPermission = new Permission[] { Permission.管理员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.UserManagerView"
});
@@ -267,6 +272,7 @@ namespace BPASmartClient.DosingSystem
{
MainMenuIcon = "&#xe66d;",
MainMenuName = "用户管理",
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
Alias = "User Management",
subMenumodels = UserManager,
});


Loading…
取消
儲存