Commit 5985a3af authored by 刘丹's avatar 刘丹

权限分配

parent 2b59d83d
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<div class="pull-right"> <div class="pull-right">
<ul class="bread_btn"> <ul class="bread_btn">
<li> <li>
<a href="/index/roleedit" data-toggle="modal" class="btn btn-default"><i class="icon-plus"></i> <a href="#modal-edit" data-toggle="modal" class="btn btn-default"><i class="icon-plus"></i>
添加角色</a> 添加角色</a>
</li> </li>
</ul> </ul>
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭 <button type="button" class="btn btn-default" data-dismiss="modal">关闭
</button> </button>
<button type="button" class="btn btn-primary submit_follow2" data-dismiss="modal"> <button type="button" class="btn btn-primary submit_edit" data-dismiss="modal">
提交 提交
</button> </button>
</div> </div>
...@@ -93,12 +93,15 @@ ...@@ -93,12 +93,15 @@
</h4> </h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="auth" id="access_box">
</div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭 <button type="button" class="btn btn-default" data-dismiss="modal">关闭
</button> </button>
<button type="button" class="btn btn-primary submit_follow2" data-dismiss="modal"> <button type="button" class="btn btn-primary submit_power" data-dismiss="modal">
提交 提交
</button> </button>
</div> </div>
......
...@@ -85,7 +85,7 @@ Route::group('index', [ ...@@ -85,7 +85,7 @@ Route::group('index', [
'access' => ['index/auth/access', ['method' => 'get']], //--权限分配角色页面 'access' => ['index/auth/access', ['method' => 'get']], //--权限分配角色页面
'updateAccess' => ['index/auth/updateAccess', ['method' => 'post']], //--编辑角色权限【接口】 'updateAccess' => ['index/auth/updateAccess', ['method' => 'post']], //--编辑角色权限【接口】
'addAuth' => ['index/auth/addAuth', ['method' => 'get|post']], //--添加角色【接口】 'addAuth' => ['index/auth/addAuth', ['method' => 'get|post']], //--添加角色【接口】
'accessLook'=>['index/auth/accessLook', ['method' => 'post']], //--查看编辑角色权限【接口】 'accessLook'=>['index/auth/accessLook', ['method' => 'get|post']], //--查看编辑角色权限【接口】
'setStatus'=>['index/auth/setStatus', ['method' => 'post']], //--设置角色的状态【接口】 'setStatus'=>['index/auth/setStatus', ['method' => 'post']], //--设置角色的状态【接口】
'accessUser' => ['index/auth/accessUser', ['method' => 'get']], //成员授权 'accessUser' => ['index/auth/accessUser', ['method' => 'get']], //成员授权
......
...@@ -9,31 +9,93 @@ define (['doT', 'text!temp/auth_template_tpl.html', 'css!style/home.css','pagina ...@@ -9,31 +9,93 @@ define (['doT', 'text!temp/auth_template_tpl.html', 'css!style/home.css','pagina
auth.event (); auth.event ();
}, },
event: function () { event: function () {
$ (document).delegate (".anch", "click", function () {//点击编辑 $ (document).delegate (".edit", "click", function () {//点击编辑
auth.house_id = $ (this).attr ("data-id"); auth.house_id = $ (this).attr ("data-id");
auth.Edit(); auth.Edit();
}); });
$ (document).delegate (".submit_edit", "click", function () {//提交编辑
auth.Submit_edit();
auth.getList();
});
$ (document).delegate (".power", "click", function () {//点击权限分配
auth.id = $ (this).attr ("data-id");
auth.Power();
});
$ (document).delegate (".submit_power", "click", function () {//点击提交权限
auth.Submit_power();
});
}, },
Edit:function(){ Edit:function(){//获取
var caozuo_table="";
$.ajax({ $.ajax({
'type': 'GET', 'type': 'GET',
'url' : '/index/addAuth/group_id/',//获取编辑数据 'url' : '/index/addAuth/group_id/',//获取编辑数据
data: {"id":auth.house_id}, data: {"id":auth.house_id},
dataType: "json", dataType: "json",
success: function(data){ success: function(data){
if(data.code == 200){
if (data.data) { if (data.data) {
$("input[name = id]").val(data.data.id); $("input[name = id]").val(data.data.id);
$("input[name = title]").val(data.data.title); $("input[name = title]").val(data.data.title);
$("#description").val(data.data.description); $("#description").val(data.data.description);
} }
} else { else {
alert('获取失败!'); alert('获取失败!');
} }
} }
}); });
}, },
Submit_edit:function(){//提交编辑的信息
var par={};
par.id= auth.house_id;
par.title=$("input[name =title]").val();
par.description=$("textarea[name =description]").val();
$.ajax({
'type': 'POST',
'url' : '/index/addAuth',
data:par,
dataType: "json",
success: function(data){
if(data.code==200){
}else{
alert(data.msg);
}
}
});
},
Power:function(){//获取的信息
$.ajax({
'type': 'GET',
'url' : '/index/accessLook',
data:{
id:auth.id
},
dataType: "json",
success: function(data){
var temp=document.getElementById('access_tpl').innerHTML;
var doTempl=doT.template(temp);
$("#access_box").html(doTempl(data.data.class));
}
});
},
Submit_power:function(){//提交权限的信息
var v='';
$("input[name=rules]:checked").each(function (i) {
v+= $(this).val()+',';
})
$.ajax({
'type': 'POST',
'url' : '/index/updateAccess',
data:{'rules':v,'id':auth.id},
dataType: "json",
success: function(data){
if(data.code==200){
}else{
alert(data.msg);
}
}
});
},
getList: function (pageNo) { getList: function (pageNo) {
auth.pageNo = pageNo; auth.pageNo = pageNo;
var params = {}; var params = {};
...@@ -41,7 +103,7 @@ define (['doT', 'text!temp/auth_template_tpl.html', 'css!style/home.css','pagina ...@@ -41,7 +103,7 @@ define (['doT', 'text!temp/auth_template_tpl.html', 'css!style/home.css','pagina
params.pageSize = auth.pageSize; params.pageSize = auth.pageSize;
$.ajax ({ $.ajax ({
url: '/index/getAuth.html', url: '/index/getAuth.html',//列表数据
type: 'GET', type: 'GET',
async: true, async: true,
data: params, data: params,
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
</td> </td>
<td>[%= it[item]["status"] %]</td> <td>[%= it[item]["status"] %]</td>
<td> <td>
<a class="btn1 btn-success " href="#modal-edit" data-toggle="modal" data-id='[%= it[item]["id"] %]'>编辑</a> <a class="btn1 btn-success edit" href="#modal-edit" data-toggle="modal" data-id='[%= it[item]["id"] %]'>编辑</a>
<a class="btn btn-info btn-xs power" href="#modal-power" data-toggle="modal" data-id='[%= it[item]["id"] %]'>权限分配</a>
<a class="btn btn-info btn-xs" href="/admin.php/index/access?id=[%= it[item]['id']%]" data-toggle="modal" data-id='[%= it[item]["id"] %]'>权限分配</a> <a class="btn btn-info btn-xs" href="/admin.php/index/access?id=[%= it[item]['id']%]" data-toggle="modal" data-id='[%= it[item]["id"] %]'>权限分配</a>
</td> </td>
</tr> </tr>
...@@ -22,3 +23,24 @@ ...@@ -22,3 +23,24 @@
</tr> </tr>
[% } %] [% } %]
</script> </script>
<script id="access_tpl" type="text/template">
[% if(it) { %]
[% for(var item in it){ %]
[% if(it[item]['pid']!=0){ %]
[% } %]
[% if(it[item]['is']!=0){ %]
<label class="checkbox-inline">
<input type="checkbox" value="[%= it[item]['id'] %]" name="rules" checked="checked"> [%= it[item]["title"] %]
</label>
[% }else{ %]
<label class="checkbox-inline">
<input type="checkbox" value="[%= it[item]['id'] %]" name="rules" > [%= it[item]["title"] %]
</label>
[% } %]
[% } %]
[% } %]
</script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment