| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- $(document).ready(function() {
- // 获取反映类别
- getReactionCategory();
- $("#reflectCategory").bind("input propertychange", function () {
- $(".layui-dropdown").hide();
- if ($("#reflectCategory").val() == "") {
- $(".reflectCategoryList-wrapper").hide();
- return;
- }
- var debounceGetSearchReactionCategory = debounce(getSearchReactionCategory, 500)
- $(".reflectCategoryList-wrapper").show();
- debounceGetSearchReactionCategory($("#reflectCategory").val())
- })
- $("#reflectCategoryList").on("click", "li", function () {
- $(".reflectCategoryList-wrapper").hide();
- $("#reflectCategory").val($(this).attr("indexName"));
- $("#keyId").val($(this).attr("index"));
- });
- })
- function getReactionCategory(pid = 38) {
- $.get(
- huayi.config.callcenter_url + "Dictionary/GetZTreeNew", {
- token: $.cookie("token"),
- pid: pid,
- },
- function (result) {
- result = $.parseJSON(result);
- var content = JSON.parse(result.data);
- layui.use("dropdown", function () {
- var dropdown = layui.dropdown;
- dropdown.render({
- elem: "#reflectCategory", //可绑定在任意元素中,此处以上述按钮为例
- data: content,
- id: "reflectCategory",
- //菜单被点击的事件
- click: function (obj) {
- $("#reflectCategory").val(obj.title)
- $("#keyId").val(obj.id)
- },
- });
-
- });
- }
- );
- }
- function getSearchReactionCategory(key) {
- $.get(
- huayi.config.callcenter_url + "Dictionary/GetKeyListNew", {
- token: $.cookie("token"),
- key: key,
- },
- function (result) {
- result = $.parseJSON(result);
- if (result.state.toLowerCase() === "success") {
- $("#reflectCategoryList").empty();
- var content = result.data;
- if (content.length > 0) {
- content.forEach(function (e, i) {
- $("<li index='" + e.id + "' indexName='" + e.name + "'>" + e.names +
- "</li>")
- .appendTo("#reflectCategoryList");
- });
- } else {
- $("<li index='' indexName=''>没有相关数据</li>").appendTo("#reflectCategoryList");
- }
- }
- }
- );
- }
- function debounce(fun, delay) {
- return function (args) {
- var that = this;
- var _args = args
- clearTimeout(fun.id)
- fun.id = setTimeout(function () {
- fun.call(that, _args)
- }, delay)
- }
- }
|