indexAuthor.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. function indexAutorTree(treeAction, treeId, clickEvent, onSuccess, onAppend) {
  2. var manager = "";
  3. $("#" + treeId).ligerTree({
  4. url : getProjectName() + "/" + changePath(treeAction),
  5. checkbox : true,
  6. folderCheckbox : false,
  7. single : true,
  8. childIcon : 'folder',
  9. idFieldName : 'id',
  10. parentIDFieldName : 'pid',
  11. openFolderEven : false,
  12. slide : false,
  13. nodeWidth : 120,
  14. attribute : [ 'id', 'url', 'type' ],
  15. onSelect : function(node) {
  16. var id = node.data.id;
  17. if (!node.data.checkbox) {
  18. $("input[name='author']").each(function() {
  19. $(this).attr("checked", false);
  20. });
  21. $("input[name='unit']").val(id);
  22. }
  23. },
  24. onCheck : function(node) {
  25. clickEvent(node);
  26. },
  27. onAppend : function(parentNode, newdata) {
  28. if (onAppend)
  29. onAppend(parentNode, newdata);
  30. },
  31. onSuccess : function() {
  32. if (onSuccess)
  33. onSuccess();
  34. }
  35. });
  36. manager = $("#" + treeId).ligerGetTreeManager();
  37. return manager;
  38. }
  39. function toSave(){
  40. var params=$("input[name='checkedRoleId']").val();
  41. if(params==""){
  42. addError('请选择用户');
  43. return;
  44. }
  45. $("input[name='indexAuthor']:checked").each(function(){
  46. var id=$(this).attr("id");
  47. params+=",";
  48. params+=id;
  49. });
  50. var param={'param':params};
  51. sendAjaxParam(param, "saveIndexAuthor.do", 'json', displayAjaxMsg);
  52. }
  53. function clickIndexRoleEvent(node){
  54. var id = node.data.id;
  55. var mc=managerTree.getChecked();
  56. if(mc!=null&&""!=mc){
  57. $("input[name='checkedRoleId']").val(id);
  58. }else{
  59. $("input[name='checkedRoleId']").val("");
  60. }
  61. var rs=$("input[name='checkedRoleId']").val();
  62. var type = node.data.type;
  63. var param = {'id':id};
  64. sendAjaxParam(param,'findIndexAuthor.do','json',processs);
  65. }
  66. function processs(data){
  67. $("input[name='indexAuthor']:checked").each(function(){
  68. $(this).attr("checked",false);
  69. });
  70. if(data.length==0){
  71. return;
  72. }
  73. for(var i=0;i<data.length;i++){
  74. var p = data[i]["modelId"];
  75. $("#"+p).attr("checked", true);
  76. }
  77. }