lygbRole.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. var gridObj;
  2. var pagingObj;
  3. $(function () {
  4. gridObj = $.fn.bsgrid.init('searchTable', {
  5. url: prjContextPath+"/roleAction!query.action",
  6. pageSizeSelect: true,
  7. stripeRows: true,
  8. pageSize: thisPageSize,//当前页显示行数
  9. otherParames:{"perPage":thisPageSize},//
  10. pageSizeSelect:false,
  11. displayBlankRows: false, // single grid setting
  12. displayPagingToolbarOnlyMultiPages: true, // single grid setting
  13. complete:set_pageCon_end() //执行完成后回调函数
  14. });
  15. // 表格的checkbox选择
  16. if($('#searchTable thead tr th:eq(0) input[type=checkbox]').length == 1) {
  17. $('#searchTable thead tr th:eq(0) input[type=checkbox]').change(function () {
  18. var checked = $.bsgrid.adaptAttrOrProp($(this), 'checked') ? true : false;
  19. $.bsgrid.adaptAttrOrProp($('#searchTable tbody tr td:nth-child(1)>input[type=checkbox]'), 'checked', checked);
  20. });
  21. }
  22. });
  23. function checkbox(record, rowIndex, colIndex, options) {
  24. return '<input type="checkbox" value="' + gridObj.getColumnValue(rowIndex, gridObj.getColumnAttr(colIndex, options.settings.colsProperties.indexAttr)) + '"/>';
  25. }
  26. /*获取勾选的checkbox值*/
  27. function getCheckedIds() {
  28. var records = getCheckedRecords();
  29. var ids = '';
  30. for(var i = 0; i < records.length; i++) {
  31. ids += ',' + gridObj.getRecordIndexValue(records[i], 'WANGGE_ID');
  32. }
  33. alert(ids.length > 0 ? ids.substring(1) : '');
  34. }
  35. /*获取勾选checkbox对象*/
  36. function getCheckedRecords() {
  37. var records = new Array();
  38. $('#searchTable tbody tr').each(function() {
  39. if($(this).find('td:eq(0)>input:checked').length == 1){
  40. records[records.length] = gridObj.getRowRecord($(this));
  41. }
  42. });
  43. return records;
  44. }
  45. /*执行完成后回调函数*/
  46. function set_pageCon_end(){
  47. }
  48. /*获取选中行主键*/
  49. function get_choose_row(){
  50. var chooseRowId=gridObj.getRecordIndexValue(gridObj.getRowRecord(gridObj.getSelectedRow()), 'WANGGE_ID');
  51. alert(chooseRowId);
  52. }
  53. /*功能区按钮*/
  54. function operate(record, rowIndex, colIndex, options) {
  55. return '<a href="#" onclick="role_update(\'' + gridObj.getRecordIndexValue(record, 'roleid') + '\');">'+"<img src='../../jqcase/builds/images/icons/page-edit.png' alt='编辑'>"+'</a>'
  56. +'&emsp;<a href="#" onclick="role_delete(\'' + gridObj.getRecordIndexValue(record, 'roleid') + '\');">'+"<img src='../../jqcase/builds/images/icons/edit-delete-6.png' alt='删除'>"+'</a>';
  57. }
  58. function my_test(){
  59. var url = prjContextPath+"/jCaseAction!exe_pro.action";
  60. $.post(url, null, null);
  61. }
  62. var win_handle;
  63. //增加按钮
  64. function role_add(){
  65. var url = prjContextPath+"/system/role/lygbRole_add.jsp";
  66. role_winHandle = openWindow(url,450,200,'角色管理增加页面',this.window);
  67. }
  68. //功能区-修改按钮
  69. function role_update(roleid){
  70. var url = prjContextPath+"/system/role/lygbRole_update.jsp?roleid="+roleid;
  71. role_winHandle = openWindow(url,450,200,'角色管理修改页面',this.window);
  72. }
  73. //功能区-修改按钮
  74. function role_delete(roleid){
  75. parent._confirm_msg_show( '是否删除此信息?' , this.window.name+'.deleteCarManagerCall(1,'+roleid+')');
  76. }
  77. //删除操作,用户做选择后回调函数
  78. function deleteCarManagerCall(btn,roleid){
  79. //如果点击确定
  80. if(btn == '1')
  81. {
  82. $.post(prjContextPath+"/roleAction!delete.action",{roleid:roleid},callBackFunFileDel);
  83. }else{
  84. gridObj.refreshPage();//刷新当前页
  85. }
  86. }
  87. var role_winHandle
  88. function callBackFunFileDel(json){
  89. if(json.success==1){
  90. role_winHandle=openSecondMessageWindow('删除成功!',prjContextPath);
  91. // close_handle(1);
  92. if(gridObj.options.curPageRowsNum==1){
  93. if(gridObj.options.curPage==1){
  94. gridObj.refreshPage();
  95. }else{
  96. gridObj.prevPage();
  97. }
  98. }else{
  99. gridObj.refreshPage();
  100. }
  101. }else if(json.success==0){
  102. role_winHandle=openSecondMessageWindow('删除失败,请查看此角色是否已被赋予权限!',prjContextPath);
  103. // close_handle(1);
  104. }
  105. }
  106. //权限按钮调用方法
  107. function authority_add(){
  108. var rowid=gridObj.getRecordIndexValue(gridObj.getRowRecord(gridObj.getSelectedRow()), 'roleid');
  109. if(rowid==null||rowid==""){
  110. role_winHandle=openSecondMessageWindow('请选择要维护的数据!',prjContextPath);
  111. }else{
  112. var url = prjContextPath+"/system/role/lygbroleModule.jsp?roleid="+rowid;
  113. role_winHandle = openWindow(url,420,310,'设置角色模块',this.window);
  114. }
  115. }
  116. //关闭窗口
  117. function close_handle(flg){
  118. //flg:0 刷新到首页(增加);flg:1 刷新当前页(修改、删除)
  119. if(flg==0){
  120. if(gridObj.options.curPage!=1)
  121. gridObj.firstPage();
  122. else
  123. gridObj.refreshPage();
  124. }else{
  125. gridObj.refreshPage();
  126. }
  127. if(role_winHandle!=null||win_handle=="undefined"){
  128. role_winHandle.reset();
  129. }
  130. }
  131. //关闭消息框
  132. function closeSysMes(){
  133. if(role_winHandle!=null){
  134. role_winHandle.reset();
  135. }
  136. close_handle(1);
  137. }
  138. //弹出窗口关闭
  139. function closeWindow(){
  140. gridObj.firstPage();
  141. if(role_winHandle!=null){
  142. parent.win_handle();
  143. }
  144. }