f06b40b135436e8810234b4461320c11b83a3964.svn-base 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. var setting1;
  2. var corpId = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  3. var role_id = top.com.sinosoft.lz.system.user.LoginInfo.getRoleids();
  4. var corpName = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_names();
  5. var deptId = top.com.sinosoft.lz.system.user.LoginInfo.getDeptids();
  6. //获取用户Id
  7. var user_id = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
  8. var yqRole = getYqRole(role_id);
  9. //记录选中的组织id
  10. var selectedOrgId=[];
  11. var addTreeNodes=[];
  12. var zTree = $.fn.zTree.getZTreeObj("myTree1");
  13. function initTree1(){
  14. $.fn.zTree.init($("#myTree1"), setting1);
  15. }
  16. function getDeptLevel2(dpids){
  17. var dept_level = "";
  18. $.ajax({
  19. url : $.pathname()+ "/ws/planService/PlanService/getDeptLevel",
  20. type : 'post',
  21. timeout : 60000,
  22. data : {id:dpids},
  23. dataType : 'text',
  24. async: false,
  25. success : function(data){
  26. dept_level = data;
  27. }
  28. });
  29. return dept_level;
  30. }
  31. function showData(selectedComp,report_type,affair){
  32. selectedOrgId = selectedComp.split(",");
  33. setting1 = {
  34. async : {
  35. enable : true,
  36. dataType : 'JSON',
  37. contentType : "application/json",
  38. dataName : 'treeNodes',
  39. url : $.pathname() +"/ws/getRepotDept/ReportDeptService/getAllDeptTree",
  40. autoParam : [ "id" ],
  41. otherParam : [ "corpId",corpId ,"selectedComp",selectedComp,"deptLevel",getDeptLevel2(corpId)]
  42. },
  43. check : {
  44. enable:true,
  45. },
  46. callback:{
  47. onClick:nodeCheck
  48. }
  49. };
  50. initTree1();
  51. }
  52. //数据补录里的单位选择
  53. function showData2(selectedComp,report_type,affair){
  54. setting1 = {
  55. async : {
  56. enable : true,
  57. dataType : 'JSON',
  58. contentType : "application/json",
  59. dataName : 'treeNodes',
  60. url : $.pathname() +"/ws/getRepotDept/ReportDeptService/getAllDeptTree2",
  61. autoParam : [ "id" ],
  62. otherParam : [ "corpId",corpId ,"deptLevel",getDeptLevel2(corpId),"roleId",role_id]
  63. },
  64. check : {
  65. enable:true,
  66. },
  67. callback:{
  68. onClick:nodeCheck
  69. }
  70. };
  71. //取消父子节点的相互关联
  72. setting1.check.chkboxType = {
  73. "Y":"",
  74. "N":""
  75. };
  76. initTree1();
  77. }
  78. function queDing(){
  79. var treeObj = $.fn.zTree.getZTreeObj("myTree1");
  80. var nodes = treeObj.getCheckedNodes(true);
  81. var arr = [];
  82. if(nodes.length>0){
  83. for(var i=0;i<nodes.length;i++){
  84. // if(nodes[i].isParent!=true){
  85. if(nodes[i].id!=corpId && nodes[i].name!='本部'){
  86. arr.push(nodes[i].id+","+nodes[i].name);
  87. }
  88. }
  89. }
  90. return arr;
  91. }
  92. function queDing2(){
  93. var treeObj = $.fn.zTree.getZTreeObj("myTree1");
  94. var nodes = treeObj.getCheckedNodes(true);
  95. var arr = [];
  96. if(nodes.length>0){
  97. for(var i=0;i<nodes.length;i++){
  98. arr.push(nodes[i].id+","+nodes[i].name);
  99. }
  100. }
  101. return arr;
  102. }
  103. function qingChu(){
  104. var treeObj = $.fn.zTree.getZTreeObj("myTree1");
  105. treeObj.checkAllNodes(false);
  106. }
  107. function quanXuan(){
  108. var treeObj = $.fn.zTree.getZTreeObj("myTree1");
  109. treeObj.checkAllNodes(true);
  110. }
  111. function nodeCheck(event,treeId,treeNode){
  112. if(treeNode.id!=corpId && treeNode.id!="benbu999"){
  113. var treeObj = $.fn.zTree.getZTreeObj("myTree1");
  114. var nodes = treeObj.getSelectedNodes();
  115. for (var i=0, l=nodes.length; i < l; i++) {
  116. var id = nodes[i].id;
  117. if(chekedId(selectedOrgId,id)){
  118. treeObj.checkNode(nodes[i], true, true);
  119. selectedOrgId.push(id);
  120. }else{
  121. treeObj.checkNode(nodes[i], false, false);
  122. for(var j=0; j<selectedOrgId.length; j++) {
  123. if(selectedOrgId[j] == id){
  124. selectedOrgId.splice(j, 1);
  125. }
  126. }
  127. }
  128. }
  129. }
  130. return false;
  131. }
  132. function chekedId(arr,str){
  133. if(arr.length==0){
  134. return true;
  135. }
  136. for(var i=0;i<arr.length;i++){
  137. if(arr[i]==str){
  138. return false;
  139. }
  140. }
  141. return true;
  142. }