<button class="btn btn-primary" id="btnSave">保存</button>
<button class="btn btn-cancel" id="btnCancle">取消</button>
$("#btnCancle").click(function () {
window.location.href = '/Sys/ReloList.aspx';
});
var md = sRequire('modal');
$("#btnSave").click(function () {
var $this = $(this);
var ckv = [];
var ckedv = [];
$('input[name="like"]:checked').each(function () {
ckv.push(this.value);
});
$('input[name="menuChild"]:checked').each(function () {
ckedv.push(this.value);
});
$.post('/sys/RoleFunction.aspx?action=assign', { roleId: '<%=roleId %>', ck: ckv.join(","), cked: ckedv.join(",") }, function (data) {
if (data.reCode > 0) {
window.location.href = '/Sys/ReloList.aspx';
}
else {
$error.html(data.msg);
md.bind({
target: '#md2'
});
}
}, 'json');
});
else if ("assign" == action)
{
//保存此角色的功能权限信息
/*
* 1. 获取数据
* 2. 保存数据
*/
// 获取数据,角色id合法性校验
var ck = InputHelper.GetInputString( Request[ "ck" ] );
var cked = InputHelper.GetInputString( Request[ "cked" ] );
if ( roleId <= 0 ) {
Response.Write( "{\"reCode\":0,\"msg\":\"角色id不合法\"}" );
Response.End();
return;
}
// 删除以前的角色菜单信息
sys_roleFuncBll.Delete(string.Format("RoleID = {0}", roleId));
// 批量给一级主功能权限信息
// (此处主要用在下次修改改角色功能权限时,方便进行选中赋值使用)
if ( !string.IsNullOrWhiteSpace( ck ) ) {
// 循环给该角色添加功能权限信息
foreach ( var id in ck.Split( ',' ) ) {
// 功能id合法性校验
int funcId = InputHelper.GetInputInt( id );
if (funcId > 0)
{
//新增菜单给此角色
Sys_RoleFunctionInfo addInfo = new Sys_RoleFunctionInfo
{
RoleID = roleId,
FunctionID = funcId
};
sys_roleFuncBll.Insert(addInfo);
}
}
}
// 循环添加功能权限
foreach ( var id in cked.Split( ',' ) ) {
int funcId = InputHelper.GetInputInt(id);
if (funcId > 0)
{
Sys_RoleFunctionInfo addInfo = new Sys_RoleFunctionInfo
{
RoleID = roleId,
FunctionID = funcId
};
sys_roleFuncBll.Insert(addInfo);
}
}
Response.Write( "{\"reCode\":1,\"msg\":\"ok\"}" );
Response.End();
}
// 删除以前的角色菜单信息
sys_roleFuncBll.Delete(string.Format("RoleID = {0}", roleId));
// 批量给一级主功能权限信息
// (此处主要用在下次修改改角色功能权限时,方便进行选中赋值使用)
if ( !string.IsNullOrWhiteSpace( ck ) ) {
// 循环给该角色添加功能权限信息
foreach ( var id in ck.Split( ',' ) ) {
// 功能id合法性校验
int funcId = InputHelper.GetInputInt( id );
if (funcId > 0)
{
//新增菜单给此角色
Sys_RoleFunctionInfo addInfo = new Sys_RoleFunctionInfo
{
RoleID = roleId,
FunctionID = funcId
};
sys_roleFuncBll.Insert(addInfo);
}
}
}
// 循环添加功能权限
欢迎光临 苏飞论坛 (http://www.sufeinet.com/) | Powered by Discuz! X3.4 |