targetClassTree.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. var managerTree = "";
  2. var dialog = "";
  3. var manager = "";
  4. var class_id= "";
  5. var typeRootId = "";
  6. $(document).ready(function(){
  7. loadTree();
  8. });
  9. function loadTree(){
  10. $("#targetclassTree").empty();
  11. manager = targetclassTree("hrPerformanceTargetAction.do?task=targetclassTree","targetclassTree",clickEvent,onSuccess);
  12. }
  13. function targetclassTree(treeAction, treeId, clickEvent) {
  14. managerTree=$("#" + treeId).ligerTree({
  15. url : PROJECT_NAME + "/" + changePath(treeAction)+"&time="+new Date().getTime(),
  16. checkbox : false,
  17. folderCheckbox : false,
  18. single : true,
  19. childIcon : 'folder',
  20. idFieldName : 'id',
  21. parentIDFieldName : 'pid',
  22. slide : false,
  23. nodeWidth : 160,
  24. openFolderEven: false,
  25. attribute : [ 'id', 'url' ],
  26. onSelect : function(node) {
  27. class_id=node.data.id;
  28. $("#class_id").val(class_id);
  29. selectEvent(node);
  30. },
  31. onclick : function(node) {
  32. clickEvent(node);
  33. },
  34. onSuccess : function() {
  35. if (onSuccess)
  36. onSuccess();
  37. }
  38. });
  39. managerTree = $("#" + treeId).ligerGetTreeManager();
  40. return managerTree;
  41. }
  42. function selectEvent(node){
  43. // var id = node.data.id;
  44. var pid = node.data.pid;
  45. if(pid == '0'){
  46. $('#editClassTypeBtn').attr("disabled","disabled");
  47. $('#delClassTypeBtn').attr("disabled","disabled");
  48. }else{
  49. $('#editClassTypeBtn').attr("disabled","");
  50. $('#delClassTypeBtn').attr("disabled","");
  51. }
  52. searchByKword("tree");
  53. }
  54. function clickEvent(node){
  55. }
  56. function onSuccess(){
  57. $('#editClassTypeBtn').attr("disabled","disabled");
  58. $('#delClassTypeBtn').attr("disabled","disabled");
  59. }
  60. function addClassType(){
  61. dialog = $.ligerDialog.open({ height: 260,
  62. width:500,
  63. url: 'hrPerformanceTargetAction.do?task=toAddClass',
  64. allowClose:false,
  65. title:'新增指标分类',
  66. buttons : [ {
  67. text : '保存',
  68. onclick : function(item,dialog){
  69. dialog.frame.saveClass();
  70. // loadTree();
  71. }
  72. },{
  73. text : '关闭',
  74. onclick : addClassCloseOk
  75. }]
  76. });
  77. }
  78. function editClassType(){
  79. var class_id = $("#class_id").val();
  80. dialog = $.ligerDialog.open({ height: 260,
  81. width:500,
  82. url: 'hrPerformanceTargetAction.do?task=toEditClass&class_id='+class_id,
  83. allowClose:false,
  84. title:'编辑指标分类',
  85. buttons : [ {
  86. text : '保存',
  87. onclick : function(item,dialog){
  88. dialog.frame.editClassType();
  89. loadTree();
  90. }
  91. },{
  92. text : '关闭',
  93. onclick : addClassCloseOk
  94. }]
  95. });
  96. }
  97. function delClassType(){
  98. var param={'class_id':class_id};
  99. if (window.confirm("确定要删除吗?")){
  100. sendAjaxParam(param,"hrPerformanceTargetAction.do?task=delClassType",'json',delTypeProcess);
  101. }
  102. }
  103. function delTypeProcess(data){
  104. if(data.result>0){
  105. $.ligerDialog.success("删除成功");
  106. class_id="";
  107. $("#class_id").val("");
  108. }else if(data.result==0){
  109. $.ligerDialog.warn("请检查指标分类是否被指标信息引用");
  110. }else if(data.result==-1){
  111. $.ligerDialog.error("删除失败");
  112. }
  113. loadTree();
  114. }
  115. function addClassCloseOk(item,dialog){
  116. dialog.close();
  117. loadTree();
  118. }