123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="renderer" content="webkit|ie-comp|ie-stand">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
- <meta http-equiv="Cache-Control" content="no-siteapp" />
- <!--[if lt IE 9]>
- <script type="text/javascript" src="${ctx}/assets/lib/html5.js"></script>
- <script type="text/javascript" src="${ctx}/assets/lib/respond.min.js"></script>
- <script type="text/javascript" src="${ctx}/assets/lib/PIE_IE678.js"></script>
- <![endif]-->
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui/css/H-ui.min.css" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/css/H-ui.admin.css" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/Hui-iconfont/1.0.7/iconfont.css" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/icheck/icheck.css" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/skin/default/skin.css" id="skin" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/css/style.css" />
- <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" >
- <script type="text/ecmascript" src="${ctx}/assets/lib/jquery/1.9.1/jquery.js"></script>
- <script type="text/javascript" src="${ctx}/assets/static/h-ui/js/H-ui.js"></script>
- <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqueryui/jquery-ui.css" />
- <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqgrid/css/ui.jqgrid.css" />
- <script type="text/ecmascript" src="${ctx}/assets/lib/jqueryui/jquery-ui.js"></script>
- <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/i18n/grid.locale-cn.js"></script>
- <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/jquery.jqGrid.min.js"></script>
- <script type="text/javascript" src="${ctx}/assets/js/base.js"></script>
- <script type="text/javascript" src="${ctx}/assets/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
- <!--[if IE 6]>
- <script type="text/javascript" src="${ctx}/assets/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
- <script>DD_belatedPNG.fix('*');</script>
- <![endif]-->
- <script type="text/javascript">
- $(function() {
- $("#jqGrid").jqGrid({
- url : '${ctx}/myconsole/role/getByPage',
- editurl:"${ctx}/myconsole/role/op",
- mtype : "POST",
- datatype : "json",
- caption:'角色管理',
- colModel : [ {
- label : '角色编号',
- name : 'keyid',
- editable: false,
- key : true,
- width : 50,
- }, {
- label : '角色名称',
- name : 'rolename',
- editable: true,
- formoptions:{
- elmsuffix:" <span style='color:red'>*<span>"
- },
- editrules:{required:true},
- width : 80,
- editoptions: {
- size:50,
- maxlength: 16
- }
- }, {
- label : '角色描述',
- name : 'note',
- editable: true,
- hidden:true,
- width : 100,
- edittype : "textarea",
- editrules:{
- edithidden : true
- },
- editoptions: {
- size:50,
- maxlength: 50,
- rows:"3",
- cols:"49"
- }
- }, {
- label : '排序值',
- name : 'sortid',
- editable: true,
- hidden : true,
- formoptions:{
- elmsuffix:' 必须是数字'
- },
- width : 80,
- editrules:{
- edithidden : true
- },
- editoptions: {
- size:10,
- maxlength: 5
- }
- } , {
- label : '创建人',
- name : 'insertusername',
- editable: false,
- width : 80,
- }, {
- label : '创建时间',
- name : 'inserttime',
- editable: false,
- width : 80,
- }],
- rownumbers : true,//添加左侧行号
- viewrecords : true,//是否在浏览导航栏显示记录总数
- rowNum : 15,//每页显示记录数
- rowList : [10,15,20,30,40,50 ],//用于改变显示行数的下拉列表框的元素数组。
- autowidth : true,
- height : 'auto',
- pager : "#jqGridPager",
- prmNames:{
- id:"keyid"
- },
- loadComplete: function() {
- if (true){
- $('td[title="分配权限"]').show();
- }
- }
- });
- $('#jqGrid').navGrid('#jqGridPager',
- {
- edit : true,
- add : true,
- del : true,
- search : true,
- view : true,
- position : "left",
- cloneToTop : true
- },
- {
- recreateForm : true,
- checkOnUpdate : true,
- checkOnSubmit : true,
- closeAfterEdit : true,
- onInitializeForm:function(formid) {
- //makeTree("orgid","/myconsole/user/getOrgTree","radio");
- },
- serializeEditData: function(postdata) {
- $.each(postdata,function (index, value) {
- if(index!="jqGrid_id" && index!="oper" && index!="id"){
- modifyJosnKey(postdata,index,"role."+index);
- }
- if(index=="id"){
- postdata["role."+index]=value
- }
- })
- return postdata;
- },
- errorTextFormat : function(data) {
- return 'Error: ' + data.responseText
- }
- },
- {
- closeAfterAdd : true,
- recreateForm : true,
- beforeSubmit: function(postdata, formid){
- $.each(postdata,function (index, value) {
- if(index!="jqGrid_id" && index!="oper"){
- modifyJosnKey(postdata,index,"role."+index);
- }
- })
- postdata["role.keyid"] = "";
- return[true,''];
- },
- errorTextFormat : function(data) {
- return 'Error: ' + data.responseText
- }
- },
- {
- errorTextFormat : function(data) {
- return 'Error: ' + data.responseText
- }
- },{
- // search options 这里支持多条件查询
- multipleSearch: true,
- closeAfterSearch: true,
- sopt:['eq','ne','cn','nc','lt','le','gt','ge'],
- afterSubmit: function(r, data) {
- var messageString = r.responseText;
- var mesObj = eval('(' + messageString + ')');
- return [mesObj.state, mesObj.message];
- }
- }
- ).navButtonAdd('#jqGridPager',{
- title:"分配权限",
- caption:"分配权限",
- buttonicon:"ui-icon-del",
- onClickButton: function(){
- var sel=$('#jqGrid').jqGrid('getGridParam','selrow');
- if(sel==null){
- //alert('请先选择数据');
- parent.layer.alert("请先选择需要编辑的行!", {
- skin: 'layui-layer-molv' //样式类名
- ,closeBtn: 0
- });
- }else{
-
- var lzck=$('<div id="dd" style="overflow:hidden"><iframe id="xx" scrolling="auto" frameborder="0" src="${ctx}/myconsole/perm?roleid='+sel+'" style="width:100%;height:98%;"></iframe></div>');
-
- lzck.dialog({
- title: '分配权限',
- width: 1000,
- height: 550,
- closed : false,
- cache : false,
- modal : true,
- });
- }
- },
- position : "last"
- }
- )
- .navButtonAdd("#jqGridPager",{
- caption:'分配用户',
- id:'role',
- onClickButton:function(){
- var selectedRowId = $("#jqGrid").jqGrid("getGridParam", "selrow");
- if (!selectedRowId) {
- //alert("请先选择需要编辑的行!");
- parent.layer.alert("请先选择需要编辑的行!", {
- skin: 'layui-layer-molv' //样式类名
- ,closeBtn: 0
- });
- return false;
- } else {
- var RoleID=selectedRowId;
- var zTreeObj;
- var zNodes;
- function zTreeChecked(event, treeId, treeNode) {
- $.post("${ctx}/myconsole/role/saveUserRole",{"roleid":RoleID,"userkeyid":treeNode.id,"checked":treeNode.checked},function(data){
- //alert(data.msg);
- parent.layer.msg(data.msg);
- })
- };
- function ajaxDataFilter(treeId, parentNode, data) {
- if(data == "") return;
- var zNodes = [];
-
- var orgN = data.Org;
- orgN.forEach(function(item,index){
- zNodes.push({id:item.orgid,pId:item.parentid,name:item.orgname,istype:false, isParent:true,"nocheck":true});
- })
- var userN = data.User;
- userN.forEach(function(item,index){
- zNodes.push({id:item.keyid,pId:item.orgid,name:item.username,istype:true,checked:item.chk});
- })
-
- return zNodes;
- }
- var setting = { //初始化树
- check: {
- enable: true,
- chkboxType: { "Y" : "", "N" : "" },
- autoCheckTrigger: true
- },
- data: {
- simpleData: {
- idKey:"id",
- pIdKey:"pId",
- enable:true,
- rootPId:"${OrgParentID}"
- }
- },
- callback: {
- onCheck: zTreeChecked
- },
- async:{
- enable:true,
- url:"${ctx}/myconsole/role/getUserTree?roleid=" + RoleID,
- autoParam:["id", "name"] ,
- dataFilter: ajaxDataFilter
- }
- };
-
- //获取数据
- $.ajax({
- url : "${ctx}/myconsole/role/getUserTree?roleid=" + RoleID+"&name=CSH",
- type : "post",
- dataType : "json",
- success : function(data) {
- if(data == "") return;
- var zNodes = [];
- var orgN = data.Org;
- orgN.forEach(function(item,index){
- zNodes.push({id:item.orgid,pId:item.parentid,name:item.orgname,istype:false, isParent:true,"nocheck":true});
- })
-
- var userN = data.User;
- userN.forEach(function(item,index){
- zNodes.push({id:item.keyid,pId:item.orgid,name:item.username,istype:true,checked:item.chk});
- })
-
- zTreeObj = $.fn.zTree.init($("#UserTree"), setting, zNodes);//初始化树节点时,添加同步获取的数据
- }
- });
- $('<div id="dlgSetUser"><ul id="UserTree" class="ztree"></ul></div>').dialog({
- title : '分配用户',
- width : 400,
- height : 450,
- closed : false,
- cache : false,
- modal : true
- });
- $(".ui-dialog-titlebar-close").click(function(){
- $("#dlgSetUser").remove();
- });
- }
- }
- });
- ;
- })
- </script>
- <title>角色管理</title>
- </head>
- <body>
- <div class="page-container">
- <table id="jqGrid"></table>
- <div id="jqGridPager"></div>
- </div>
- <footer class="footer mt-20">
- <div class="container">
- <p></p>
- </div>
- </footer>
- </body>
- </html>
|