lygbperson.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. var gridObj;
  2. var pagingObj;
  3. $(function () {
  4. gridObj = $.fn.bsgrid.init('searchTable', {
  5. url: prjContextPath+"/employeeAction!query.action",
  6. pageSizeSelect: true,
  7. stripeRows: true,
  8. pageSize: thisPageSize,//当前页显示行数
  9. otherParames:{"perPage":thisPageSize,"position":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. function show_mess_clo(){
  27. if(winhandle!=null){
  28. winhandle.reset();
  29. }
  30. }
  31. var winHandle;
  32. /*获取勾选的checkbox值*/
  33. function getCheckedIds() {
  34. var records = getCheckedRecords();
  35. var ids = '';
  36. for(var i = 0; i < records.length; i++) {
  37. ids += ',' + gridObj.getRecordIndexValue(records[i], 'id');
  38. }
  39. // alert(ids.length > 0 ? ids.substring(1) : '');
  40. }
  41. /*获取勾选checkbox对象*/
  42. function getCheckedRecords() {
  43. var records = new Array();
  44. $('#searchTable tbody tr').each(function() {
  45. if($(this).find('td:eq(0)>input:checked').length == 1){
  46. records[records.length] = gridObj.getRowRecord($(this));
  47. }
  48. });
  49. return records;
  50. }
  51. /*执行完成后回调函数*/
  52. function set_pageCon_end(){
  53. }
  54. /*功能区按钮*/
  55. function operate(record, rowIndex, colIndex, options) {
  56. return '<a href="#" onclick="data_query(\'' + gridObj.getRecordIndexValue(record, 'id') + '\');">'+"<img src='../../jqcase/builds/images/icons/system-search-6.png' alt='查看'>"+'</a>'
  57. +'&emsp;<a href="#" onclick="data_update(\'' + gridObj.getRecordIndexValue(record, 'id') + '\');">'+"<img src='../../jqcase/builds/images/icons/page-edit.png' alt='编辑'>"+'</a>'
  58. +'&emsp;<a href="#" onclick="data_delete(\'' + gridObj.getRecordIndexValue(record, 'id') + '\');">'+"<img src='../../jqcase/builds/images/icons/edit-delete-6.png' alt='删除'>"+'</a>';
  59. }
  60. var person_win_handle;
  61. //功能区查询按钮
  62. function data_query(jigouid){
  63. var url = prjContextPath+"/system/person/lygbperson_query.jsp?zuzhijigouid="+jigouid;
  64. person_win_handle = openWindow(url,450,200,'人员管理查看页面',this.window);
  65. }
  66. //功能区修改按钮
  67. function data_update(dataid){
  68. var url = prjContextPath+"/system/person/lygbperson_update.jsp?dataid="+dataid;
  69. person_win_handle = openWindow(url,450,200,'人员管理修改页面',this.window);
  70. }
  71. //增加按钮调用方法
  72. function add_data(){
  73. var zuzhijigouid=tree.getSelectedItemId();//获取数据库中主键
  74. if(!checkIsNotEmpty(zuzhijigouid)){
  75. winHandle=openSecondMessageWindow('请选择左侧组织机构中节点!',prjContextPath);
  76. return false;
  77. }
  78. // var a=tree.getAllFatItems().split(",");
  79. var a=tree.getUserData(tree.getSelectedItemId(), tree.getSelectedItemId()).split(",,,");
  80. var bumenid=a[0];//获取此岗位的部门ID
  81. var type=tree.getUserData(tree.getSelectedItemId(), tree.getSelectedItemId()).split(",,,");
  82. //alert(type[9]); //此元素代表当前选中节点的节点类型:科室,教师,学生等。
  83. //根据userdata中数据取出jigoutype
  84. if(type[3]!=0){
  85. //jigoutype为0,表示岗位
  86. var url = prjContextPath+"/system/person/lygbperson_add.jsp?zuzhijigouid="+zuzhijigouid+"&bumenid="+bumenid;
  87. person_win_handle = openWindow(url,450,200,'人员管理增加页面',this.window);
  88. }else{
  89. person_win_handle=openSecondMessageWindow('请选择岗位!',prjContextPath);
  90. return;
  91. }
  92. }
  93. function data_delete(dataid){
  94. parent._confirm_msg_show( '是否删除此信息?' , this.window.name+'.deleteCarManagerCall(1,'+dataid+')');
  95. }
  96. //删除操作,用户做选择后回调函数
  97. function deleteCarManagerCall(btn,dataid){
  98. var id=dataid;
  99. //如果点击确定
  100. if(btn == '1')
  101. {
  102. //删除人员前校验此人员是否被分配用户callBackForSelCout
  103. $.post(prjContextPath+"/employeeAction!selCouFroPer.action",{id:id},function callBackForSelCout(json){
  104. //如果此人员被分配用户,则不允许直接删除
  105. if(json.data[0]>0){
  106. person_win_handle=openSecondMessageWindow('此人员已被分配用户,请先删除被分配的用户!',prjContextPath);
  107. }else{
  108. $.post(prjContextPath+"/employeeAction!delete.action",{id:id},callBackFunFileDel);
  109. }
  110. });
  111. }else{
  112. gridObj.refreshPage();//刷新当前页
  113. }
  114. }
  115. function callBackFunFileDel(json){
  116. if(json.success==1){
  117. winHandle=openSecondMessageWindow('删除成功!',prjContextPath);
  118. if(gridObj.options.curPageRowsNum==1){
  119. if(gridObj.options.curPage==1){
  120. gridObj.refreshPage();
  121. }else{
  122. gridObj.prevPage();
  123. }
  124. }else{
  125. gridObj.refreshPage();
  126. }
  127. }else{
  128. winHandle=openSecondMessageWindow('删除失败,请联系管理员!',prjContextPath);
  129. }
  130. }
  131. //弹出窗口关闭
  132. function close_handle(flg){
  133. //flg:0 刷新到首页(增加);flg:1 刷新当前页(修改、删除)
  134. if(flg==0){
  135. if(gridObj.options.curPage!=1)
  136. gridObj.firstPage();
  137. else
  138. gridObj.refreshPage();
  139. }else{
  140. gridObj.refreshPage();
  141. }
  142. if(person_win_handle!=null){
  143. person_win_handle.reset();
  144. }
  145. }
  146. //关闭消息框
  147. function closeSysMes(){
  148. if(winHandle!=null){
  149. winHandle.reset();
  150. }
  151. close_handle(1);
  152. }
  153. //弹出窗口关闭
  154. function closeWindow(){
  155. gridObj.firstPage();
  156. if(person_win_handle!=null){
  157. parent.person_win_handle();
  158. }
  159. }