/** layui-v2.5.1 MIT License By https://www.layui.com */ ;layui.define("form",function(a){"use strict";var e=layui.form,i=layui.$,t={config:{},index:layui.transfer?layui.transfer.index+1e4:0,set:function(a){var e=this;return e.config=i.extend({},e.config,a),e},on:function(a,e){return layui.onevent.call(this,l,a,e)}},n=function(){var a=this,e=a.config;return{getData:function(){return a.getData()},config:e}},l="transfer",r="layui-transfer",d="layui-transfer-topTitle",s="layui-transfer-search",c="layui-transfer-box",f="layui-transfer-data",u="layui-transfer-left",h="layui-transfer-right",o="layui-transfer-dataLeft",y="layui-transfer-dataRight",p="layui-transfer-btnLeft",v="layui-transfer-btnRight",k="layui-btn-disabled",b=function(a){var e=this;e.index=++t.index,e.config=i.extend({},e.config,t.config,a),e.render()};b.prototype.config={title:["列表一","列表二"],width:200,height:340,data:[],value:[],showSearch:!1,id:""},b.prototype.render=function(){var a=this,t=a.config,n="",l="",u=[];"function"==typeof t.parseData&&layui.each(t.data,function(a,e){t.data[a]=t.parseData(e)||e});var h=0,o="",y=0,p=0;layui.each(t.data,function(a,e){h=0,layui.each(t.value,function(a,i){if(e.value==i)return h=1,!0}),o='
  • ",0==h?(n+=o,y+=e.disabled?0:1):(l+=o,p+=e.disabled?0:1,u.push(a))});var v=['
    ','
    ','
    ',function(){return t.showSearch?'
    ",'
    ','','
    ','
    ','
    ',function(){return t.showSearch?'
    ","
    "].join(""),k=i(t.elem),b=k.next("."+r);b[0]&&b.remove(),a.elem=i(v),k.html(a.elem),a.layTop=a.elem.find("."+d),a.layBox=a.elem.find("."+c),a.laySearch=a.elem.find("."+s),a.layData=a.elem.find("."+f),a.layBox.css({width:t.width,height:t.height}),a.layData.css({height:function(){return t.height-a.layTop.outerHeight()-a.laySearch.outerHeight()-2}()}),a.event(),e.render("checkbox","LAY-Transfer-"+a.index)},b.prototype.event=function(){function a(a){var e=l.find(a).find(".layui-transfer-search"),t=e.children("input").val(),n=e.next();n.children("li").each(function(){i(this).data("title").indexOf(t)==-1?i(this).hide():i(this).show()})}var t=this,n=t.config,l=t.elem,r="",s="",c=l.find("."+u).find("."+d).find('input[name="layTranLeftCheck"]'),f=l.find("."+h).find("."+d).find('input[name="layTranRightCheck"]'),b=l.find("."+u).data("total"),g=l.find("."+h).data("total");l.on("click",'input[name="layTranLeftCheck"]+',function(){var a=i(this).prev(),n=a[0].checked,d=l.find("."+o).find('input[name="layTranLeftCheck"]'),s="layTranLeftCheckAll"==a.attr("lay-filter");if(!a[0].disabled){if(s)r="",0==b?a[0].checked=!1:(d.each(function(a,e){e.disabled||(e.checked=n,n?(r+=i(d[a]).data("index")+",",i(d[a]).parent("li").addClass("selected")):i(d[a]).parent("li").removeClass("selected"))}),n?l.find("."+v).removeClass(k):l.find("."+v).addClass(k));else{var f=1;n?(d.each(function(a,e){e.disabled||e.checked||(f=0)}),1==f&&(c[0].checked=n),r+=a.data("index")+",",a.parent("li").addClass("selected"),l.find("."+v).removeClass(k)):(c[0].checked&&(c[0].checked=!1),a.parent("li").removeClass("selected"),r=r.replace(a.data("index"),""),d.each(function(a,e){e.checked&&(f=0)}),1==f&&l.find("."+v).addClass(k))}e.render("checkbox","LAY-Transfer-"+t.index)}}),l.on("click",'input[name="layTranRightCheck"]+',function(){var a=i(this).prev(),n=a[0].checked,r=l.find("."+y).find('input[name="layTranRightCheck"]'),d="layTranRightCheckAll"===a.attr("lay-filter");if(!a[0].disabled){if(d)s="",0==g?a[0].checked=!1:(r.each(function(a,e){e.disabled||(e.checked=n,n?(s+=i(r[a]).data("index")+",",i(r[a]).parent("li").addClass("selected")):i(r[a]).parent("li").removeClass("selected"))}),n?l.find("."+p).removeClass(k):l.find("."+p).addClass(k)),e.render("checkbox","LAY-Transfer-"+t.index);else{var c=1;n?(r.each(function(a,e){e.disabled||e.checked||(c=0)}),1==c&&(f[0].checked=n),s+=a.data("index")+",",a.parent("li").addClass("selected"),l.find("."+p).removeClass(k)):(f[0].checked&&(f[0].checked=!1),a.parent("li").removeClass("selected"),s=s.replace(a.data("index"),""),r.each(function(a,e){e.checked&&(c=0)}),1==c&&l.find("."+p).addClass(k))}e.render("checkbox","LAY-Transfer-"+t.index)}}),l.on("click","."+v,function(){var d="";if(!i(this).hasClass(k)){l.find("."+o).find("li").each(function(){i(this).hasClass("selected")&&i(this).remove()});var s=l.find("."+h).data("arr"),u=0;layui.each(r.split(","),function(a,e){if(e){var i=n.data[e];d+='
  • ",s+=","+e,u++}}),l.find("."+y).append(d),a("."+h),c[0].checked=!1,f[0].checked=!1,i(this).addClass(k),r="",g+=u,b-=u,l.find("."+h).data("total",g),l.find("."+h).data("total",b),l.find("."+h).data("arr",s),e.render("checkbox","LAY-Transfer-"+t.index),n.onchange&&n.onchange(t.getData())}}),l.on("click","."+p,function(){var r="";if(!i(this).hasClass(k)){l.find("."+y).find("li").each(function(){i(this).hasClass("selected")&&i(this).remove()});var d=l.find("."+h).data("arr"),p=0;layui.each(s.split(","),function(a,e){if(e){var i=n.data[e];r+='
  • ",d=d.replace(e,"").replace(/(,)+/g,","),p++}}),l.find("."+o).append(r),a("."+u),c[0].checked=!1,f[0].checked=!1,i(this).addClass(k),s="",g-=p,b+=p,l.find("."+h).data("total",g),l.find("."+h).data("total",b),l.find("."+h).data("arr",d),e.render("checkbox","LAY-Transfer-"+t.index),n.onchange&&n.onchange(t.getData())}}),l.find(".layui-transfer-search").on("keyup","input",function(){var e=i(this).parent("div").parent("div");a(e)})},b.prototype.getData=function(){function a(a,e){return a-e}var e=this,i=e.config,t=e.elem.find("."+h).data("arr"),n=[];return layui.each(t.split(",").sort(a),function(a,e){e&&n.push(i.data[e])}),n},t.render=function(a){var e=new b(a);return n.call(e)},a(l,t)});