标签:show dev input query this compare 点击事件 htm turn
/** * 公共的设备型号的下拉 */ function pubModel(id){ var list=getEqumentList(); $(list).each(function(idx,ele){ $("#"+id).append(‘<option value="‘+this.id+‘">‘+this.text+‘</option>‘); }) } function getEqumentList() { var equmentList = []; $.ajaxSetup({async : false}); $.post("Filter_listEqument.action", { }, function(respData, status) { var resultList = respData.resultList; if (resultList != null) for (var i=0; i<resultList.length; ++i) equmentList.push(eval("("+resultList[i]+")")); }, "json"); $.ajaxSetup({async : true}); return equmentList; } /** * 公共的设备状态的下拉 */ function pubDevState(id){ var list=[{‘id‘:‘0‘,‘text‘:‘正常‘}, {‘id‘:‘1‘,‘text‘:‘停用‘}, {‘id‘:‘2‘,‘text‘:‘故障‘}] $(list).each(function(idx,ele){ $("#"+id).append(‘<option value="‘+this.id+‘">‘+this.text+‘</option>‘); }) } /** * 公共的抄表类型下拉 */ function pubReadType(id){ var list=[{id:0,text:‘数采‘},{id:1,text:‘手抄‘}]; $(list).each(function(idx,ele){ $("#"+id).append(‘<option value="‘+this.id+‘">‘+this.text+‘</option>‘); }) } /** * 公共的部门的下拉 */ ;(function($){ var me;//input输入框 var selectId=""; $.fn.buildButtomTree=function(data,_id){ selectId=!!_id?_id:""; if(_id){ this.val(depObj[_id]); this.attr("departmentval",depObj[_id]); } // var data=[ // {id: "101001", name: "计划财务部", pId: "001", code: "101001"}, // {id: "105001", name: "港吉", pId: "001", code: "105001"}, // {id: "001", name: "整个公司", pId: "000", code: "001"} // ] //构建html var str= ‘<div class="menuContent" style="display:none;overflow:auto">‘+ ‘<ul id="treeDemo" class="ztree" style="margin-top:0;width:177px"></ul>‘+ ‘</div>‘; this.parent().append(str); this.click(function(){ showMenu(); }) initTreeData(data,this); } var initTreeData=function(zNodes,el){ me=el; var setting = { view: { selectedMulti: false //是否允许多选 }, data: { simpleData: { enable: true } }, callback: { //zTree节点的点击事件 onClick: function(e, treeId, treeNode){ var zTree = $.fn.zTree.getZTreeObj("treeDemo"), nodes = zTree.getSelectedNodes(); var v = "",c=""; nodes.sort(function compare(a,b){return a.id-b.id;}); for (var i=0, l=nodes.length; i<l; i++) { v += nodes[i].name + ","; //v += nodes[i].name; //c += nodes[i].code + ","; c += nodes[i].code; } if (v.length > 0 ) v = v.substring(0, v.length-1); var cityObj =me; cityObj.val(v); cityObj.attr("departmentval", c); hideMenu(); } } }; //var $tree=el.next().find(".ztree"); $.fn.zTree.init($("#treeDemo"), setting, zNodes); var zTree = $.fn.zTree.getZTreeObj("treeDemo"); if(!!selectId){ var node=zTree.getNodeByParam("id",selectId); console.log(node); //设置选中 zTree.selectNode(node); } zTree.expandAll(true); } var hideMenu=function(){ me.next().fadeOut("fast"); $("body").unbind("mousedown", onBodyDown); } var onBodyDown=function(){ if (!(event.target.id == "menuBtn" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) { hideMenu(); } } var showMenu=function(){ me.next().slideDown("fast"); $("body").bind("mousedown", onBodyDown); } })(jQuery);
标签:show dev input query this compare 点击事件 htm turn
原文地址:https://www.cnblogs.com/pengfei25/p/9275734.html