Нет описания

department.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. $(document).ready(function() {
  2. tree();
  3. })
  4. $(".inps").focus(function () {
  5. $(".xlAdd").css("display", "block");
  6. });
  7. $(".xl").click(function () {
  8. if ($(".xlAdd").css("display") == "block") {
  9. $(".xlAdd").css("display", "none");
  10. } else {
  11. $(".xlAdd").css("display", "block");
  12. }
  13. });
  14. $(".addTree").mouseleave(function () {
  15. $(this).css("display", "none");
  16. });
  17. //清除
  18. $(".Cleans ").click(function () {
  19. $(".inps").val("");
  20. $("#PID").val("");
  21. });
  22. function tree() {
  23. $.get(
  24. huayi.config.callcenter_url + "Department/GetDeptList",
  25. {
  26. token: $.cookie("token"),
  27. // "pid": pid
  28. },
  29. function (result) {
  30. result = $.parseJSON(result);
  31. $.fn.zTree.init($("#addTreeDemo"), setting1, result.data); //实例化树形图
  32. }
  33. );
  34. }
  35. var setting1 = {
  36. data: {
  37. key: {
  38. name: "F_DeptName",
  39. },
  40. simpleData: {
  41. enable: true,
  42. idKey: "F_DeptId",
  43. pIdKey: "F_PartentId",
  44. rootPId: 0,
  45. },
  46. },
  47. callback: {
  48. onClick: zTreeOnClick,
  49. },
  50. };
  51. function zTreeOnClick(event, treeId, treeNode) {
  52. if (treeNode.level >= 1) {
  53. $(".inps").val(treeNode.F_DeptName);
  54. $("#PID").val(treeNode.F_DeptId);
  55. $(".Cleans").show();
  56. }
  57. }
  58. function Close() {
  59. $(".lyxz").removeClass("cx");
  60. if ($("audio").length > 0) {
  61. $("audio")[0].pause();
  62. }
  63. }
  64. function darptSearch() {
  65. $(".xlAdd").css("display", "none");
  66. $(".selDpart1").css("display", "block");
  67. depart();
  68. }
  69. $("#sponsor").on("click", "li", function () {
  70. $(".selDpart1").css("display", "none");
  71. $(".inps").val($(this).html());
  72. $("#PID").val($(this).attr("index"));
  73. $(".Cleans").show();
  74. });
  75. ///部门
  76. function depart() {
  77. $("#sponsor").empty();
  78. $.getJSON(
  79. huayi.config.callcenter_url + "Department/GetDeptListByDept",
  80. {
  81. token: $.cookie("token"),
  82. dept: $(".inps").val(),
  83. },
  84. function (data) {
  85. if (data.state.toLowerCase() == "success") {
  86. var content = data.data;
  87. $(content).each(function (i, n) {
  88. $(
  89. "<li index='" +
  90. n.F_DeptId +
  91. "'>" +
  92. n.F_DeptName +
  93. "</li>"
  94. ).appendTo("#sponsor");
  95. });
  96. }
  97. }
  98. );
  99. }