@using DTO;
|
@{
|
ViewBag.Title = "Search";
|
Layout = "~/Views/Shared/_Layout_Content.cshtml";
|
var listRole = ViewBag.listRole == null ? new List<PltRoleDTO>() : (List<PltRoleDTO>)ViewBag.listRole;//获取所有角色
|
}
|
<link href="~/css/font-awesome.min.css" rel="stylesheet">
|
<link href="~/css/plugins/iCheck/custom.css" rel="stylesheet">
|
<link href="~/css/animate.min.css" rel="stylesheet">
|
<link href="~/css/style.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="~/css/ztree/demo.css" type="text/css">
|
<link rel="stylesheet" href="~/css/ztree/zTreeStyle/zTreeStyle.css" type="text/css">
|
<script type="text/javascript" src="~/js/ztree/jquery-1.4.4.min.js"></script>
|
<script type="text/javascript" src="~/js/ztree/jquery.ztree.core-3.4.js"></script>
|
<script type="text/javascript" src="~/js/ztree/jquery.ztree.excheck-3.4.js"></script>
|
|
<style>
|
#add {
|
margin-left: 30%;
|
}
|
|
.ibox-title {
|
margin-top: 0;
|
}
|
|
span.icon {
|
margin-right: 5px;
|
}
|
|
.list-group-item {
|
padding: 7px 15px;
|
}
|
</style>
|
<div style="width:20%;height:100%;float:left;">
|
<div id="tree">
|
<ul class="list-group rolesearch" style="margin-bottom:0px;">
|
<li class="list-group-item" style="font-weight: bold;text-align: center;">角色列表</li>
|
<li class="list-group-item">
|
<div class="row">
|
<div class="col-lg-12">
|
<div class="input-group" style="width:100%">
|
<input type="text" class="form-control" placeholder="检索角色名称" id="rolesearch">
|
<!-- /btn-group -->
|
</div>
|
</div>
|
</div>
|
</li>
|
</ul>
|
<ul class="list-group" id="listrole" style="overflow-y:scroll;">
|
@foreach (var item in listRole)
|
{
|
<li class="list-group-item node-tree" data-roleid="@item.Id" data-name="@item.RoleName" style="cursor:pointer;" data-nodeid="0">
|
<span class="icon"><i class="glyphicon glyphicon-globe"></i></span>@item.RoleName
|
</li>
|
}
|
|
</ul>
|
</div>
|
</div>
|
<div style="width:80%;height:100%;float:right;background-color:black;">
|
<div class="ibox-title">
|
<div class="row">
|
<div class="col-sm-12 col-md-12" style="text-align:center;">
|
<h3>权限列表</h3>
|
</div>
|
</div>
|
</div>
|
<div id="authlist" class="ibox-content" style="overflow-y:scroll;">
|
<div class="row">
|
<div class="col-sm-12 col-md-12">
|
<div class="left">
|
<ul id="treeDemo" class="ztree" style="width:100%; margin-top:0px; background:#fff; border:#ddd solid 1px; padding-left:30px;"></ul>
|
</div>
|
|
</div>
|
|
</div>
|
</div>
|
</div>
|
<div class="ibox-content" id="top" style="z-index:100; position:fixed;height:50px; width:100%;bottom:0; text-align:right; padding-top:8px ">
|
<div class="" style="float:right;" data-bootstro-width="500px" data-bootstro-content="功能按钮:“停用”,“保存”,“新增”等操作">
|
|
<a style="text-decoration:none;" class="btn btn-success " onclick="SaveAuth()">
|
<i class="glyphicon glyphicon-ok"></i> <span class="bold">保存设置</span>
|
</a>
|
</div>
|
</div>
|
<script>
|
$(function () {
|
$('#authlist').css('height', document.body.clientHeight - 85);
|
$('#treeDemo').css('height', document.body.clientHeight - 135);
|
$('#listrole').css('height', document.body.clientHeight - $('.rolesearch').height() - 50);
|
$('.node-tree').bind('click', function () {
|
var nRoleID = $(this).attr('data-roleid');
|
$('.node-tree').removeClass('text-navy');
|
$(this).addClass('text-navy');
|
GetTree(nRoleID);
|
});
|
|
$('#rolesearch').bind('keyup',function () {
|
var sRoleName = $.trim($(this).val());
|
if (sRoleName == '')
|
{
|
$('.node-tree').show();
|
}
|
else
|
{
|
$('.node-tree').each(function () {
|
var sName = $(this).attr('data-name');
|
if (sName.indexOf(sRoleName) != -1) {
|
$(this).show();
|
}
|
else {
|
$(this).hide();
|
}
|
});
|
}
|
});
|
});
|
|
var SaveAuth = function () {
|
var nRoleID = $('#tree .text-navy').attr('data-roleid');
|
var aryPageId = [];
|
var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
|
$.each(treeObj.getCheckedNodes(true), function (i, r) {
|
aryPageId.push(r.id);
|
});
|
var error = "";
|
if (aryPageId.length == 0) {
|
toastr.warning("请选择权限");
|
return;
|
}
|
if (nRoleID == undefined || parseInt(nRoleID) == 0) {
|
toastr.warning("请选择权限角色");
|
return;
|
}
|
|
var mAuth = {
|
roleid: nRoleID,
|
pageid: aryPageId.join(',')
|
};
|
$.ajax({
|
url: "/PltAuth/Save",
|
data: mAuth,
|
type: 'Post',
|
dataType:'json',
|
success: function (data) {
|
if (data.Result) {
|
toastr.success("保存成功");
|
parent.layer.closeAll('loading');
|
}
|
else {
|
toastr.warning(data.Message);
|
}
|
},
|
error: function () {
|
|
},
|
complete: function () {
|
|
}
|
});
|
|
}
|
</script>
|
<SCRIPT type="text/javascript">
|
|
var setting = {
|
check: {
|
enable: true
|
},
|
data: {
|
simpleData: {
|
enable: true
|
}
|
}
|
};
|
var GetTree = function (nroleid) {
|
$.ajax({
|
url: "/PltAuth/GetPageByRole",
|
data: { roleid: nroleid },
|
type: 'Post',
|
dataType: 'json',
|
success: function (data) {
|
|
var sJson = data.sJson.replace(/True/g, true);
|
sJson = sJson.replace(/False/g, false);
|
var Json = eval("(" + sJson + ")");
|
$.fn.zTree.init($("#treeDemo"), setting, Json);
|
parent.layer.closeAll('loading');
|
},
|
error: function () {
|
|
},
|
complete: function () {
|
|
}
|
});
|
}
|
</SCRIPT>
|