187 lines
6.7 KiB
Plaintext
187 lines
6.7 KiB
Plaintext
@using WX.CRM.WebHelper
|
|
@{
|
|
ViewBag.Title = "角色权限管理";
|
|
Layout = "~/Views/Shared/_EasyUI_Layout.cshtml";
|
|
}
|
|
<style>
|
|
.panel-body {
|
|
border: none;
|
|
}
|
|
</style>
|
|
|
|
<div data-options="region:'north',border:false" style="height:55px;">
|
|
<div class="mvctool">
|
|
@*@Html.ToolButton("btnQuery", "icon-search", "查询", true)*@
|
|
@Html.Action("ToolBar", "Control", ViewBag.ToolBar as ToolBar)
|
|
</div>
|
|
</div>
|
|
<div data-options="region:'west',split:true" style="width:200px;border-left:none;border-bottom:none;padding:5px;">
|
|
<ul id="ulRole"></ul>
|
|
</div>
|
|
<div data-options="region:'center'" style="border-right: none; border-bottom: none; padding: 10px; ">
|
|
<ul id="ulRight"></ul>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
$('#ulRight').tree({
|
|
checkbox: true,
|
|
url: "/Base/RightGroup/GetRightTreeList?isSelect=true",
|
|
onLoadSuccess: function () {
|
|
$('.tree-checkbox').attr("onclick", "javascript:selectBttn(this);");
|
|
}
|
|
});
|
|
$('#ulRole').tree({
|
|
dnd: true,
|
|
url: "/Base/Role/GetRoleTree",
|
|
onSelect: function (node) {
|
|
|
|
Clear_RoleRight();
|
|
Load_RoleRight(node);
|
|
}
|
|
});
|
|
|
|
});
|
|
function selectBttn(right) {
|
|
if ($(right).hasClass("tree-checkbox1")) {
|
|
var $top_select = $(right).parent('div').next('ul');
|
|
var $cur_select = $(right).next('span').children('input');
|
|
|
|
if ($cur_select.length) {
|
|
$cur_select.each(function () {
|
|
$(this).removeAttr("checked");
|
|
})
|
|
}
|
|
else if ($top_select.length) {
|
|
$top_select.find('.tool_button').each(function () {
|
|
$(this).removeAttr("checked");
|
|
})
|
|
}
|
|
//$(right).next('span').children('input').each(function () {
|
|
// $(this).removeProp("checked");
|
|
//})
|
|
}
|
|
else {
|
|
var $top_select = $(right).parent('div').next('ul');
|
|
var $cur_select = $(right).next('span').children('input');
|
|
if ($cur_select.length) {
|
|
$cur_select.each(function () {
|
|
$(this).attr("checked", 'true');
|
|
});
|
|
}
|
|
else if ($top_select.length) {
|
|
$top_select.find('.tool_button').each(function () {
|
|
$(this).attr("checked", 'true');
|
|
})
|
|
}
|
|
//$(right).next('span').children('input').each(function () {
|
|
// $(this).prop("checked", 'true');
|
|
//})
|
|
}
|
|
}
|
|
function Clear_RoleRight() { //清除之前的角色权限
|
|
var checked = $("#ulRight").tree("getChecked");
|
|
$(checked).each(function (i, n) {
|
|
$("#ulRight").tree("uncheck", n.target);
|
|
});
|
|
}
|
|
function Load_RoleRight(node) { //加载角色对应的权限
|
|
$.r_post("/Base/RoleRightResource/GetBas_RoleRight?id=" + node.id, function (data) {
|
|
if (data) {
|
|
$(".tool_button").each(function () {
|
|
$(this).removeAttr("checked");
|
|
});
|
|
}
|
|
$(data).each(function (i, n) {
|
|
$("#ulRight").tree("check", $("#ulRight").tree("find", n.id).target);
|
|
$("input[name='" + n.id + "']").each(function () {
|
|
if (Number(n.toolValue) && ((Number(n.toolValue) & Number($(this).val())) > 0)) {
|
|
$(this).attr("checked", 'true');
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
}, "json");
|
|
|
|
|
|
}
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
|
|
function ExpandAll_Click() {
|
|
$("#ulRight").tree("expandAll");
|
|
}
|
|
function CollapseAll_Click() {
|
|
$("#ulRight").tree("collapseAll");
|
|
}
|
|
function Reload_Click() {
|
|
|
|
var node = $("#ulRole").tree("getSelected");
|
|
if (node) {
|
|
Clear_RoleRight();
|
|
Load_RoleRight(node);
|
|
}
|
|
else {
|
|
//console
|
|
$('#ulRight').tree({
|
|
checkbox: true,
|
|
url: "/Base/RightGroup/GetRightTreeList?isSelect=true"
|
|
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
function Save_Click() {
|
|
var row = $('#ulRole').tree('getSelected');
|
|
if (row != null) {
|
|
$.messager.confirm('提示', '您确定要保存此角色的权限修改吗?', function (r) {
|
|
if (r) {
|
|
var checked = $("#ulRight").tree("getChecked");
|
|
var rightIds = [];
|
|
var hasbuttons;
|
|
$(checked).each(function (i, n) {
|
|
if (typeof n.id == "string") {
|
|
var buttons = 0;
|
|
$("input[name='" + n.id + "']:checked").each(function () {
|
|
buttons += Number($(this).val()) || 0;
|
|
hasbuttons = true;
|
|
});
|
|
rightIds.push({ rightId: n.id, buttons: buttons });
|
|
//rightIds += n.id + ",";
|
|
}
|
|
//rightIds += "" + (-parseInt(n.id.toString().replace("r_", ""))) + ",";
|
|
});
|
|
if (!hasbuttons) {
|
|
$.messager.confirm('提示', '按钮权限为空,是否要保存?', function (r) {
|
|
if (r) {
|
|
$.r_post("/Base/RoleRightResource/Save", { roleId: row.id, rightIds: JSON.stringify(rightIds) }, function (data) {
|
|
$.messageBox5s('提示', data.message);
|
|
}, "json");
|
|
}
|
|
})
|
|
}
|
|
else {
|
|
$.r_post("/Base/RoleRightResource/Save", { roleId: row.id, rightIds: JSON.stringify(rightIds) }, function (data) {
|
|
$.messageBox5s('提示', data.message);
|
|
}, "json");
|
|
}
|
|
|
|
//if (rightIds.length > 0)
|
|
// rightIds = rightIds.substr(0, rightIds.length - 1);
|
|
|
|
}
|
|
});
|
|
} else { $.messageBox5s('提示', '请您选中左边的角色!'); }
|
|
}
|
|
|
|
function AddRole_Click() {
|
|
$("#modalwindow").html(GetIframeHtml("/Base/Role/Edit"));
|
|
$("#modalwindow").window({ title: '新增角色', width: 700, height: 400, iconCls: 'icon-add' }).window('open');
|
|
}
|
|
function GetIframeHtml(src) {
|
|
return "<iframe width='100%' height='98%' scrolling='no' frameborder='0'' src='" + src + "'></iframe>";
|
|
}
|
|
</script>
|