From 83bbf8c453f72cf5c40156845475f23fd2b51c29 Mon Sep 17 00:00:00 2001
From: maqiao <625215135@qq.com>
Date: Wed, 8 Jan 2025 09:28:06 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=AD=E6=A0=B9=E6=8D=AE?=
=?UTF-8?q?=E8=A7=92=E8=89=B2=E6=9D=83=E9=99=90=E9=80=89=E6=8B=A9=E5=8F=AF?=
=?UTF-8?q?=E6=93=8D=E4=BD=9C=E7=9A=84=E6=8A=BD=E5=B1=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DM_Weight/App.config | 2 +-
DM_Weight/Models/RoleDm.cs | 6 +
.../ViewModels/AddToJiaoJieDialogViewModel.cs | 49 +++--
.../ViewModels/ApplyInStockWindowViewModel.cs | 30 +--
.../ViewModels/CheckStockWindowViewModel.cs | 28 +--
.../ViewModels/DestoryEmptyDialogViewModel.cs | 28 +--
.../DrawerAddDrugWindowViewModel.cs | 132 +++++++++++--
.../DrawerTakeDrugWindowViewModel.cs | 136 ++++++++++++--
.../ViewModels/InvoiceAddDialogViewModel.cs | 30 +--
.../ViewModels/InvoiceTakeDialogViewModel.cs | 30 +--
.../ViewModels/OrderReturnDialogViewModel.cs | 30 +--
.../ViewModels/OrderTakeDialogViewModel.cs | 30 +--
.../ViewModels/ReturnDrugDialogViewModel.cs | 43 +++--
.../ViewModels/ReturnEmptyDialogViewModel.cs | 28 +--
.../ViewModels/RoleManagerWindowViewModel.cs | 175 +++++++++++++++++-
.../ViewModels/SelfAddDialogViewModel.cs | 30 +--
.../ViewModels/SelfTakeDialogViewModel.cs | 30 +--
DM_Weight/Views/DrawerAddDrugWindow.xaml | 16 +-
DM_Weight/Views/DrawerTakeDrugWindow.xaml | 16 +-
DM_Weight/Views/RoleManagerWindow.xaml | 32 +++-
20 files changed, 669 insertions(+), 232 deletions(-)
diff --git a/DM_Weight/App.config b/DM_Weight/App.config
index c7db2fb..4e54c67 100644
--- a/DM_Weight/App.config
+++ b/DM_Weight/App.config
@@ -37,7 +37,7 @@
-
+
diff --git a/DM_Weight/Models/RoleDm.cs b/DM_Weight/Models/RoleDm.cs
index ce3e319..64c8e9e 100644
--- a/DM_Weight/Models/RoleDm.cs
+++ b/DM_Weight/Models/RoleDm.cs
@@ -36,5 +36,11 @@ namespace DM_Weight.Models
///
[SugarColumn(ColumnName="machine_id" )]
public string MachineId { get; set; }
+
+ ///
+ /// 抽屉权限
+ ///
+ [SugarColumn(ColumnName = "drawer")]
+ public string drawer { get; set; }
}
}
diff --git a/DM_Weight/ViewModels/AddToJiaoJieDialogViewModel.cs b/DM_Weight/ViewModels/AddToJiaoJieDialogViewModel.cs
index 87fcc4f..46fda43 100644
--- a/DM_Weight/ViewModels/AddToJiaoJieDialogViewModel.cs
+++ b/DM_Weight/ViewModels/AddToJiaoJieDialogViewModel.cs
@@ -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().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().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 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().Publish(alertMsg);
+ return;
+ }
List channelStocks = grouping.ToList();
channelStocks.ForEach(it => it.process = 1);
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
diff --git a/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs b/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs
index 0220bab..2dd8f4e 100644
--- a/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs
+++ b/DM_Weight/ViewModels/ApplyInStockWindowViewModel.cs
@@ -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().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().Publish(alertMsg);
+ // return;
+ // }
- }
+ //}
if (AddChannels == null || AddChannels.Count <= 0)
{
AlertMsg alertMsg = new AlertMsg
diff --git a/DM_Weight/ViewModels/CheckStockWindowViewModel.cs b/DM_Weight/ViewModels/CheckStockWindowViewModel.cs
index 4f40a7a..ffa96a1 100644
--- a/DM_Weight/ViewModels/CheckStockWindowViewModel.cs
+++ b/DM_Weight/ViewModels/CheckStockWindowViewModel.cs
@@ -108,21 +108,21 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand((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().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().Publish(alertMsg);
+ // return;
+ // }
- }
+ //}
this.DrawerNo = Convert.ToInt32(DrawerNo);
RequestData();
}, (DrawerNo) => Status == 0
diff --git a/DM_Weight/ViewModels/DestoryEmptyDialogViewModel.cs b/DM_Weight/ViewModels/DestoryEmptyDialogViewModel.cs
index 2270c4d..db82345 100644
--- a/DM_Weight/ViewModels/DestoryEmptyDialogViewModel.cs
+++ b/DM_Weight/ViewModels/DestoryEmptyDialogViewModel.cs
@@ -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().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().Publish(alertMsg);
+ // return;
+ // }
- }
+ //}
Status = 1;
//_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
diff --git a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs
index 6243341..446854c 100644
--- a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs
+++ b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs
@@ -24,7 +24,80 @@ namespace DM_Weight.ViewModels
private readonly ILog logger = LogManager.GetLogger(typeof(DrawerAddDrugWindowViewModel));
private List _drawerNoList = new List();
-
+ #region 抽屉权限
+ ///
+ /// 1号抽屉
+ ///
+ private bool _Drawer1 = false;
+ public bool Drawer1
+ {
+ get { return _Drawer1; }
+ set { SetProperty(ref _Drawer1, value); }
+ }
+ ///
+ /// 2号抽屉
+ ///
+ private bool _Drawer2 = false;
+ public bool Drawer2
+ {
+ get { return _Drawer2; }
+ set { SetProperty(ref _Drawer2, value); }
+ }
+ ///
+ /// 3号抽屉
+ ///
+ private bool _Drawer3 = false;
+ public bool Drawer3
+ {
+ get { return _Drawer3; }
+ set { SetProperty(ref _Drawer3, value); }
+ }
+ ///
+ /// 4号抽屉
+ ///
+ private bool _Drawer4 = false;
+ public bool Drawer4
+ {
+ get { return _Drawer4; }
+ set { SetProperty(ref _Drawer4, value); }
+ }
+ ///
+ /// 5号抽屉
+ ///
+ private bool _Drawer5 = false;
+ public bool Drawer5
+ {
+ get { return _Drawer5; }
+ set { SetProperty(ref _Drawer5, value); }
+ }
+ ///
+ /// 6号抽屉
+ ///
+ private bool _Drawer6 = false;
+ public bool Drawer6
+ {
+ get { return _Drawer6; }
+ set { SetProperty(ref _Drawer6, value); }
+ }
+ ///
+ /// 7号抽屉
+ ///
+ private bool _Drawer7 = false;
+ public bool Drawer7
+ {
+ get { return _Drawer7; }
+ set { SetProperty(ref _Drawer7, value); }
+ }
+ ///
+ /// 8号抽屉
+ ///
+ private bool _Drawer8 = false;
+ public bool Drawer8
+ {
+ get { return _Drawer8; }
+ set { SetProperty(ref _Drawer8, value); }
+ }
+ #endregion
private List? _channelStocks;
public List? 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().Publish(alertMsg);
- return;
- }
-
- }
Status = 1;
try
@@ -468,9 +526,51 @@ namespace DM_Weight.ViewModels
_eventAggregator.GetEvent().Subscribe(DoMyPrismEvent);
FindDrawerCount();
RequestData();
+ GetDrawer();
}
+ ///
+ /// 查询当前用户对应角色的抽屉权限
+ ///
+ 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)
{
diff --git a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
index cfe8b66..f416bcf 100644
--- a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
+++ b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
@@ -27,7 +27,80 @@ namespace DM_Weight.ViewModels
public class DrawerTakeDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
{
private readonly ILog logger = LogManager.GetLogger(typeof(DrawerTakeDrugWindowViewModel));
-
+ #region 抽屉权限
+ ///
+ /// 1号抽屉
+ ///
+ private bool _Drawer1 = false;
+ public bool Drawer1
+ {
+ get { return _Drawer1; }
+ set { SetProperty(ref _Drawer1, value); }
+ }
+ ///
+ /// 2号抽屉
+ ///
+ private bool _Drawer2 = false;
+ public bool Drawer2
+ {
+ get { return _Drawer2; }
+ set { SetProperty(ref _Drawer2, value); }
+ }
+ ///
+ /// 3号抽屉
+ ///
+ private bool _Drawer3 = false;
+ public bool Drawer3
+ {
+ get { return _Drawer3; }
+ set { SetProperty(ref _Drawer3, value); }
+ }
+ ///
+ /// 4号抽屉
+ ///
+ private bool _Drawer4 = false;
+ public bool Drawer4
+ {
+ get { return _Drawer4; }
+ set { SetProperty(ref _Drawer4, value); }
+ }
+ ///
+ /// 5号抽屉
+ ///
+ private bool _Drawer5 = false;
+ public bool Drawer5
+ {
+ get { return _Drawer5; }
+ set { SetProperty(ref _Drawer5, value); }
+ }
+ ///
+ /// 6号抽屉
+ ///
+ private bool _Drawer6 = false;
+ public bool Drawer6
+ {
+ get { return _Drawer6; }
+ set { SetProperty(ref _Drawer6, value); }
+ }
+ ///
+ /// 7号抽屉
+ ///
+ private bool _Drawer7 = false;
+ public bool Drawer7
+ {
+ get { return _Drawer7; }
+ set { SetProperty(ref _Drawer7, value); }
+ }
+ ///
+ /// 8号抽屉
+ ///
+ private bool _Drawer8 = false;
+ public bool Drawer8
+ {
+ get { return _Drawer8; }
+ set { SetProperty(ref _Drawer8, value); }
+ }
+ #endregion
private List _channelStocks = new List();
public List 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().Publish(alertMsg);
- return;
- }
-
- }
Status = 1;
//_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
@@ -468,8 +526,52 @@ namespace DM_Weight.ViewModels
_eventAggregator.GetEvent().Subscribe(DoMyPrismEvent);
FindDrawerCount();
RequestData();
+ GetDrawer();
}
+ ///
+ /// 查询当前用户对应角色的抽屉权限
+ ///
+ 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)
diff --git a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs
index 6a43716..f9e97f0 100644
--- a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs
+++ b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs
@@ -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().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().Publish(alertMsg);
+ // return;
+ // }
- }
+ //}
enumerator.MoveNext();
Status = 1;
OpenOneByOne();
diff --git a/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs b/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs
index 4cc90ad..8215614 100644
--- a/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs
@@ -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().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().Publish(alertMsg);
+ // return;
+ // }
- }
+ //}
enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
enumerator = enumerable.GetEnumerator();
enumerator.MoveNext();
diff --git a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs
index 97420d5..64873d8 100644
--- a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs
+++ b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs
@@ -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().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().Publish(alertMsg);
+ // return;
+ // }
- }
+ //}
enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
enumerator = enumerable.GetEnumerator();
enumerator.MoveNext();
diff --git a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
index 17e51c0..0d1be98 100644
--- a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
@@ -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().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().Publish(alertMsg);
+ // return;
+ // }
- }
+ //}
enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
enumerator = enumerable.GetEnumerator();
diff --git a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs
index 62dce20..51ca16e 100644
--- a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs
+++ b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs
@@ -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().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().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().Publish(alertMsg);
+ return;
}
+
if (ChannelStock != null)
{
Status = 1;
diff --git a/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs b/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs
index 6ef6eea..6c0f70d 100644
--- a/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs
+++ b/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs
@@ -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().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().Publish(alertMsg);
+ // return;
+ // }
- }
+ //}
if (ChannelStock != null)
{
if (Status == 0)
diff --git a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs
index f2fd8d2..9aa6fb5 100644
--- a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs
+++ b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs
@@ -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 抽屉权限
+ ///
+ /// 1号抽屉
+ ///
+ private bool _Drawer1=false;
+ public bool Drawer1
+ {
+ get { return _Drawer1; }
+ set { SetProperty(ref _Drawer1, value); }
+ }
+ ///
+ /// 2号抽屉
+ ///
+ private bool _Drawer2 = false;
+ public bool Drawer2
+ {
+ get { return _Drawer2; }
+ set { SetProperty(ref _Drawer2, value); }
+ }
+ ///
+ /// 3号抽屉
+ ///
+ private bool _Drawer3= false;
+ public bool Drawer3
+ {
+ get { return _Drawer3; }
+ set { SetProperty(ref _Drawer3, value); }
+ }
+ ///
+ /// 4号抽屉
+ ///
+ private bool _Drawer4 = false;
+ public bool Drawer4
+ {
+ get { return _Drawer4; }
+ set { SetProperty(ref _Drawer4, value); }
+ }
+ ///
+ /// 5号抽屉
+ ///
+ private bool _Drawer5= false;
+ public bool Drawer5
+ {
+ get { return _Drawer5; }
+ set { SetProperty(ref _Drawer5, value); }
+ }
+ ///
+ /// 6号抽屉
+ ///
+ private bool _Drawer6 = false;
+ public bool Drawer6
+ {
+ get { return _Drawer6; }
+ set { SetProperty(ref _Drawer6, value); }
+ }
+ ///
+ /// 7号抽屉
+ ///
+ private bool _Drawer7= false;
+ public bool Drawer7
+ {
+ get { return _Drawer7; }
+ set { SetProperty(ref _Drawer7, value); }
+ }
+ ///
+ /// 8号抽屉
+ ///
+ 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(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 roleList = SqlSugarHelper.Db.Queryable().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(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 continuationCallback)
{
diff --git a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs
index 8fcc929..69038ab 100644
--- a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs
+++ b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs
@@ -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().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().Publish(alertMsg);
+ // return;
+ // }
- }
+ //}
enumerator.MoveNext();
Status = 1;
OpenOneByOne();
diff --git a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
index e3ff86e..261c4c7 100644
--- a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
@@ -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().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().Publish(alertMsg);
+ // return;
+ // }
- }
+ //}
enumerator.MoveNext();
Status = 1;
OpenOneByOne();
diff --git a/DM_Weight/Views/DrawerAddDrugWindow.xaml b/DM_Weight/Views/DrawerAddDrugWindow.xaml
index e9dc3aa..c40faf0 100644
--- a/DM_Weight/Views/DrawerAddDrugWindow.xaml
+++ b/DM_Weight/Views/DrawerAddDrugWindow.xaml
@@ -63,14 +63,14 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/DM_Weight/Views/DrawerTakeDrugWindow.xaml b/DM_Weight/Views/DrawerTakeDrugWindow.xaml
index a38edff..a1343af 100644
--- a/DM_Weight/Views/DrawerTakeDrugWindow.xaml
+++ b/DM_Weight/Views/DrawerTakeDrugWindow.xaml
@@ -61,14 +61,14 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/DM_Weight/Views/RoleManagerWindow.xaml b/DM_Weight/Views/RoleManagerWindow.xaml
index aaf0010..9a7ec66 100644
--- a/DM_Weight/Views/RoleManagerWindow.xaml
+++ b/DM_Weight/Views/RoleManagerWindow.xaml
@@ -101,12 +101,40 @@
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+