|
|
|
;layui.define("form",function(e){"use strict";var i=layui.$,a=layui.form,n={config:{},index:layui.atree?layui.atree.index+1e4:0,set:function(e){var a=this;return a.config=i.extend({},a.config,e),a},on:function(e,i){return layui.onevent.call(this,l,e,i)}},r=function(){var e=this,i=e.config;return{getCheck:function(){return e.getCheck()},setCheck:function(i){return e.setCheck(i)},config:i}},l="tree",t="layui-tree",s="layui-tree-set",d="layui-tree-iconClick",c="layui-icon-addition",h="layui-icon-subtraction",o="layui-tree-entry",u="layui-tree-main",p="layui-tree-pack",y="layui-tree-spread",f="layui-tree-setLineShort",v="layui-tree-showLine",C="layui-tree-lineExtend",m=function(e){var a=this;a.index=++n.index,a.config=i.extend({},a.config,n.config,e),a.render()};m.prototype.config={data:[],showCheckbox:!1,showLine:!0,key:"id",checked:[],spread:[],accordion:!1,expandClick:!0,isJump:!1,renderContent:!1,showSearch:!1,draggable:!1,emptyText:"暂无数据"},m.prototype.render=function(){var e=this,n=e.config,r=i('<div class="layui-tree'+(n.showCheckbox?" layui-form":"")+(n.showLine?" layui-tree-line":"")+'"></div>');e.tree(r);var l=i(n.elem),s=l.next("."+t);return s[0]&&s.remove(),n.showSearch&&r.prepend('<input type="text" class="layui-input layui-tree-search" placeholder="请输入关键字进行过滤">'),e.elem=r,e.emptyText=i('<div class="layui-tree-emptyText">'+n.emptyText+"</div>"),l.html(e.elem),0==e.elem.find(".layui-tree-set").length?void e.elem.append(e.emptyText):(n.draggable&&e.drag(),n.showCheckbox&&a.render("checkbox"),e.elem.find(".layui-tree-set").each(function(){i(this).parent(".layui-tree-pack")[0]||i(this).addClass("layui-tree-setHide"),!i(this).next()[0]&&i(this).parents(".layui-tree-pack").eq(1).hasClass("layui-tree-lineExtend")&&i(this).addClass(f),i(this).next()[0]||i(this).parents(".layui-tree-set").eq(0).next()[0]||i(this).addClass(f)}),void e.events())},m.prototype.tree=function(e,a){var n=this,r=n.config,l=a||r.data;layui.each(l,function(a,l){function t(e){return 0!=r.spread.length&&i.inArray(e,r.spread)!=-1}function d(e){return 0!=r.checked.length&&i.inArray(e,r.checked)!=-1}var c=l.children&&l.children.length>0,h=i('<div class="layui-tree-pack" style="'+(t(l[r.key])?"display: block;":"")+'"></div>'),o=i(["<div "+(r.key?'data-key="'+(l[r.key]||"")+'"':"")+' class="layui-tree-set'+(t(l[r.key])?" layui-tree-spread":"")+(d(l[r.key])?" layui-tree-checkedFirst":"")+'">',"<div "+(r.draggable&&!l.fixed?'draggable="true"':"")+' class="layui-tree-entry">','<div class="layui-tree-main layui-inline">',function(){return r.showLine?c?'<span class="layui-tree-iconClick layui-tree-icon"><i class="layui-icon '+(t(l[r.key])?"layui-icon-subtraction":"layui-icon-addition")+'"></i></span>':'<span class="layui-tree-iconClick"><i class="layui-icon layui-icon-file"></i></span>':'<span class="layui-tree-iconClick"><i class="layui-tree-iconArrow '+(c?"":"hide")+'"></i></span>'}(),function(){return r.showCheckbox?'<input type="checkbox" name="layuiTreeCheck" lay-skin="primary" '+(l.disabled?"disabled":"")+">":""}(),function(){return r.isJump&&l.href?'<a href="'+l.href+'" target="_blank" class="layui-tree-txt">'+(l.label||"未命名")+"</a>":'<span class="layui-tree-txt">'+(l.label||"未命名")+"</span>"}(),"</div>",function(){return r.renderContent?['<div class="layui-btn-group layui-tree-btnGroup">','<button class="layui-btn layui-btn-primary layui-btn-sm" data-type="add"><i class="layui-icon layui-icon-add-1"></i></button>','<button class="layui-btn layui-btn-primary layui-btn-sm" data-type="edit"><i class="layui-icon layui-icon-edit"></i></button>','<button class="layui-btn layui-btn-primary layui-btn-sm" data-type="del"><i class="layui-icon layui-icon-delete"></i></button>',"</div>"].join(","):""}(),"</div></div>"].join(""));c&&(o.append(h),n.tree(h,l.children)),e.append(o),o.prev("."+s)[0]&&o.prev().children(".layui-tree-pack").addClass("layui-tree-showLine"),c||o.parent(".layui-tree-pack").addClass("layui-tree-lineExtend"),n.spread(o,l),r.showCheckbox&&n.checkClick(o,l),r.renderContent&&n.operate(o,l)})},m.prototype.s
|