(function(){ X.pageLogic['projectadmin'] = { init : function(parms){ var role_id,datalist; var system; updataroles(); function updataroles(roleid){ X.api("authz/roles","get",{},function(d){ // var roleid = roleid ? roleid : 0; datalist = d; if(roleid){ for(let i in d){ if(d[i]['auth_id'] == roleid){ updataapiinfo(d[i]); } } }else { if(d[0]){ role_id = d[0]['auth_id']; system = d[0]['system']; $(".projectadmin-list-name").html(d[0]["name"]); X.laytpldata("#projectadmin-con-hz-left-list-tit-xiangmu-dot",d,".projectadmin-con-hz-left-list-box"); updataapiinfo(d[0]); }else { layer.msg('查无数据'); } } }); } $(document).off('click',".menu_dapax .item_kuvn").on('click',".menu_dapax .item_kuvn",function(){ $(".menu_dapax .item_kuvn").removeClass("selected___3ctlt"); $(this).addClass("selected___3ctlt"); var url = $(this).attr("data-url"); }); var currentindex = 0; $(document).off('click','.roleinproject-tit').on("click",".roleinproject-tit",function(){ var index = $(this).attr("data-index"); currentindex = index; system = $(this).attr("data-system"); $(".projectadmin-con-hz-left-list-con").removeClass("selected___3ctlt"); $(this).addClass("selected___3ctlt"); $(".projectadmin-list-name").html(datalist[index]['name']); role_id = $(this).attr("data-id"); updataapiinfo(datalist[index]); }); function updataapiinfo(d){ console.log(d); X.laytpldata("#projectadmin-info-box-dot",d,".projectadmin-info-box"); }; $(document).off('click','.projectadmin-del').on('click','.projectadmin-del',function(){ var index = $(this).attr('data-index'); var path = $(this).attr('data-path'); var path_name = $(this).attr("data-name"); layer.confirm('确认取消当前api的授权?', { btn: ['取消','确认 '] //按钮 }, function(){ //取消 layer.close(layer.index); }, function(){ //删除 X.api("authz/del_policy",'post',{role_id:role_id,path:path,path_name: path_name,system:system},function(d){ console.log('11a23sd13as4d54a65'+ d); layer.close(layer.index); updataroles(role_id); layer.msg('操作成功'); }) }); }); $(document).off('click','.projectadmin-edit').on('click','.projectadmin-edit',function(params){ var index = $(this).attr('data-index'); var path = $(this).attr('data-path'); var path_name = $(this).attr("data-name"); X.api("authz/add_policy",'post',{role_id:role_id,path:path,path_name:path_name,system:system},function(d){ layer.close(layer.index); layer.msg('添加成功'); // updataapiinfo(datalist[currentindex]); updataroles(role_id); }) }); $(document).off('click','.projectadmin-gongduo').on('click','.projectadmin-gongduo',function(e){ e.stopPropagation(); var obj = $(this); var offset = obj.offset(); var id = obj.attr('data-id'); var name = obj.attr("data-name"); var arr = [ { title:'重命名', id:'edit' }, { title:'删除', id:'del' } ] X.querycriteriapop(arr,'dropdownlist',offset.left,offset.top+obj.height(),function(val){ if(val.id == 'del'){ layer.confirm('确认删除当前角色吗?', { btn: ['取消','删除 '] //按钮 }, function(){ //取消 layer.close(layer.index); }, function(){ //删除 X.api("authz/del_role_user",'post',{role_id:id,game:X['DATA']['game'],username:name},function(d){ layer.close(layer.index); layer.msg('删除成功'); updataroles(); }) }); }else { var arr = { id:id, title:$(".projectadmin-list-name").html() } X.parametersopen(arr,"roleeditname",'auto',function(d){ updataroles(); }) } }) }); } }; })();