deptUserTree.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. var managerTree = "";
  2. var isSingle = false;
  3. var h = 500;
  4. (function($) {
  5. $.tree = function(e, o) {
  6. var param = "";
  7. if(o.tabParam ==undefined)o.tabParam = "";
  8. else{
  9. for(var i=0;i<o.tabParam.length;i++){
  10. var tab = o.tabParam[i];
  11. var tabIndex = tab["tab"];
  12. var root = tab["root"];
  13. var ttype = tab["ttype"];
  14. var tabName = tab["tabName"];
  15. var tabId = tab["id"];
  16. var isMultiDept = tab["isMultiDept"];
  17. var action = tab["action"];
  18. if(tabIndex==undefined)tabIndex="";
  19. if(isMultiDept==undefined)isMultiDept="";
  20. if(root==undefined)root="";
  21. if(ttype==undefined)ttype="";
  22. if(tabName==undefined)tabName="";
  23. if(tabId==undefined)tabId="";
  24. if(action==undefined){
  25. action="";
  26. }else{
  27. action=action.replace("&","!");
  28. }
  29. param+="$"+tabIndex+"_"+root+"_"+isMultiDept+"_"+ttype+"_"+tabName+"_"+tabId+"_"+action;
  30. }
  31. if(param.length>0)param = param.substring(1);
  32. }
  33. if(o.root ==undefined) o.root = "";
  34. if(o.groot ==undefined) o.groot = "";
  35. if(o.isMultiDept ==undefined) o.isMultiDept = "";
  36. if(o.userState ==undefined) o.userState = "1";
  37. if(o.mainPost==undefined)o.mainPost="";//岗位显示参数(1、只显示主岗,0、只显示副岗,空显示所有)
  38. var wh = $(window).height()-200;
  39. o = $.extend({
  40. url : getProjectName() + "/loadDeptUserTree.do?filter="
  41. +o.filter+"&type="+o.type+"&root="+o.root+"&groot="+o.groot+"&mainPost="+o.mainPost
  42. +"&param="+param+"&isMultiDept="+o.isMultiDept+"&userState="+o.userState+"&t=" + new Date().getTime(),
  43. height:wh,
  44. width:550,
  45. type:"user",
  46. selectId:"",
  47. iframeName:"",
  48. buttons:[{
  49. text : '确定',
  50. onclick : function(item, dialog) {
  51. var idObj = o.win.getElementsByName(o.backId);
  52. var nameObj = o.win.getElementsByName(o.backName);
  53. if(idObj.length==0)idObj = o.win.getElementById(o.backId);
  54. if(nameObj.length==0)nameObj = o.win.getElementById(o.backName);
  55. var checkList = findIframeByJquery("deptTreeFrame",".checkList");
  56. var ids = "";
  57. var names="";
  58. $("li",checkList).each(function(){
  59. var selectId = $(this).attr("id");
  60. selectId = selectId.substring(selectId.indexOf("_")+1);
  61. names += ","+$(this).text();
  62. ids +=","+selectId;
  63. });
  64. if(ids!=""){
  65. ids = ids.substring(1);
  66. }
  67. if(names!=""){
  68. names = names.substring(1);
  69. }
  70. if(o.okpress){
  71. o.okpress(ids, names);
  72. }else{
  73. $(idObj).val(ids);
  74. $(nameObj).change();
  75. $(nameObj).val(names);
  76. }
  77. dialog.close();
  78. }
  79. }, {
  80. text : '取消',
  81. onclick : function(item, dialog) {
  82. dialog.close();
  83. }
  84. } ]
  85. }, o);
  86. var action = {
  87. openTree : function() {
  88. type = o.type;
  89. if(o.tab==undefined)o.tab="";
  90. $.ligerDialog.open({
  91. url : o.url+"&selectId="+o.selectId+"&tab="+o.tab,
  92. height : o.height,
  93. width : o.width,
  94. buttons :o.buttons,
  95. isHidden:false,
  96. name:"deptTreeFrame"
  97. });
  98. }
  99. };
  100. $(e).unbind("click");
  101. $(e).bind("click",function() {
  102. var selectObj = $(e).parents("body").find("#"+o.backId);
  103. if($(selectObj).length == 0)selectObj = $("input[name='"+o.backId+"']",$(e).parents("body"));
  104. o.selectId = $(selectObj).val();
  105. action.openTree();
  106. });
  107. };
  108. $.fn.bindTree = function(options) {
  109. $.tree(this, options);
  110. };
  111. })(jQuery);
  112. function loadDeptTree(e,options){
  113. $(e).bindTree(options);
  114. }