using Yw;
|
using Yw.WinFrmUI;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class RoleProjectMenuPage : DocumentPage
|
{
|
public RoleProjectMenuPage()
|
{
|
InitializeComponent();
|
this.treeList1.InitialMultiColSettings();
|
this.PageTitle.Caption = "角色菜单管理";
|
this.PageTitle.SvgImageSize = new Size(24, 24);
|
this.roleTreeListCtrl1.FocusedChangedEvent += RoleTreeListCtrl1_FocusedChangedEvent;
|
}
|
|
public override void InitialDataSource()
|
{
|
this.roleTreeListCtrl1.InitialData();
|
}
|
|
private List<RoleProjcetMenuViewModel> _allBindingList;
|
|
private Yw.Vmo.RoleVmo _lastRole;
|
|
/// <summary>
|
/// 聚焦改变事件
|
/// </summary>
|
private async void RoleTreeListCtrl1_FocusedChangedEvent(Yw.Vmo.RoleVmo obj)
|
{
|
_lastRole = obj;
|
_allBindingList = new List<RoleProjcetMenuViewModel>();
|
var allList = await BLLFactory<Yw.BLL.RoleProjectMenuMapping>.Instance.GetAuthorizeMenuList(LoginUserInfo.ProjectID, obj.ID);
|
foreach (var item in allList)
|
{
|
_allBindingList.Add(new RoleProjcetMenuViewModel(item));
|
}
|
this.roleProjcetMenuViewModelBindingSource.DataSource = _allBindingList;
|
this.roleProjcetMenuViewModelBindingSource.ResetBindings(false);
|
}
|
|
//保存
|
private async void BtnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var menuList = new List<long>();
|
foreach (var item in _allBindingList)
|
{
|
if (item.Have)
|
{
|
menuList.Add(item.ID);
|
}
|
}
|
var vmo = new Yw.Vmo.SetRoleProjectMenuVmo();
|
vmo.ProjectID = LoginUserInfo.ProjectID;
|
vmo.RoleID = _lastRole.ID;
|
vmo.MenuIds = menuList;
|
var bol = await BLLFactory<Yw.BLL.RoleProjectMenuMapping>.Instance.Set(vmo);
|
if (bol)
|
{
|
TipFormHelper.ShowSucceed("保存成功!");
|
}
|
else
|
{
|
TipFormHelper.ShowError("保存失败!");
|
}
|
}
|
|
private void barBtnSearch_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
this.treeList1.OptionsFind.AlwaysVisible = !this.treeList1.OptionsFind.AlwaysVisible;
|
}
|
|
private void treeList1_AfterCheckNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e)
|
{
|
// 获取父节点
|
var parentNode = e.Node.ParentNode;
|
if (parentNode != null)
|
{
|
parentNode.Checked = _isCheck;
|
}
|
}
|
|
private bool _isCheck = false;
|
|
private void treeList1_BeforeCheckNode(object sender, DevExpress.XtraTreeList.CheckNodeEventArgs e)
|
{
|
var parentNode = e.Node.ParentNode;
|
if (parentNode != null)
|
{
|
_isCheck = parentNode.Checked;
|
}
|
}
|
|
private void barBtnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
RoleTreeListCtrl1_FocusedChangedEvent(_lastRole);
|
}
|
}
|
}
|