Nenhuma Descrição

reflectCategory.js 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. $(document).ready(function() {
  2. // 获取反映类别
  3. getReactionCategory();
  4. $("#reflectCategory").bind("input propertychange", function () {
  5. $(".layui-dropdown").hide();
  6. if ($("#reflectCategory").val() == "") {
  7. $(".reflectCategoryList-wrapper").hide();
  8. return;
  9. }
  10. var debounceGetSearchReactionCategory = debounce(getSearchReactionCategory, 500)
  11. $(".reflectCategoryList-wrapper").show();
  12. debounceGetSearchReactionCategory($("#reflectCategory").val())
  13. })
  14. $("#reflectCategoryList").on("click", "li", function () {
  15. $(".reflectCategoryList-wrapper").hide();
  16. $("#reflectCategory").val($(this).attr("indexName"));
  17. $("#keyId").val($(this).attr("index"));
  18. });
  19. })
  20. function getReactionCategory(pid = 38) {
  21. $.get(
  22. huayi.config.callcenter_url + "Dictionary/GetZTreeNew", {
  23. token: $.cookie("token"),
  24. pid: pid,
  25. },
  26. function (result) {
  27. result = $.parseJSON(result);
  28. var content = JSON.parse(result.data);
  29. layui.use("dropdown", function () {
  30. var dropdown = layui.dropdown;
  31. dropdown.render({
  32. elem: "#reflectCategory", //可绑定在任意元素中,此处以上述按钮为例
  33. data: content,
  34. id: "reflectCategory",
  35. //菜单被点击的事件
  36. click: function (obj) {
  37. $("#reflectCategory").val(obj.title)
  38. $("#keyId").val(obj.id)
  39. },
  40. });
  41. });
  42. }
  43. );
  44. }
  45. function getSearchReactionCategory(key) {
  46. $.get(
  47. huayi.config.callcenter_url + "Dictionary/GetKeyListNew", {
  48. token: $.cookie("token"),
  49. key: key,
  50. },
  51. function (result) {
  52. result = $.parseJSON(result);
  53. if (result.state.toLowerCase() === "success") {
  54. $("#reflectCategoryList").empty();
  55. var content = result.data;
  56. if (content.length > 0) {
  57. content.forEach(function (e, i) {
  58. $("<li index='" + e.id + "' indexName='" + e.name + "'>" + e.names +
  59. "</li>")
  60. .appendTo("#reflectCategoryList");
  61. });
  62. } else {
  63. $("<li index='' indexName=''>没有相关数据</li>").appendTo("#reflectCategoryList");
  64. }
  65. }
  66. }
  67. );
  68. }
  69. function debounce(fun, delay) {
  70. return function (args) {
  71. var that = this;
  72. var _args = args
  73. clearTimeout(fun.id)
  74. fun.id = setTimeout(function () {
  75. fun.call(that, _args)
  76. }, delay)
  77. }
  78. }