var loadComplete = 0; var setTree = function (obj, nwidth, nheight) { $('' + obj + '').attr("materialcode", ""); var html = '
'; $(''+obj+'').after(html); LoadArticleTree(obj); $('' + obj + '').bind('focus', function () { $('#showArticle').show(); }); var id = $('' + obj + '').attr("id") || ""; //隐藏物料分类弹框 document.body.addEventListener("click", function (even) { if (even.target.id == id&&loadComplete == 0) { layer.msg('物料树加载中,请稍后再试....', { icon: 6 }); return; } if (!even.target) return; if (even.target.id != id && even.target.tagName != 'I') { $("#showArticle").hide(); } }) } var LoadArticleTree = function (obj) { var treeindex; $.ajax({ type: "POST", url: "/Article/GetTreeJson", dataType: "json", async: true, beforeSend: function () { //treeindex = parent.layer.load(1, '#000'); }, complete: function () { loadComplete = 1; //parent.layer.close(treeindex); }, success: function (result) { var treedata = [result]; $('#showArticle').treeview({ data: treedata, // 数据源 backColor: 'white', //列表树所有节点背景颜色 showCheckbox: false, //是否显示复选框 highlightSelected: false, //是否高亮选中 nodeIcon: 'glyphicon glyphicon-globe', emptyIcon: '', //没有子节点的节点图标 multiSelect: true, //多选 onNodeChecked: function (event, data) { }, onNodeSelected: function (event, data) { $('#showArticle').hide(); $('' + obj + '').val(data.text); $('' + obj + '').attr('materialcode', data.code); } }); }, error: function () { alert("物料树形结构加载失败!"); } }); }