lygbUser.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. var gridObj;
  2. var pagingObj;
  3. $(function () {
  4. gridObj = $.fn.bsgrid.init('searchTable', {
  5. url: prjContextPath+"/permissionsAction!query.action",
  6. pageSizeSelect: true,
  7. stripeRows: true,
  8. pageSize: thisPageSize,//当前页显示行数
  9. otherParames:{"perPage":thisPageSize,"position":0,"deptid":0},//
  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 operate(record, rowIndex, colIndex, options) {
  50. return '<a href="#" onclick="updateNewRow(\'' + gridObj.getRecordIndexValue(record, 'userid') + '\',\''+gridObj.getRecordIndexValue(record, 'id')+'\',\''+gridObj.getRecordIndexValue(record, 'loginname')+'\');">'+"<img src='../../jqcase/builds/images/icons/system-config-boot.png' alt='权限'>"+'</a>'
  51. +'&emsp;<a href="#" onclick="data_update(\'' + gridObj.getRecordIndexValue(record, 'userid') + '\',\''+gridObj.getRecordIndexValue(record, 'id')+'\',\''+gridObj.getRecordIndexValue(record, 'loginname')+'\');">'+"<img src='../../jqcase/builds/images/icons/page-edit.png' alt='编辑'>"+'</a>'
  52. +'&emsp;<a href="#" onclick="data_delete(\'' + gridObj.getRecordIndexValue(record, 'id') + '\');">'+"<img src='../../jqcase/builds/images/icons/edit-delete-6.png' alt='删除'>"+'</a>';
  53. }
  54. var user_win_handle;
  55. //功能区修改按钮
  56. function data_update(userid,id,loginname){
  57. //根据登陆账号是否为空判断
  58. if(loginname=="undefined"||loginname==null||loginname=="")
  59. {
  60. //增加页面
  61. var url = prjContextPath+"/system/permissions/lygbUser_add.jsp?userid="+userid;
  62. user_win_handle = openWindow(url,450,200,'用户管理增加页面',this.window);
  63. }else {
  64. //修改页面
  65. var url = prjContextPath+"/system/permissions/lygbUser_update.jsp?id="+id;
  66. user_win_handle = openWindow(url,450,200,'用户管理修改页面',this.window);
  67. }
  68. }
  69. //功能区-修改按钮
  70. function data_delete(dataid){
  71. if(dataid==""){
  72. user_win_handle=openSecondMessageWindow('您选择的数据尚未创建账号,请先创建账号!',prjContextPath);
  73. return false;
  74. }
  75. parent._confirm_msg_show( '是否要删除此信息?' , this.window.name+'.deleteCarManagerCall(1,'+dataid+')');
  76. }
  77. //删除操作,用户做选择后回调函数
  78. function deleteCarManagerCall(btn,dataid){
  79. //如果点击确定
  80. if(btn == '1')
  81. {
  82. $.post(prjContextPath+"/permissionsAction!delete.action",{id:dataid},callBackFunFileDel);
  83. }else{
  84. gridObj.refreshPage();//刷新当前页
  85. }
  86. }
  87. function callBackFunFileDel(json){
  88. if(json.success==1){
  89. user_win_handle=openSecondMessageWindow('删除成功!',prjContextPath);
  90. // close_handle(1);
  91. }else if(json.success==0){
  92. user_win_handle=openSecondMessageWindow('删除失败,请查看此账户是否已被分配角色!',prjContextPath);
  93. }
  94. }
  95. //增加按钮调用方法
  96. function add_data(){
  97. //暂时失效
  98. }
  99. //编辑单条数据
  100. function updateNewRow(userid,id,loginname){
  101. if(loginname=="undefined"||loginname==null||loginname=="")
  102. {
  103. user_win_handle=openSecondMessageWindow('您选择的数据尚未创建账号,请先创建账号!',prjContextPath);
  104. return false;
  105. }else {
  106. var url=prjContextPath+'/system/permissions/userRoleRange.jsp?id='+id+'&userid='+userid;
  107. user_win_handle = openWindow(url,420,340,'用户分配角色页面',this.window);
  108. }
  109. }
  110. //弹出窗口关闭
  111. function close_handle(flg){
  112. //flg:0 刷新到首页(增加);flg:1 刷新当前页(修改、删除)
  113. if(flg==0){
  114. if(gridObj.options.curPage!=1)
  115. gridObj.firstPage();
  116. else
  117. gridObj.refreshPage();
  118. }else{
  119. gridObj.refreshPage();
  120. }
  121. if(user_win_handle!=null||user_win_handle=="undefined"){
  122. user_win_handle.reset();
  123. }
  124. }
  125. //关闭消息框
  126. function closeSysMes(){
  127. if(user_win_handle!=null){
  128. user_win_handle.reset();
  129. }
  130. close_handle(1);
  131. }
  132. //弹出窗口关闭
  133. function closeWindow(){
  134. gridObj.firstPage();
  135. if(user_win_handle!=null){
  136. parent.win_handle();
  137. }
  138. }