role.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="renderer" content="webkit|ie-comp|ie-stand">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  8. <meta http-equiv="Cache-Control" content="no-siteapp" />
  9. <!--[if lt IE 9]>
  10. <script type="text/javascript" src="${ctx}/assets/lib/html5.js"></script>
  11. <script type="text/javascript" src="${ctx}/assets/lib/respond.min.js"></script>
  12. <script type="text/javascript" src="${ctx}/assets/lib/PIE_IE678.js"></script>
  13. <![endif]-->
  14. <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui/css/H-ui.min.css" />
  15. <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/css/H-ui.admin.css" />
  16. <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/Hui-iconfont/1.0.7/iconfont.css" />
  17. <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/icheck/icheck.css" />
  18. <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/skin/default/skin.css" id="skin" />
  19. <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/css/style.css" />
  20. <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" >
  21. <script type="text/ecmascript" src="${ctx}/assets/lib/jquery/1.9.1/jquery.js"></script>
  22. <script type="text/javascript" src="${ctx}/assets/static/h-ui/js/H-ui.js"></script>
  23. <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqueryui/jquery-ui.css" />
  24. <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqgrid/css/ui.jqgrid.css" />
  25. <script type="text/ecmascript" src="${ctx}/assets/lib/jqueryui/jquery-ui.js"></script>
  26. <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/i18n/grid.locale-cn.js"></script>
  27. <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/jquery.jqGrid.min.js"></script>
  28. <script type="text/javascript" src="${ctx}/assets/js/base.js"></script>
  29. <script type="text/javascript" src="${ctx}/assets/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
  30. <!--[if IE 6]>
  31. <script type="text/javascript" src="${ctx}/assets/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
  32. <script>DD_belatedPNG.fix('*');</script>
  33. <![endif]-->
  34. <script type="text/javascript">
  35. $(function() {
  36. $("#jqGrid").jqGrid({
  37. url : '${ctx}/myconsole/role/getByPage',
  38. editurl:"${ctx}/myconsole/role/op",
  39. mtype : "POST",
  40. datatype : "json",
  41. caption:'角色管理',
  42. colModel : [ {
  43. label : '角色编号',
  44. name : 'keyid',
  45. editable: false,
  46. key : true,
  47. width : 50,
  48. }, {
  49. label : '角色名称',
  50. name : 'rolename',
  51. editable: true,
  52. formoptions:{
  53. elmsuffix:" <span style='color:red'>*<span>"
  54. },
  55. editrules:{required:true},
  56. width : 80,
  57. editoptions: {
  58. size:50,
  59. maxlength: 16
  60. }
  61. }, {
  62. label : '角色描述',
  63. name : 'note',
  64. editable: true,
  65. hidden:true,
  66. width : 100,
  67. edittype : "textarea",
  68. editrules:{
  69. edithidden : true
  70. },
  71. editoptions: {
  72. size:50,
  73. maxlength: 50,
  74. rows:"3",
  75. cols:"49"
  76. }
  77. }, {
  78. label : '排序值',
  79. name : 'sortid',
  80. editable: true,
  81. hidden : true,
  82. formoptions:{
  83. elmsuffix:' 必须是数字'
  84. },
  85. width : 80,
  86. editrules:{
  87. edithidden : true
  88. },
  89. editoptions: {
  90. size:10,
  91. maxlength: 5
  92. }
  93. } , {
  94. label : '创建人',
  95. name : 'insertusername',
  96. editable: false,
  97. width : 80,
  98. }, {
  99. label : '创建时间',
  100. name : 'inserttime',
  101. editable: false,
  102. width : 80,
  103. }],
  104. rownumbers : true,//添加左侧行号
  105. viewrecords : true,//是否在浏览导航栏显示记录总数
  106. rowNum : 15,//每页显示记录数
  107. rowList : [10,15,20,30,40,50 ],//用于改变显示行数的下拉列表框的元素数组。
  108. autowidth : true,
  109. height : 'auto',
  110. pager : "#jqGridPager",
  111. prmNames:{
  112. id:"keyid"
  113. },
  114. loadComplete: function() {
  115. if (true){
  116. $('td[title="分配权限"]').show();
  117. }
  118. }
  119. });
  120. $('#jqGrid').navGrid('#jqGridPager',
  121. {
  122. edit : true,
  123. add : true,
  124. del : true,
  125. search : true,
  126. view : true,
  127. position : "left",
  128. cloneToTop : true
  129. },
  130. {
  131. recreateForm : true,
  132. checkOnUpdate : true,
  133. checkOnSubmit : true,
  134. closeAfterEdit : true,
  135. onInitializeForm:function(formid) {
  136. //makeTree("orgid","/myconsole/user/getOrgTree","radio");
  137. },
  138. serializeEditData: function(postdata) {
  139. $.each(postdata,function (index, value) {
  140. if(index!="jqGrid_id" && index!="oper" && index!="id"){
  141. modifyJosnKey(postdata,index,"role."+index);
  142. }
  143. if(index=="id"){
  144. postdata["role."+index]=value
  145. }
  146. })
  147. return postdata;
  148. },
  149. errorTextFormat : function(data) {
  150. return 'Error: ' + data.responseText
  151. }
  152. },
  153. {
  154. closeAfterAdd : true,
  155. recreateForm : true,
  156. beforeSubmit: function(postdata, formid){
  157. $.each(postdata,function (index, value) {
  158. if(index!="jqGrid_id" && index!="oper"){
  159. modifyJosnKey(postdata,index,"role."+index);
  160. }
  161. })
  162. postdata["role.keyid"] = "";
  163. return[true,''];
  164. },
  165. errorTextFormat : function(data) {
  166. return 'Error: ' + data.responseText
  167. }
  168. },
  169. {
  170. errorTextFormat : function(data) {
  171. return 'Error: ' + data.responseText
  172. }
  173. },{
  174. // search options 这里支持多条件查询
  175. multipleSearch: true,
  176. closeAfterSearch: true,
  177. sopt:['eq','ne','cn','nc','lt','le','gt','ge'],
  178. afterSubmit: function(r, data) {
  179. var messageString = r.responseText;
  180. var mesObj = eval('(' + messageString + ')');
  181. return [mesObj.state, mesObj.message];
  182. }
  183. }
  184. ).navButtonAdd('#jqGridPager',{
  185. title:"分配权限",
  186. caption:"分配权限",
  187. buttonicon:"ui-icon-del",
  188. onClickButton: function(){
  189. var sel=$('#jqGrid').jqGrid('getGridParam','selrow');
  190. if(sel==null){
  191. //alert('请先选择数据');
  192. parent.layer.alert("请先选择需要编辑的行!", {
  193. skin: 'layui-layer-molv' //样式类名
  194. ,closeBtn: 0
  195. });
  196. }else{
  197. 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>');
  198. lzck.dialog({
  199. title: '分配权限',
  200. width: 1000,
  201. height: 550,
  202. closed : false,
  203. cache : false,
  204. modal : true,
  205. });
  206. }
  207. },
  208. position : "last"
  209. }
  210. )
  211. .navButtonAdd("#jqGridPager",{
  212. caption:'分配用户',
  213. id:'role',
  214. onClickButton:function(){
  215. var selectedRowId = $("#jqGrid").jqGrid("getGridParam", "selrow");
  216. if (!selectedRowId) {
  217. //alert("请先选择需要编辑的行!");
  218. parent.layer.alert("请先选择需要编辑的行!", {
  219. skin: 'layui-layer-molv' //样式类名
  220. ,closeBtn: 0
  221. });
  222. return false;
  223. } else {
  224. var RoleID=selectedRowId;
  225. var zTreeObj;
  226. var zNodes;
  227. function zTreeChecked(event, treeId, treeNode) {
  228. $.post("${ctx}/myconsole/role/saveUserRole",{"roleid":RoleID,"userkeyid":treeNode.id,"checked":treeNode.checked},function(data){
  229. //alert(data.msg);
  230. parent.layer.msg(data.msg);
  231. })
  232. };
  233. function ajaxDataFilter(treeId, parentNode, data) {
  234. if(data == "") return;
  235. var zNodes = [];
  236. var orgN = data.Org;
  237. orgN.forEach(function(item,index){
  238. zNodes.push({id:item.orgid,pId:item.parentid,name:item.orgname,istype:false, isParent:true,"nocheck":true});
  239. })
  240. var userN = data.User;
  241. userN.forEach(function(item,index){
  242. zNodes.push({id:item.keyid,pId:item.orgid,name:item.username,istype:true,checked:item.chk});
  243. })
  244. return zNodes;
  245. }
  246. var setting = { //初始化树
  247. check: {
  248. enable: true,
  249. chkboxType: { "Y" : "", "N" : "" },
  250. autoCheckTrigger: true
  251. },
  252. data: {
  253. simpleData: {
  254. idKey:"id",
  255. pIdKey:"pId",
  256. enable:true,
  257. rootPId:"${OrgParentID}"
  258. }
  259. },
  260. callback: {
  261. onCheck: zTreeChecked
  262. },
  263. async:{
  264. enable:true,
  265. url:"${ctx}/myconsole/role/getUserTree?roleid=" + RoleID,
  266. autoParam:["id", "name"] ,
  267. dataFilter: ajaxDataFilter
  268. }
  269. };
  270. //获取数据
  271. $.ajax({
  272. url : "${ctx}/myconsole/role/getUserTree?roleid=" + RoleID+"&name=CSH",
  273. type : "post",
  274. dataType : "json",
  275. success : function(data) {
  276. if(data == "") return;
  277. var zNodes = [];
  278. var orgN = data.Org;
  279. orgN.forEach(function(item,index){
  280. zNodes.push({id:item.orgid,pId:item.parentid,name:item.orgname,istype:false, isParent:true,"nocheck":true});
  281. })
  282. var userN = data.User;
  283. userN.forEach(function(item,index){
  284. zNodes.push({id:item.keyid,pId:item.orgid,name:item.username,istype:true,checked:item.chk});
  285. })
  286. zTreeObj = $.fn.zTree.init($("#UserTree"), setting, zNodes);//初始化树节点时,添加同步获取的数据
  287. }
  288. });
  289. $('<div id="dlgSetUser"><ul id="UserTree" class="ztree"></ul></div>').dialog({
  290. title : '分配用户',
  291. width : 400,
  292. height : 450,
  293. closed : false,
  294. cache : false,
  295. modal : true
  296. });
  297. $(".ui-dialog-titlebar-close").click(function(){
  298. $("#dlgSetUser").remove();
  299. });
  300. }
  301. }
  302. });
  303. ;
  304. })
  305. </script>
  306. <title>角色管理</title>
  307. </head>
  308. <body>
  309. <div class="page-container">
  310. <table id="jqGrid"></table>
  311. <div id="jqGridPager"></div>
  312. </div>
  313. <footer class="footer mt-20">
  314. <div class="container">
  315. <p></p>
  316. </div>
  317. </footer>
  318. </body>
  319. </html>