角色管理页面1)修复bug,先中角色中全部菜单菜单中会包含已选过的菜单的子菜单的第一个页面
2)添加不可重复添加同角色名的角色校验
This commit is contained in:
parent
4d2e593f53
commit
eae6d92837
|
@ -16,6 +16,8 @@ using DM_Weight.Models;
|
||||||
using DM_Weight.util;
|
using DM_Weight.util;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
|
using MaterialDesignThemes.Wpf;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace DM_Weight.ViewModels
|
namespace DM_Weight.ViewModels
|
||||||
{
|
{
|
||||||
|
@ -83,7 +85,7 @@ namespace DM_Weight.ViewModels
|
||||||
{
|
{
|
||||||
int i = p.Children.ToList().FindIndex(it4 => it4.Id == it3.Id);
|
int i = p.Children.ToList().FindIndex(it4 => it4.Id == it3.Id);
|
||||||
//if (i > 0 && AllPremissions.ElementAt(index).Children.Count > i)
|
//if (i > 0 && AllPremissions.ElementAt(index).Children.Count > i)
|
||||||
if (p.Children[i]!=null)
|
if (p.Children.Count > 0 && i >= 0 && p.Children[i] != null)
|
||||||
{
|
{
|
||||||
AllPremissions.ElementAt(index).Children.RemoveAt(i);
|
AllPremissions.ElementAt(index).Children.RemoveAt(i);
|
||||||
}
|
}
|
||||||
|
@ -598,6 +600,20 @@ namespace DM_Weight.ViewModels
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
|
||||||
|
public ISnackbarMessageQueue SnackbarMessageQueue
|
||||||
|
{
|
||||||
|
get => _snackbarMessageQueue;
|
||||||
|
set => SetProperty(ref _snackbarMessageQueue, value);
|
||||||
|
}
|
||||||
|
private SolidColorBrush _colorBrush;
|
||||||
|
|
||||||
|
public SolidColorBrush SnackbarBackground
|
||||||
|
{
|
||||||
|
get => _colorBrush;
|
||||||
|
set => SetProperty(ref _colorBrush, value);
|
||||||
|
}
|
||||||
|
|
||||||
public DelegateCommand AddRole
|
public DelegateCommand AddRole
|
||||||
{
|
{
|
||||||
get => new DelegateCommand(() =>
|
get => new DelegateCommand(() =>
|
||||||
|
@ -605,6 +621,13 @@ namespace DM_Weight.ViewModels
|
||||||
Role.Id = 0;
|
Role.Id = 0;
|
||||||
Role.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
|
Role.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
|
||||||
Role.Permissions = RightPremissions.ToList();
|
Role.Permissions = RightPremissions.ToList();
|
||||||
|
List<RoleDm> roleList = SqlSugarHelper.Db.Queryable<RoleDm>().Where(r => r.RoleName == Role.RoleName).ToList();
|
||||||
|
if (roleList.Count > 0)
|
||||||
|
{
|
||||||
|
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
|
||||||
|
SnackbarMessageQueue.Enqueue("该角色已存在!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
SqlSugarHelper.Db.Insertable<RoleDm>(Role).ExecuteCommand();
|
SqlSugarHelper.Db.Insertable<RoleDm>(Role).ExecuteCommand();
|
||||||
RequestData();
|
RequestData();
|
||||||
});
|
});
|
||||||
|
|
|
@ -189,5 +189,8 @@
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
<materialDesign:Snackbar
|
||||||
|
Background="{Binding SnackbarBackground}"
|
||||||
|
MessageQueue="{Binding SnackbarMessageQueue}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
Loading…
Reference in New Issue