layui.define("layer",function(x){var n=layui.$,y=layui.layer,T=function(e){this.c={elem:"",data:"",url:"",placeholder:"请选择:",disabledTips:"",success:function(){}},this.c=n.extend(this.c,e),this.init()};T.prototype={init:function(){this.data=this.c.url?this.getData(this.c.url):this.c.data,this.render()},getData:function(e){var t;return n.ajax({url:e,type:"get",dataType:"json",async:!1,success:function(a){t=a.data||y.msg("数据接口错误,请正确配置")},error:function(){y.msg("数据接口错误,请正确配置"),t=""}}),t},getChild:function(e,t){for(var a=[],i=0;i",i=0;i'+e[i].name+""}return a+="",a},setValue:function(e){var t=this,a=t.data,i=n(t.c.elem),r=i.parent();r.find(".pop").empty(),r.find(".show").html(t.c.placeholder),i.val("");for(var l=[],s=t.getChild(a,0),d=0;d0){r.find(".pop").empty();for(var h=0;h0){var u=t.createChild(m);r.find(".pop").append(u)}var w=l.map(function(p){return p.name}).join("/"),q=l.map(function(p){return p.name}).join("/");if(r.find(".show").html(w),i.val(q),typeof t.c.success=="function"){var b=l.map(function(p){return p.id}),Y=l.map(function(p){return p.name});t.c.success({data:Y,ids:b})}return l.map(function(p){return p.id})}return[]},showPopup:function(e,t){var a=this,i=a.getChild(e,t);if(i.length!=0){var r=a.createChild(i);n(a.c.elem).parent().find(".pop").append(r)}},scroll:function(){for(var e=this,t=e.c,a=t.elem,i=n(a).parent().find(".pop ul"),r=0;rd&&i.eq(r).scrollTop(s+i.eq(r).scrollTop()-d+c+3),s<0&&i.eq(r).scrollTop(s+i.eq(r).scrollTop()-5)}}},render:function(){var e=this,t=e.c,a=t.elem,i='
',r=''+t.placeholder+"",l='
';if(n(a).wrap(i),n(a).after(r+l),e.showPopup(e.data,0),n(a).val()!=""){var s=n(a).val().split("/"),d=s.join("/");n(a).parent().find(".show").html(d);for(var c=e.setValue(s),o=0;o/");if(n(a).val(w),n(a).parent().find(".show").html(q),typeof t.success=="function"){var b={data:f,ids:m};t.success(b)}}layui.stope(v)}),n(a).parent().find(".show").on("click",function(v){n(a).parent().find(".pop").show(),e.scroll(),layui.stope(v)}),n(document).on("click",function(){n(a).parent().find(".pop").hide()})}},x("selectY2",function(e){return new T(e)})}).link(layui.cache.base+"selectY/selectY.css?v="+new Date().getTime());