设置中根据角色权限选择可操作的抽屉

This commit is contained in:
maqiao 2025-01-08 09:28:06 +08:00
parent 98e770854e
commit 83bbf8c453
20 changed files with 669 additions and 232 deletions

View File

@ -37,7 +37,7 @@
<!-- 按处方还药或者按取药记录还药 1:处方ReturnDrugWindow22药品ReturnDrugWindow-->
<add key="returnDrugMode" value="2" />
<!-- 自动退出时间单位秒为0时不自动退出 -->
<add key="autoExit" value="3"/>
<add key="autoExit" value="0"/>
<!-- 无操作退出录像时间单位秒为0时不退出录像 -->
<add key="stopRecord" value="0"/>

View File

@ -36,5 +36,11 @@ namespace DM_Weight.Models
///</summary>
[SugarColumn(ColumnName="machine_id" )]
public string MachineId { get; set; }
/// <summary>
/// 抽屉权限
/// </summary>
[SugarColumn(ColumnName = "drawer")]
public string drawer { get; set; }
}
}

View File

@ -90,8 +90,14 @@ namespace DM_Weight.ViewModels
AddQuantity = g.Sum(s => s.AddQuantity)
}).Select(cs => new ChannelStock() { DrugId = cs.DrugId, AddQuantity = cs.AddQuantity }).ToList();
RequestData();
drawerAuthority = HomeWindowViewModel.Operator.Role.drawer;
if (!string.IsNullOrEmpty(drawerAuthority))
{
drawerAuthorityList = drawerAuthority.Split(',');
}
}
string drawerAuthority = string.Empty;
string[] drawerAuthorityList;
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
IDialogService _dialogService;
@ -261,22 +267,22 @@ namespace DM_Weight.ViewModels
{
if (Status == 0)
{
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
if (bDrawer)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "当前用户没有打开抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
//if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
//{
// //查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
// bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
// if (bDrawer)
// {
// AlertMsg alertMsg = new AlertMsg
// {
// Message = "当前用户没有打开抽屉的权限!",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// return;
// }
}
//}
enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
enumerator = enumerable.GetEnumerator();
enumerator.MoveNext();
@ -291,6 +297,17 @@ namespace DM_Weight.ViewModels
{
IGrouping<int, ChannelStock> grouping = enumerator.Current;
int DrawerNo = grouping.Key;
bool hasAuthority=Array.Exists(drawerAuthorityList, element => element == DrawerNo.ToString());
if(!hasAuthority)
{
AlertMsg alertMsg = new AlertMsg
{
Message = $"当前用户没有打开{DrawerNo}号抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
List<ChannelStock> channelStocks = grouping.ToList();
channelStocks.ForEach(it => it.process = 1);
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");

View File

@ -508,22 +508,22 @@ namespace DM_Weight.ViewModels
{
if (Status == 0)
{
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
if (bDrawer)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "当前用户没有打开抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
//if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
//{
// //查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
// bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
// if (bDrawer)
// {
// AlertMsg alertMsg = new AlertMsg
// {
// Message = "当前用户没有打开抽屉的权限!",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// return;
// }
}
//}
if (AddChannels == null || AddChannels.Count <= 0)
{
AlertMsg alertMsg = new AlertMsg

View File

@ -108,21 +108,21 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand<string>((DrawerNo) =>
{
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
if (Convert.ToInt32(DrawerNo) > 3)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "当前用户没有打开抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
//if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
//{
// //查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
// if (Convert.ToInt32(DrawerNo) > 3)
// {
// AlertMsg alertMsg = new AlertMsg
// {
// Message = "当前用户没有打开抽屉的权限!",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// return;
// }
}
//}
this.DrawerNo = Convert.ToInt32(DrawerNo);
RequestData();
}, (DrawerNo) => Status == 0

View File

@ -199,21 +199,21 @@ namespace DM_Weight.ViewModels
{
if (Status == 0)
{
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
if (_ChannelStock.DrawerNo>3)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "当前用户没有打开抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
//if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
//{
// //查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
// if (_ChannelStock.DrawerNo>3)
// {
// AlertMsg alertMsg = new AlertMsg
// {
// Message = "当前用户没有打开抽屉的权限!",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// return;
// }
}
//}
Status = 1;
//_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");

View File

@ -24,7 +24,80 @@ namespace DM_Weight.ViewModels
private readonly ILog logger = LogManager.GetLogger(typeof(DrawerAddDrugWindowViewModel));
private List<int> _drawerNoList = new List<int>();
#region
/// <summary>
/// 1号抽屉
/// </summary>
private bool _Drawer1 = false;
public bool Drawer1
{
get { return _Drawer1; }
set { SetProperty(ref _Drawer1, value); }
}
/// <summary>
/// 2号抽屉
/// </summary>
private bool _Drawer2 = false;
public bool Drawer2
{
get { return _Drawer2; }
set { SetProperty(ref _Drawer2, value); }
}
/// <summary>
/// 3号抽屉
/// </summary>
private bool _Drawer3 = false;
public bool Drawer3
{
get { return _Drawer3; }
set { SetProperty(ref _Drawer3, value); }
}
/// <summary>
/// 4号抽屉
/// </summary>
private bool _Drawer4 = false;
public bool Drawer4
{
get { return _Drawer4; }
set { SetProperty(ref _Drawer4, value); }
}
/// <summary>
/// 5号抽屉
/// </summary>
private bool _Drawer5 = false;
public bool Drawer5
{
get { return _Drawer5; }
set { SetProperty(ref _Drawer5, value); }
}
/// <summary>
/// 6号抽屉
/// </summary>
private bool _Drawer6 = false;
public bool Drawer6
{
get { return _Drawer6; }
set { SetProperty(ref _Drawer6, value); }
}
/// <summary>
/// 7号抽屉
/// </summary>
private bool _Drawer7 = false;
public bool Drawer7
{
get { return _Drawer7; }
set { SetProperty(ref _Drawer7, value); }
}
/// <summary>
/// 8号抽屉
/// </summary>
private bool _Drawer8 = false;
public bool Drawer8
{
get { return _Drawer8; }
set { SetProperty(ref _Drawer8, value); }
}
#endregion
private List<ChannelStock>? _channelStocks;
public List<ChannelStock>? ChannelStocks
@ -129,21 +202,6 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand(() =>
{
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
if (DrawerNo > 3)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "当前用户没有打开抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
}
Status = 1;
try
@ -468,9 +526,51 @@ namespace DM_Weight.ViewModels
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
FindDrawerCount();
RequestData();
GetDrawer();
}
/// <summary>
/// 查询当前用户对应角色的抽屉权限
/// </summary>
void GetDrawer()
{
string drawerAuthority = HomeWindowViewModel.Operator.Role.drawer;
if (!string.IsNullOrEmpty(drawerAuthority))
{
string[] iList = drawerAuthority.Split(',');
foreach (string i in iList)
{
switch (i)
{
case "1":
Drawer1 = true;
break;
case "2":
Drawer2 = true;
break;
case "3":
Drawer3 = true;
break;
case "4":
Drawer4 = true;
break;
case "5":
Drawer5 = true;
break;
case "6":
Drawer6 = true;
break;
case "7":
Drawer7 = true;
break;
case "8":
Drawer8 = true;
break;
}
}
}
}
//每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建
public bool IsNavigationTarget(NavigationContext navigationContext)
{

View File

@ -27,7 +27,80 @@ namespace DM_Weight.ViewModels
public class DrawerTakeDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
{
private readonly ILog logger = LogManager.GetLogger(typeof(DrawerTakeDrugWindowViewModel));
#region
/// <summary>
/// 1号抽屉
/// </summary>
private bool _Drawer1 = false;
public bool Drawer1
{
get { return _Drawer1; }
set { SetProperty(ref _Drawer1, value); }
}
/// <summary>
/// 2号抽屉
/// </summary>
private bool _Drawer2 = false;
public bool Drawer2
{
get { return _Drawer2; }
set { SetProperty(ref _Drawer2, value); }
}
/// <summary>
/// 3号抽屉
/// </summary>
private bool _Drawer3 = false;
public bool Drawer3
{
get { return _Drawer3; }
set { SetProperty(ref _Drawer3, value); }
}
/// <summary>
/// 4号抽屉
/// </summary>
private bool _Drawer4 = false;
public bool Drawer4
{
get { return _Drawer4; }
set { SetProperty(ref _Drawer4, value); }
}
/// <summary>
/// 5号抽屉
/// </summary>
private bool _Drawer5 = false;
public bool Drawer5
{
get { return _Drawer5; }
set { SetProperty(ref _Drawer5, value); }
}
/// <summary>
/// 6号抽屉
/// </summary>
private bool _Drawer6 = false;
public bool Drawer6
{
get { return _Drawer6; }
set { SetProperty(ref _Drawer6, value); }
}
/// <summary>
/// 7号抽屉
/// </summary>
private bool _Drawer7 = false;
public bool Drawer7
{
get { return _Drawer7; }
set { SetProperty(ref _Drawer7, value); }
}
/// <summary>
/// 8号抽屉
/// </summary>
private bool _Drawer8 = false;
public bool Drawer8
{
get { return _Drawer8; }
set { SetProperty(ref _Drawer8, value); }
}
#endregion
private List<ChannelStock> _channelStocks = new List<ChannelStock>();
public List<ChannelStock> ChannelStocks
@ -70,7 +143,7 @@ namespace DM_Weight.ViewModels
if (Status == 2)
{
Status = 3;
}
}
//保存库存
SaveStock();
RequestData();
@ -139,21 +212,6 @@ namespace DM_Weight.ViewModels
{
if (Status == 0)
{
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
if (DrawerNo>3)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "当前用户没有打开抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
}
Status = 1;
//_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
@ -468,8 +526,52 @@ namespace DM_Weight.ViewModels
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
FindDrawerCount();
RequestData();
GetDrawer();
}
/// <summary>
/// 查询当前用户对应角色的抽屉权限
/// </summary>
void GetDrawer()
{
string drawerAuthority = HomeWindowViewModel.Operator.Role.drawer;
if (!string.IsNullOrEmpty(drawerAuthority))
{
string[] iList = drawerAuthority.Split(',');
foreach (string i in iList)
{
switch (i)
{
case "1":
Drawer1 = true;
break;
case "2":
Drawer2 = true;
break;
case "3":
Drawer3 = true;
break;
case "4":
Drawer4 = true;
break;
case "5":
Drawer5 = true;
break;
case "6":
Drawer6 = true;
break;
case "7":
Drawer7 = true;
break;
case "8":
Drawer8 = true;
break;
}
}
}
}
/// <param name="navigationContext"></param>
/// <returns></returns>
//每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建
public bool IsNavigationTarget(NavigationContext navigationContext)

View File

@ -175,22 +175,22 @@ namespace DM_Weight.ViewModels
{
if (Status == 0)
{
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
if (bDrawer)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "当前用户没有打开抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
//if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
//{
// //查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
// bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
// if (bDrawer)
// {
// AlertMsg alertMsg = new AlertMsg
// {
// Message = "当前用户没有打开抽屉的权限!",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// return;
// }
}
//}
enumerator.MoveNext();
Status = 1;
OpenOneByOne();

View File

@ -250,22 +250,22 @@ namespace DM_Weight.ViewModels
{
if (Status == 0)
{
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
if (bDrawer)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "当前用户没有打开抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
//if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
//{
// //查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
// bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
// if (bDrawer)
// {
// AlertMsg alertMsg = new AlertMsg
// {
// Message = "当前用户没有打开抽屉的权限!",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// return;
// }
}
//}
enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
enumerator = enumerable.GetEnumerator();
enumerator.MoveNext();

View File

@ -245,22 +245,22 @@ namespace DM_Weight.ViewModels
{
if (Status == 0)
{
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
if (bDrawer)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "当前用户没有打开抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
//if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
//{
// //查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
// bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
// if (bDrawer)
// {
// AlertMsg alertMsg = new AlertMsg
// {
// Message = "当前用户没有打开抽屉的权限!",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// return;
// }
}
//}
enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
enumerator = enumerable.GetEnumerator();
enumerator.MoveNext();

View File

@ -247,22 +247,22 @@ namespace DM_Weight.ViewModels
if (Status == 0)
{
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
if (bDrawer)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "当前用户没有打开抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
//if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
//{
// //查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
// bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
// if (bDrawer)
// {
// AlertMsg alertMsg = new AlertMsg
// {
// Message = "当前用户没有打开抽屉的权限!",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// return;
// }
}
//}
enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
enumerator = enumerable.GetEnumerator();

View File

@ -148,6 +148,8 @@ namespace DM_Weight.ViewModels
}
}
string drawerAuthority = string.Empty;
string[] drawerAuthorityList;
public bool CanCloseDialog()
{
@ -191,22 +193,35 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand(() =>
{
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
if (bDrawer)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "当前用户没有打开抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
//if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
//{
// //查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
// bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
// if (bDrawer)
// {
// AlertMsg alertMsg = new AlertMsg
// {
// Message = "当前用户没有打开抽屉的权限!",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// return;
// }
//}
bool hasAuthority = Array.Exists(drawerAuthorityList, element => element == ChannelStock.DrawerNo.ToString());
if (!hasAuthority)
{
AlertMsg alertMsg = new AlertMsg
{
Message = $"当前用户没有打开{ChannelStock.DrawerNo}号抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
if (ChannelStock != null)
{
Status = 1;

View File

@ -211,21 +211,21 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand(() =>
{
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
if (ChannelStock.DrawerNo>3)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "当前用户没有打开抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
//if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
//{
// //查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
// if (ChannelStock.DrawerNo>3)
// {
// AlertMsg alertMsg = new AlertMsg
// {
// Message = "当前用户没有打开抽屉的权限!",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// return;
// }
}
//}
if (ChannelStock != null)
{
if (Status == 0)

View File

@ -18,6 +18,7 @@ using System.Data;
using System.Configuration;
using MaterialDesignThemes.Wpf;
using System.Windows.Media;
using System.Windows.Data;
namespace DM_Weight.ViewModels
{
@ -56,8 +57,80 @@ namespace DM_Weight.ViewModels
SetProperty(ref _role, value);
}
}
#region
/// <summary>
/// 1号抽屉
/// </summary>
private bool _Drawer1=false;
public bool Drawer1
{
get { return _Drawer1; }
set { SetProperty(ref _Drawer1, value); }
}
/// <summary>
/// 2号抽屉
/// </summary>
private bool _Drawer2 = false;
public bool Drawer2
{
get { return _Drawer2; }
set { SetProperty(ref _Drawer2, value); }
}
/// <summary>
/// 3号抽屉
/// </summary>
private bool _Drawer3= false;
public bool Drawer3
{
get { return _Drawer3; }
set { SetProperty(ref _Drawer3, value); }
}
/// <summary>
/// 4号抽屉
/// </summary>
private bool _Drawer4 = false;
public bool Drawer4
{
get { return _Drawer4; }
set { SetProperty(ref _Drawer4, value); }
}
/// <summary>
/// 5号抽屉
/// </summary>
private bool _Drawer5= false;
public bool Drawer5
{
get { return _Drawer5; }
set { SetProperty(ref _Drawer5, value); }
}
/// <summary>
/// 6号抽屉
/// </summary>
private bool _Drawer6 = false;
public bool Drawer6
{
get { return _Drawer6; }
set { SetProperty(ref _Drawer6, value); }
}
/// <summary>
/// 7号抽屉
/// </summary>
private bool _Drawer7= false;
public bool Drawer7
{
get { return _Drawer7; }
set { SetProperty(ref _Drawer7, value); }
}
/// <summary>
/// 8号抽屉
/// </summary>
private bool _Drawer8 = false;
public bool Drawer8
{
get { return _Drawer8; }
set { SetProperty(ref _Drawer8, value); }
}
#endregion
private void CompareList(RoleDm Role)
{
@ -135,6 +208,64 @@ namespace DM_Weight.ViewModels
}
});
RightPremissions = new ObservableCollection<PremissionDm>(Permissions);
if(Role.drawer!=null)
{
SetDrawerChecked("");
SetDrawerChecked(Role.drawer);
}
else
{
SetDrawerChecked("");
}
}
}
void SetDrawerChecked(string drawer)
{
if(!string.IsNullOrEmpty(drawer))
{
string[] iList=drawer.Split(',');
foreach (string i in iList)
{
switch (i)
{
case "1":
Drawer1= true;
break;
case "2":
Drawer2= true;
break;
case "3":
Drawer3= true;
break;
case "4":
Drawer4= true;
break;
case "5":
Drawer5= true;
break;
case "6":
Drawer6= true;
break;
case "7":
Drawer7= true;
break;
case "8":
Drawer8= true;
break;
}
}
}
else
{
Drawer1= false;
Drawer2= false;
Drawer3 = false;
Drawer4= false;
Drawer5= false;
Drawer6= false;
Drawer7 = false;
Drawer8= false;
}
}
@ -754,6 +885,7 @@ namespace DM_Weight.ViewModels
Role.Id = 0;
Role.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
Role.Permissions = RightPremissions.ToList();
Role.drawer = GetDrawer();
List<RoleDm> roleList = SqlSugarHelper.Db.Queryable<RoleDm>().Where(r => r.RoleName == Role.RoleName).ToList();
if (roleList.Count > 0)
{
@ -771,11 +903,48 @@ namespace DM_Weight.ViewModels
get => new DelegateCommand(() =>
{
Role.Permissions = RightPremissions.ToList();
Role.drawer = GetDrawer();
SqlSugarHelper.Db.Updateable<RoleDm>(Role).ExecuteCommand();
RequestData();
});
}
string GetDrawer()
{
string strDrawer = string.Empty;
if(Drawer1)
{
strDrawer += "1,";
}
if(Drawer2)
{
strDrawer += "2,";
}
if(Drawer3)
{
strDrawer += "3,";
}
if(Drawer4)
{
strDrawer += "4,";
}
if(Drawer5)
{
strDrawer += "5,";
}
if(Drawer6)
{
strDrawer += "6,";
}
if(Drawer7)
{
strDrawer += "7,";
}
if(Drawer8)
{
strDrawer += "8";
}
return strDrawer;
}
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
{

View File

@ -169,22 +169,22 @@ namespace DM_Weight.ViewModels
{
if (Status == 0)
{
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
if (bDrawer)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "当前用户没有打开抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
//if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
//{
// //查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
// bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
// if (bDrawer)
// {
// AlertMsg alertMsg = new AlertMsg
// {
// Message = "当前用户没有打开抽屉的权限!",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// return;
// }
}
//}
enumerator.MoveNext();
Status = 1;
OpenOneByOne();

View File

@ -164,22 +164,22 @@ namespace DM_Weight.ViewModels
{
if (Status == 0)
{
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
if (bDrawer)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "当前用户没有打开抽屉的权限!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
//if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
//{
// //查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
// bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 3).Any();
// if (bDrawer)
// {
// AlertMsg alertMsg = new AlertMsg
// {
// Message = "当前用户没有打开抽屉的权限!",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// return;
// }
}
//}
enumerator.MoveNext();
Status = 1;
OpenOneByOne();

View File

@ -63,14 +63,14 @@
</Style.Triggers>
</Style>
</Grid.Resources>
<Button Grid.Row="0" Width="210" Content="1" Command="{Binding UpdateDrawerNo}" CommandParameter="1" />
<Button Grid.Row="1" Width="210" Content="2" Command="{Binding UpdateDrawerNo}" CommandParameter="2" />
<Button Grid.Row="2" Width="210" Content="3" Command="{Binding UpdateDrawerNo}" CommandParameter="3" />
<Button Grid.Row="3" Width="210" Content="4" Command="{Binding UpdateDrawerNo}" CommandParameter="4" />
<Button Grid.Row="4" Width="210" Content="5" Command="{Binding UpdateDrawerNo}" CommandParameter="5" />
<Button Grid.Row="5" Width="210" Content="6" Command="{Binding UpdateDrawerNo}" CommandParameter="6" />
<Button Grid.Row="6" Width="210" Content="7" Command="{Binding UpdateDrawerNo}" CommandParameter="7" />
<Button Grid.Row="7" Width="210" Content="8" Command="{Binding UpdateDrawerNo}" CommandParameter="8" />
<Button Grid.Row="0" Width="210" Content="1" IsEnabled="{Binding Drawer1}" Command="{Binding UpdateDrawerNo}" CommandParameter="1" />
<Button Grid.Row="1" Width="210" Content="2" IsEnabled="{Binding Drawer2}" Command="{Binding UpdateDrawerNo}" CommandParameter="2" />
<Button Grid.Row="2" Width="210" Content="3" IsEnabled="{Binding Drawer3}" Command="{Binding UpdateDrawerNo}" CommandParameter="3" />
<Button Grid.Row="3" Width="210" Content="4" IsEnabled="{Binding Drawer4}" Command="{Binding UpdateDrawerNo}" CommandParameter="4" />
<Button Grid.Row="4" Width="210" Content="5" IsEnabled="{Binding Drawer5}" Command="{Binding UpdateDrawerNo}" CommandParameter="5" />
<Button Grid.Row="5" Width="210" Content="6" IsEnabled="{Binding Drawer6}" Command="{Binding UpdateDrawerNo}" CommandParameter="6" />
<Button Grid.Row="6" Width="210" Content="7" IsEnabled="{Binding Drawer7}" Command="{Binding UpdateDrawerNo}" CommandParameter="7" />
<Button Grid.Row="7" Width="210" Content="8" IsEnabled="{Binding Drawer8}" Command="{Binding UpdateDrawerNo}" CommandParameter="8" />
</Grid>
</Grid>

View File

@ -61,14 +61,14 @@
</Style.Triggers>
</Style>
</Grid.Resources>
<Button Grid.Row="0" Width="210" Content="1" Command="{Binding UpdateDrawerNo}" CommandParameter="1" />
<Button Grid.Row="1" Width="210" Content="2" Command="{Binding UpdateDrawerNo}" CommandParameter="2" />
<Button Grid.Row="2" Width="210" Content="3" Command="{Binding UpdateDrawerNo}" CommandParameter="3" />
<Button Grid.Row="3" Width="210" Content="4" Command="{Binding UpdateDrawerNo}" CommandParameter="4" />
<Button Grid.Row="4" Width="210" Content="5" Command="{Binding UpdateDrawerNo}" CommandParameter="5" />
<Button Grid.Row="5" Width="210" Content="6" Command="{Binding UpdateDrawerNo}" CommandParameter="6" />
<Button Grid.Row="6" Width="210" Content="7" Command="{Binding UpdateDrawerNo}" CommandParameter="7" />
<Button Grid.Row="7" Width="210" Content="8" Command="{Binding UpdateDrawerNo}" CommandParameter="8" />
<Button Grid.Row="0" Width="210" Content="1" IsEnabled="{Binding Drawer1}" Command="{Binding UpdateDrawerNo}" CommandParameter="1" />
<Button Grid.Row="1" Width="210" Content="2" IsEnabled="{Binding Drawer2}" Command="{Binding UpdateDrawerNo}" CommandParameter="2" />
<Button Grid.Row="2" Width="210" Content="3" IsEnabled="{Binding Drawer3}" Command="{Binding UpdateDrawerNo}" CommandParameter="3" />
<Button Grid.Row="3" Width="210" Content="4" IsEnabled="{Binding Drawer4}" Command="{Binding UpdateDrawerNo}" CommandParameter="4" />
<Button Grid.Row="4" Width="210" Content="5" IsEnabled="{Binding Drawer5}" Command="{Binding UpdateDrawerNo}" CommandParameter="5" />
<Button Grid.Row="5" Width="210" Content="6" IsEnabled="{Binding Drawer6}" Command="{Binding UpdateDrawerNo}" CommandParameter="6" />
<Button Grid.Row="6" Width="210" Content="7" IsEnabled="{Binding Drawer7}" Command="{Binding UpdateDrawerNo}" CommandParameter="7" />
<Button Grid.Row="7" Width="210" Content="8" IsEnabled="{Binding Drawer8}" Command="{Binding UpdateDrawerNo}" CommandParameter="8" />
</Grid>
</Grid>

View File

@ -101,12 +101,40 @@
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBox
Grid.Column="0" Margin="10"
Grid.Column="0" Margin="10" Grid.Row="0"
Text="{Binding Role.RoleName}"
materialDesign:HintAssist.Hint="角色名"
Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="10" HorizontalAlignment="Right" VerticalAlignment="Center">
<!-- piece together your own items control to create some nice stuff that will make everyone think you are cool. and rightly so, because you are cool. you might even be a hipster for all I know -->
<StackPanel Margin="10" Orientation="Horizontal" Grid.Row="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<!--<ColumnDefinition/>-->
</Grid.ColumnDefinitions>
<CheckBox Margin="0 0 3 9" Grid.Row="0" Grid.Column="0" IsChecked="{Binding Drawer1}" Content="1号抽屉" />
<CheckBox Margin="0 0 3 9" Grid.Row="0" Grid.Column="1" IsChecked="{Binding Drawer2}" Content="2号抽屉" />
<CheckBox Margin="0 0 3 9" Grid.Row="0" Grid.Column="2" IsChecked="{Binding Drawer3}" Content="3号抽屉" />
<CheckBox Margin="0 0 3 9" Grid.Row="1" Grid.Column="0" IsChecked="{Binding Drawer4}" Content="4号抽屉" />
<CheckBox Margin="0 0 3 9" Grid.Row="1" Grid.Column="1" IsChecked="{Binding Drawer5}" Content="5号抽屉" />
<CheckBox Margin="0 0 3 9" Grid.Row="1" Grid.Column="2" IsChecked="{Binding Drawer6}" Content="6号抽屉" />
<CheckBox Margin="0 0 3 9" Grid.Row="2" Grid.Column="0" IsChecked="{Binding Drawer7}" Content="7号抽屉" />
<CheckBox Margin="0 0 3 9" Grid.Row="2" Grid.Column="1" IsChecked="{Binding Drawer8}" Content="8号抽屉" />
</Grid>
</StackPanel>
<StackPanel Grid.Column="1" Grid.RowSpan="2" Orientation="Horizontal" Margin="10" HorizontalAlignment="Right" VerticalAlignment="Center">
<Button
Margin="6"
Command="{Binding EditRole}"