6 lines
41 KiB
JavaScript
6 lines
41 KiB
JavaScript
/**
|
||
码云地址:https://gitee.com/beijiyi/tree_table_treegrid_based_on_layui
|
||
在线demo:http://beijiyi.com/
|
||
*/
|
||
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};layui.config({}).extend({}).define(["laytpl","laypage","layer","form"],function(e){var t=layui.$,i=layui.laytpl,a=layui.laypage,n=layui.layer,o=layui.form,r=layui.hint(),l=layui.device(),c={config:{indexName:"lay_table_index",cols:{isCheckName:"lay_is_checked",isRadio:"lay_is_radio",isOpen:"lay_is_open",isShow:"lay_is_show",level:"lay_level",children:"children",isRowCheck:"lay_is_row_check",cheDisabled:"lay_che_disabled",radDisabled:"lay_rad_disabled",iconOpen:"lay_icon_open",iconClose:"lay_icon_close",icon:"lay_icon"},initWidth:{checkbox:48,space:15,numbers:40,radio:48}},cache:{tableId:{data:{list:[],map:{},treeList:[],upIds:[]}},cla:{claIds:{tableId:!0},claObjs:{tableId:{}}},selectcode:{demokey:[{key:{value:""}}]}},index:layui.table?layui.table.index+1e4:0,set:function(e){var i=this;return i.config=t.extend({},i.config,e),i},on:function(e,t){return layui.onevent.call(this,s,e,t)},getClass:function(e){return c.cache.cla.claObjs[e]},pushClass:function(e,t){c.cache.cla.claObjs[e]=t},isCalss:function(e){return(this.cache.cla.claIds||{}).hasOwnProperty(e)||!1},isClassYes:function(e){return(this.cache.cla.claIds||{})[e]||!1},pushClassIds:function(e,t){this.cache.cla.claIds[e]=t},setObj:function(e,t,i){this.obj[e]||(this.obj[e]={}),this.obj[e][t]=i},getObj:function(e,t){return this.obj[e]?this.obj[e][t]:null},getDataList:function(e){return c.cache[e]?c.cache[e].data.list:[]},setDataList:function(e,t){c.cache[e]||(c.cache[e]={}),c.cache[e].data||(c.cache[e].data={}),c.cache[e].data.list||(c.cache[e].data.list=[]),c.cache[e].data.list=t},getDataMap:function(e){return c.cache[e]?c.cache[e].data.map:{}},setDataMap:function(e,t){c.cache[e]||(c.cache[e]={}),c.cache[e].data||(c.cache[e].data={}),c.cache[e].data.map||(c.cache[e].data.map={}),c.cache[e].data.map=t},getDataTreeList:function(e){return c.cache[e]?c.cache[e].data.treeList:[]},setDataTreeList:function(e,t){c.cache[e]||(c.cache[e]={}),c.cache[e].data||(c.cache[e].data={}),c.cache[e].data.treeList||(c.cache[e].data.treeList={}),c.cache[e].data.treeList=t},getDataRootList:function(e){return c.cache[e]?c.cache[e].data.upIds||[]:[]},setDataRootList:function(e,t){c.cache[e]||(c.cache[e]={}),c.cache[e].data||(c.cache[e].data={}),c.cache[e].data.upIds||(c.cache[e].data.upIds=[]),c.cache[e].data.upIds=t},init:function(e,i){i=i||{};var a=this,n=t(e?'table[lay-filter="'+e+'"]':f+"[lay-data]"),o="Table element property lay-data configuration item has a syntax error: ";return n.each(function(){var a=t(this),n=a.attr("lay-data");try{n=new Function("return "+n)()}catch(e){r.error(o+n)}var l=[],d=t.extend({elem:this,cols:[],data:[],skin:a.attr("lay-skin"),size:a.attr("lay-size"),even:"string"==typeof a.attr("lay-even")},c.config,i,n);e&&a.hide(),a.find("thead>tr").each(function(e){d.cols[e]=[],t(this).children().each(function(i){var a=t(this),n=a.attr("lay-data");try{n=new Function("return "+n)()}catch(e){return r.error(o+n)}var c=t.extend({title:a.text(),colspan:a.attr("colspan")||0,rowspan:a.attr("rowspan")||0},n);c.colspan<2&&l.push(c),d.cols[e].push(c)})}),a.find("tbody>tr").each(function(e){var i=t(this),a={};i.children("td").each(function(e,i){var n=t(this),o=n.data("field");if(o)return a[o]=n.html()}),layui.each(l,function(e,t){var n=i.children("td").eq(e);a[t.field]=n.html()}),d.data[e]=a}),c.render(d)}),a},render:function(e){c.pushClassIds(e.id);var t=new k(e);return d.call(t)},ready:function(e,t){function i(){if(e){var o=c.getClass(e);if(o&&o.hasOwnProperty("layBody"))t(o),a=!0;else{(new Date).getTime()-n.getTime()<=1e4&&!a&&setTimeout(i,50)}}}var a=!1,n=new Date;e&&t&&setTimeout(i,50)},checkStatus:function(e){var t=0,i=0,a=[],n=c.getDataList(e)||[];return layui.each(n,function(e,n){if(n.constructor===Array)return void i++;n[c.config.cols.isCheckName]&&(t++,a.push(c.clearCacheKey(n)))}),{data:a,isAll:!!n.length&&t===n.length-i}},setCheckStatus:function(e,t,i){var a=c.getClass(e),n=c.getDataList(e)||[];a.layBody.find('input[name="'+g+'"]');if(t&&i){i.split(",").forEach(function(e){var i=null;if(n.forEach(function(a){if(a[t]+""==e+"")return void(i=a)}),i){var o=i[c.config.indexName];a.layBody.find('input[name="'+g+'"][value="'+o+'"]').prop("checked",!0),a.setCheckData(o,!0)}}),a.syncCheckAll(),a.renderForm("checkbox")}return null},radioStatus:function(e){var t=c.getClass(e),i=null,a=c.getDataList(e)||[],n=t.layBody.find("input[name='"+y+"']:checked").val();return n=parseInt(n),a.forEach(function(e){e[c.config.indexName]==n&&(i=e)}),c.clearCacheKey(i)},setRadioStatus:function(e,t,i){var a=c.getClass(e),n=null,r=c.getDataList(e)||[];if(t&&i&&(r.forEach(function(e){if(e[t]+""==i+"")return void(n=e)}),n)){var l=n[c.config.indexName];a.layBody.find("input:radio[name='"+y+"'][value='"+l+"']").prop("checked",!0),o.render("radio")}return n},clearCacheKey:function(e){return e=t.extend({},e),delete e[c.config.cols.isCheckName],delete e[c.config.indexName],e},query:function(e,i){var a=c.getClass(e);a.renderTdCss(),a.config.data&&a.config.data.constructor===Array&&delete a.config.data,a.config=t.extend({},a.config,i),a.pullData(a.page,a.loading())},reload:function(e,i){var a=d.config[e];return i=i||{},a?(i.data&&i.data.constructor===Array&&delete a.data,c.render(t.extend(!0,{},a,i))):r.error("The ID option was not found in the table instance")},addRow:function(e,i,a){var n=c.getClass(e),o=n.config,r=[],l=c.getDataTreeList(e),d=c.getDataList(e)||[];if(n.resetData(a),d.splice(i,0,a),c.kit.restNumbers(d),c.setDataMap(e,n.resetDataMap(d)),o.isTree){var r=n.treeFindUpData(a);r?(r.children||(r.children=[]),r.children.push(a),a[c.config.cols.level]=r[c.config.cols.level]+1):(a[c.config.cols.level]=1,l.push(a))}var s=n.renderTr(a,a[c.config.indexName]),f='<tr data-index="'+a[c.config.indexName]+'"'+n.renderTrUpids(a)+">"+s.join("")+"</tr>";if(0==i){var u=n.layBody.find("table tbody");t(u).prepend(f),n.layBody.find(".layui-none").remove()}else{var h=n.layBody.find("[data-index="+(i-1)+"]");t(h).after(f)}n.renderForm(),o.isPage&&n.renderPage(n.config.page.count+1),n.restNumbers(),n.events(),o.isTree&&(n.treeNodeOpen(r,!0),n.renderTreeConvertShowName(r))},delRow:function(e,t){var i=c.getClass(e),a=i.config,n=c.getDataList(e),o=[],r={},l=[],d=[];if(i&&t){c.kit.isArray(t)?l=t:l[0]=t,l.forEach(function(e){var t=i.treeFindUpData(e);t&&d.push(t)}),o=a.isTree?c.treeFindSonList(i.config.id,l):l,o.forEach(function(e){var t=e[c.config.indexName];r[t]=t,i.layBody.find('tr[data-index="'+t+'"]').remove()}),i.restNumbers();for(var s=[],f=0,u=n.length;f<u;f++){var h=!0;o.forEach(function(e){e[c.config.indexName]===n[f][c.config.indexName]&&(h=!1)}),h&&s.push(n[f])}c.kit.restNumbers(s),c.setDataList(e,s),c.setDataMap(e,i.resetDataMap(s)),c.setDataTreeList(e,i.resetDataTreeList(s,c.getDataRootList(e))),d.forEach(function(e){i.renderTreeConvertShowName(e)}),a.isPage&&i.renderPage(i.config.page.count-Object.keys(r).length),i.events()}},updateRow:function(e,i){var a=c.getClass(e);if(a&&i){var n=i[a.config.idField],o=c.getDataMap(e),r=o[n];if(r){t.extend(r,i);var l=r[c.config.indexName],d=a.renderTr(r,l),s=a.layBody.find("tr[data-index="+l+"]");t(s).html(d)}}},treeNodeOpen:function(e,t,i){var a=c.getClass(e);a&&t&&a.treeNodeOpen(t,i)},treeOpenAll:function(e,t){var i=c.getClass(e);if(i){void 0===t&&(t=!0);var a=c.getDataList(e);a&&a.forEach(function(e){i.treeNodeOpen(e,t)})}},treeFindSonList:function(e,t){var i=c.getClass(e);if(!i||!t)return[];var a=[],n=[],o={};return c.kit.isArray(t)?a=t:a[0]=t,a.forEach(function(e){if(e.children.length>0){i.treeFindSonData(e).forEach(function(e){o[e[c.config.indexName]]||(n.push(e),o[e[c.config.indexName]]=e[c.config.indexName])})}n.push(e),o[e[c.config.indexName]]=e[c.config.indexName]}),n},treeFindUpDatas:function(e,t){var i=c.getClass(e);return i&&t?i.treeFindUpDatas(t):[]},treeFindUpData:function(e,t){var i=c.getClass(e);return i&&t?i.treeFindUpData(t):[]},treeFindSonIds:function(e,t){var i=[];return c.treeFindSonList(e,t).forEach(function(e){i.push([c.config.indexName])}),i},treeFindSonIdFields:function(e,t){var i=[],a=c.getClass(e);return c.treeFindSonList(e,t).forEach(function(e){i.push(e[a.config.idField])}),i},treeIconRender:function(e,t){var i=c.getClass(e);return i&&t?i.treeIconRender(t,!1):[]},treeFindRowCheck:function(e){var t=[],i=c.getDataList(e);return i&&i.forEach(function(e){e[c.config.cols.isRowCheck]&&t.push(e)}),t},treeRowCheck:function(e,t){var i=c.getClass(e);if(i){var a=c.getDataList(i.config.id),n=a[t];"tree"==i.config.model&&(a.forEach(function(e){e[c.config.cols.isRowCheck]=!1}),n[c.config.cols.isRowCheck]=!0,i.layBody.find("tr").css("background-color",""),i.getTr(t).css("background-color","#ccc")),"function"==typeof i.config.onClickRow&&i.config.onClickRow(t,n)}},kit:{isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},isNumber:function(e){var t=/^\d+(\.\d+)?$/,i=/^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/;return!(!t.test(e)&&!i.test(e))},restNumbers:function(e){if(e){var t=0;e.forEach(function(e){e[c.config.indexName]=t,t++})}}}},d=function e(){var t=this,i=t.config,a=i.id;return a&&(e.config[a]=i),{reload:function(e){t.reload.call(t,e)},config:i}},s="treeGrid",f=".layui-table",u="layui-none",h="layui-table-view",p="layui-table-edit",y="table_radio_",g="layTableCheckbox",v=function(e){return e=e||{},['<table cellspacing="0" cellpadding="0" border="0" class="layui-table" ','{{# if(d.data.skin){ }}lay-skin="{{d.data.skin}}"{{# } }} {{# if(d.data.size){ }}lay-size="{{d.data.size}}"{{# } }} {{# if(d.data.even){ }}lay-even{{# } }}>',"<thead>","{{# layui.each(d.data.cols, function(i1, item1){ }}","<tr>","{{# layui.each(item1, function(i2, item2){ }}",'{{# if(item2.fixed && item2.fixed !== "right"){ left = true; } }}','{{# if(item2.fixed === "right"){ right = true; } }}',function(){return e.fixed&&"right"!==e.fixed?'{{# if(item2.fixed && item2.fixed !== "right"){ }}':"right"===e.fixed?'{{# if(item2.fixed === "right"){ }}':""}(),'<th data-field="{{ item2.field||i2 }}" {{# if(item2.minWidth){ }}data-minwidth="{{item2.minWidth}}"{{# } }} {{#if(item2.colspan){}} colspan="{{item2.colspan}}"{{#} if(item2.rowspan){}} rowspan="{{item2.rowspan}}"{{#}}} {{# if(item2.unresize){ }}data-unresize="true"{{# } }}>','<div class="layui-table-cell laytable-cell-',"{{# if(item2.colspan > 1){ }}","group","{{# } else { }}","{{d.index}}-{{item2.field || i2}}",'{{# if(item2.type !== "normal"){ }}'," laytable-cell-{{ item2.type }}","{{# } }}","{{# } }}",'" {{#if(item2.align){}}align="{{item2.align}}"{{#}}}>','{{# if(item2.type === "checkbox"){ }}','<input type="checkbox" name="layTableCheckbox" lay-skin="primary" lay-filter="layTableAllChoose">',"{{# } else { }}",'<span>{{item2.title||""}}</span>',"{{# if(!(item2.colspan > 1) && item2.sort){ }}",'<span class="layui-table-sort layui-inline"><i class="layui-edge layui-table-sort-asc"></i><i class="layui-edge layui-table-sort-desc"></i></span>',"{{# } }}","{{# } }}","</div>","</th>",e.fixed?"{{# }; }}":"","{{# }); }}","</tr>","{{# }); }}","</thead>","</table>"].join("")},m=['<table cellspacing="0" cellpadding="0" border="0" class="layui-table" ','{{# if(d.data.skin){ }}lay-skin="{{d.data.skin}}"{{# } }} {{# if(d.data.size){ }}lay-size="{{d.data.size}}"{{# } }} {{# if(d.data.even){ }}lay-even{{# } }}>',"<tbody></tbody>","</table>"].join(""),b=['<div class="layui-form layui-border-box {{d.VIEW_CLASS}} {{d.data.id}}" lay-filter="LAY-table-{{d.index}}" style="{{# if(d.data.width){ }}width:{{d.data.width}}px;{{# } }} {{# if(d.data.height){ }}height:{{d.data.height}}px;{{# } }}">',"{{# if(d.data.toolbar){ }}",'<div class="layui-table-tool"></div>',"{{# } }}",'<div class="layui-table-box">',"{{# var left, right; }}",'<div class="layui-table-header">',v(),"</div>",'<div class="layui-table-filter">',void 0,"</div>",'<div class="layui-table-body layui-table-main">',m,"</div>","{{# if(left){ }}",'<div class="layui-table-fixed layui-table-fixed-l">','<div class="layui-table-header">',v({fixed:!0}),"</div>",'<div class="layui-table-body">',m,"</div>","</div>","{{# }; }}","{{# if(right){ }}",'<div class="layui-table-fixed layui-table-fixed-r">','<div class="layui-table-header">',v({fixed:"right"}),'<div class="layui-table-mend"></div>',"</div>",'<div class="layui-table-body">',m,"</div>","</div>","{{# }; }}","</div>","{{# if(d.data.isPage){ }}",'<div class="layui-table-page">','<div id="layui-table-page{{d.index}}"></div>',"</div>","{{# } }}","</div>"].join(""),x=t(window),D=t(document),k=function(e){var i=this;i.index=++c.index,i.config=t.extend({},i.config,c.config,e),i.configFirst=t.extend({},i.config,c.config,e),i.render(),c.pushClass(e.id,i)};k.prototype.config={limit:10,loading:!0,cellMinWidth:60,heightRemove:[],text:{none:"无数据"},isFilter:!1,method:"get",radDisabledNum:0,cheDisabledNum:0,branch:["",""],leaf:"",iconOpen:!1,isOpenDefault:!1,parseData:null,onClickRow:null,onDblClickRow:null,onBeforeCheck:null,onCheck:null,onRadio:null,isTree:!0,isPage:!1,height:"100%",model:"",editModel:"click"},k.prototype.configFirst={},k.prototype.render=function(){var e=this,a=e.config;if(a.elem=t(a.elem),a.where=a.where||{},a.id=a.id||a.elem.attr("id"),e.test(),a.request=t.extend({pageName:"page",limitName:"limit"},a.request),a.response=t.extend({statusName:"code",statusCode:0,msgName:"msg",dataName:"data",countName:"count"},a.response),"object"===_typeof(a.page)&&(a.limit=a.page.limit||a.limit,a.limits=a.page.limits||a.limits,e.page=a.page.curr=a.page.curr||1,delete a.page.elem,delete a.page.jump),!a.elem[0])return e;e.columnWidthInit();var n=a.elem,o=n.next("."+h),r=e.elem=t(i(b).render({VIEW_CLASS:h,data:a,index:e.index}));if(a.index=e.index,o[0]&&o.remove(),n.after(r),e.renderTdCss(),e.layHeader=r.find(".layui-table-header"),e.layMain=r.find(".layui-table-main"),e.layBody=r.find(".layui-table-body"),e.layFixed=r.find(".layui-table-fixed"),e.layFixLeft=r.find(".layui-table-fixed-l"),e.layFixRight=r.find(".layui-table-fixed-r"),e.layTool=r.find(".layui-table-tool"),e.layPage=r.find(".layui-table-page"),e.layFilter=r.find(".layui-table-filter"),e.layTool.html(i(t(a.toolbar).html()||"").render(a)),a.height&&(e.tableHeight(),e.resizeHeight(),e.renderCss()),a.cols.length>1){var l=e.layFixed.find(".layui-table-header").find("th");l.height(e.layHeader.height()-1-parseFloat(l.css("padding-top"))-parseFloat(l.css("padding-bottom")))}a.isFilter&&e.layFilter.html(e.renderFilter()),e.pullData(e.page,e.loading()),e.test()},k.prototype.initOpts=function(e){var t=this,i=t.config;e.checkbox&&(e.type="checkbox"),e.space&&(e.type="space"),e.type||(e.type="normal"),"normal"!==e.type&&(e.unresize=!0,e.width=e.width||c.config.initWidth[e.type]),i.isFilter&&0!=e.isFilter&&(e.isFilter=!0)},k.prototype.getParentDivHeight=function(e){return t("#"+e).parent().height()},k.prototype.getCols=function(e){var t=this,i={},a=t.config.cols[0],n=!1;/^[0-9]+.?[0-9]*$/.test(e)&&(n=!0);for(var o in a)if(n){if(o==parseInt(e))return a[o]}else if(e==a[o].field)return a[o];return i},k.prototype.getTr=function(e){return this.layBody.find('tr[data-index="'+e+'"]')},k.prototype.getTd=function(e,i){var a=this,n=a.getTr(e);return t(n).find('td[data-field="'+i+'"]')},k.prototype.reload=function(e){var i=this;i.config.data&&i.config.data.constructor===Array&&delete i.config.data,i.config=t.extend({},i.config,e),i.configFirst=t.extend({},i.config,e),i.render()},k.prototype.page=1,k.prototype.restNumbers=function(){var e=this,i=(e.config,e.layBody.find("table tbody tr")),a=0;i.each(function(e){t(this).attr("data-index",a),t(this).find(".laytable-cell-numbers p").text(a+1),t(this).data("index",a),a++})},k.prototype.resetData=function(e){var t=this,i=t.config;i.isTree&&(e.hasOwnProperty(c.config.cols.isOpen)||(e[c.config.cols.isOpen]=i.isOpenDefault),e.hasOwnProperty(c.config.cols.isShow)||(e[c.config.cols.isShow]=!!i.isOpenDefault)),e.hasOwnProperty(c.config.cols.cheDisabled)||(e[c.config.cols.cheDisabled]=!1),e[c.config.cols.cheDisabled]&&i.cheDisabledNum++,e[c.config.cols.radDisabled]&&i.radDisabledNum++,e.children=[]},k.prototype.resetDataMap=function(e){var t=this,i=t.config,a=i.idField,n={};return e&&e.forEach(function(e){n[e[a]]=e}),n},k.prototype.resetDataresetRoot=!0,k.prototype.resetDataRoot=function(e){var t=this,i=t.config,a=(i.treeId,i.treeUpId),n=c.getDataMap(t.config.id),o=c.cache[i.id].data.upIds||[],r={};c.cache[i.id].data.upIds=[],o=c.cache[i.id].data.upIds;for(var l=0;l<e.length;l++){var d=e[l];if(!n[d[a]]){if(!r[d[a]]){var s=!0;o.forEach(function(e){e===d[a]&&(s=!1)}),s&&o.push(d[a])}r[d[a]]=d[a]}}return o},k.prototype.resetDataTreeList=function(e,t){var i=this,a=i.config,n=a.treeId,o=a.treeUpId,r=[],l=function t(i){for(var a=[],r=0;r<e.length;r++){var l=e[r];l[o]===i&&(l.children=t(l[n]),a.push(l))}return a};return t.forEach(function(e){var t=l(e);t&&t.forEach(function(e){r.push(e)})}),r},k.prototype.resetDataTableList=function(e){var t=this,i=t.config,a=(i.treeId,i.treeUpId,[]);return function e(t,i){for(var n=0;n<t.length;n++){var o=t[n];o[c.config.cols.level]=i,a.push(o),o.children&&o.children.length>0&&e(o.children,1+i)}}(e,1),a.forEach(function(e){var i=t.treeFindUpData(e);!i||i[c.config.cols.isOpen]&&i[c.config.cols.isShow]?e[c.config.cols.isShow]=!0:e[c.config.cols.isShow]=!1}),a},k.prototype.resetDatas=function(e){var t=this,i=t.config,a=(i.treeId,i.treeUpId,[]),n=[],o=e,r=t.resetDataMap(e);if(a.push(o),a.push(n),a.push(r),c.setDataList(t.config.id,o),c.setDataTreeList(t.config.id,n),c.setDataMap(t.config.id,r),null==e||e.length<=0)return a;for(var l=0;l<e.length;l++)t.resetData(e[l]);if(i.isTree){o=[],c.setDataList(t.config.id,o);var d=c.cache[i.id].data.upIds||[];(d.length<=0||t.resetDataresetRoot)&&(c.cache[i.id].data.upIds=[],d=t.resetDataRoot(e),t.resetDataresetRoot=!1),n=t.resetDataTreeList(e,d),c.setDataTreeList(t.config.id,n),o=t.resetDataTableList(n),c.setDataList(t.config.id,o)}return a},k.prototype.treeFindDataById=function(e){var t=this,i=t.config,a=null,n=c.getDataList(t.key),o=i.treeId;return n.forEach(function(t){if(t[o]==e)return void(a=t)}),a},k.prototype.treeFindUpData=function(e){var t=this,i=t.config,a=i.treeUpId;return c.getDataMap(t.config.id)[e[a]]},k.prototype.treeFindUpDatas=function(e){var t=this,i=(t.config,[]);return function e(a){var n=t.treeFindUpData(a);n&&(i.push(n),e(n))}(e),i},k.prototype.treeFindSonData=function(e){function t(e){e.children.length>0&&e.children.forEach(function(e){i.push(e),e.children.length>0&&t(e)})}var i=[];return t(e),i},k.prototype.treeConvertShowName=function(e){var t=this,i=(t.config,e.children&&e.children.length>0);return'<div style="float: left;height: 28px;line-height: 28px;padding-left: '+function(){return i?"5px":"21px"}()+'">'+function(){for(var t="<i>",i=1;i<e[c.config.cols.level];i++)t+=" ";return t+="</i>"}()+function(){var a="",n=e[c.config.cols.isOpen]?"":"";return i?a='<i class="layui-icon layui-tree-head">'+n+"</i>"+t.treeIconRender(e,!0):a+=t.treeIconRender(e,!0),a}()+"</div>"},k.prototype.treeNodeOpen=function(e,t){var i=this,a=i.layBody.find('tr[data-index="'+e[c.config.indexName]+'"]');if(e){e[c.config.cols.isOpen]=t;!function t(a){if(a.children&&a.children.length>0)for(var n=a.children,o=0;o<n.length;o++){var r=n[o];if(e[c.config.cols.isOpen]){if(a[c.config.cols.isOpen]&&a[c.config.cols.isShow]){var l=i.layBody.find('tr[data-index="'+r[c.config.indexName]+'"]');l.css("display",""),r[c.config.cols.isShow]=!0}}else{var l=i.layBody.find('tr[data-index="'+r[c.config.indexName]+'"]');l.css("display","none"),r[c.config.cols.isShow]=!1}t(r)}}(e),i.treeIconRender(e,!1);var n=a.find(".layui-tree-head");e[c.config.cols.isOpen]?n.html(""):n.html("")}},k.prototype.treeIconRender=function(e,i){var a=this,n=a.config,o=n.iconOpen,r=e.children&&e.children.length>0,l="";if(!o)return l;var d=function(){var t='<i class="layui-tree-'+e[n.idField]+'" style="display:inline-block;width: 16px;height: 16px;background:url(';return r?e[c.config.cols.isOpen]?t+=e[c.config.cols.iconOpen]:t+=e[c.config.cols.iconClose]:t+=e[c.config.cols.icon],t+=') 0 0 no-repeat;"></i>'};if(r?l=e[c.config.cols.iconOpen]||e[c.config.cols.iconClose]?d():'<i class="layui-icon layui-tree-'+e[n.idField]+" layui-tree-"+(e[c.config.cols.isOpen]?"branch":"leaf")+'" '+o+">"+(e[c.config.cols.isOpen]?a.config.branch[1]:a.config.branch[0])+"</i>":e[c.config.cols.icon]?l=d():l+='<i class="layui-icon layui-tree-'+e[n.idField]+' layui-tree-leaf" '+o+">"+a.config.leaf+"</i>",i)return l;var s=a.layBody.find('tr[data-index="'+e[c.config.indexName]+'"]').find("td[data-field="+n.treeShowName+"]").find(".layui-table-cell");t(s).find("div .layui-tree-"+e[n.idField]).remove(),t(s).find("div").append(l)},k.prototype.pullData=function(e,i){var a=this,o=a.config,r=o.request,l=o.response;if(a.startTime=(new Date).getTime(),o.url){var d={};d[r.pageName]=e,d[r.limitName]=o.limit,a.filterRulesSet(d),a.sortSet(d),t.ajax({type:o.method||"get",url:o.url,data:t.extend(d,o.where),dataType:"json",headers:o.headers,success:function(t){t[l.dataName]||(t[l.dataName]=[],t[l.statusName]=0,t[l.countName]=0,t[l.msgName]="返回的数据状态异常"),a.resetDataresetRoot=!0,"function"==typeof o.parseData&&(t=o.parseData(t)||t),a.resetDatas(t[l.dataName]),t[l.dataName]=c.getDataList(o.id),t[l.statusName]!=l.statusCode?(a.renderForm(),a.layMain.html('<div class="'+u+'">'+(t[l.msgName]||"返回的数据状态异常")+"</div>")):(a.renderData(t,e,t[l.countName]),o.time=(new Date).getTime()-a.startTime+" ms"),i&&n.close(i),a.events(),"function"==typeof o.done&&o.done(t,e,t[l.countName]),a.renderRowCheck()},error:function(e,t){a.layMain.html('<div class="'+u+'">数据接口请求异常</div>'),a.renderForm(),i&&n.close(i)}})}else if(o.data&&o.data.constructor===Array){var s={},f=e*o.limit-o.limit;s[l.dataName]=o.data.concat().splice(f,o.limit),s[l.countName]=o.data.length,a.renderData(s,e,o.data.length),a.events(),"function"==typeof o.done&&o.done(s,e,s[l.countName]),a.renderRowCheck()}},k.prototype.filterRulesSet=function(e){var t=this;e.filterRules=JSON.stringify(t.filterRules())},k.prototype.filterRules=function(){var e=this,i=[],a=e.layFilter.find("[name^='filter_']");return layui.each(a,function(e,a){if(t(a).val()){var n={field:a.name,op:"like",value:t(a).val(),datatype:"string"};i.push(n)}}),i},k.prototype.eachCols=function(e){var i=t.extend(!0,[],this.config.cols),a=[],n=0;layui.each(i,function(e,t){layui.each(t,function(t,o){if(o.colspan>1){var r=0;n++,o.CHILD_COLS=[],layui.each(i[e+1],function(e,t){t.PARENT_COL||r==o.colspan||(t.PARENT_COL=n,o.CHILD_COLS.push(t),r+=t.colspan>1?t.colspan:1)})}o.PARENT_COL||a.push(o)})});!function t(i){layui.each(i||a,function(i,a){if(a.CHILD_COLS)return t(a.CHILD_COLS);e(i,a)})}()},k.prototype.renderTreeConvertShowName=function(e){var i=this,a=i.config,n=a.elem,o=(n.next("."+h),i.treeConvertShowName(e)),r=i.layBody.find('tr[data-index="'+e[c.config.indexName]+'"]').find("td[data-field="+a.treeShowName+"]").find(".layui-table-cell");t(r).find("div").remove(),t(r).prepend(o)},k.prototype.renderTdCss=function(){var e=this,t=e.config,i=t.elem,a=i.next("."+h),n=e.index+"_"+s+"_td_style";a.find("#"+n).remove();var o='<style id="'+n+'">'+function(){var t="";return layui.each(e.config.cols,function(i,a){layui.each(a,function(i,a){t+=".laytable-cell-"+e.index+"-"+(a.field||i)+"{width:"+(a.width?a.width+"px":"0px")+"}"})}),t}()+"</style>";a.append(o)},k.prototype.renderTdEdit=function(e,i){var a=this,n=t(a.getTd(e,i)),o=a.config,i=n.data("field"),r=n.data("edit"),e=n.parents("tr").eq(0).data("index"),l=n.find("div.layui-table-cell p").text(),d=c.getDataList(a.key)[e];if("select"===r){var s=(n.data("drop"),dl.ui.table.drop.findFieldObj(o.cols[0],i)),f=dl.cache.code.get(s.drop),u="",h=f.syscodevaluecache;for(var y in h){var g="";h[y].scv_value==d[i]&&(g="selected='selected'"),u+="<option "+g+' value="'+h[y].scv_value+'">'+h[y].scv_show_name+"</option>"}var v=t('<select class="'+p+'" lay-ignore>'+u+"</select>");n.find("."+p)[0]||n.append(v)}else{var m=t('<input class="layui-input '+p+'">');m[0].value=t.trim(l),n.find("."+p)[0]||n.append(m),m.focus()}},k.prototype.renderCss=function(){var e=this,t=e.config,i=t.elem,a=i.next("."+h),n=e.index+"_"+s+"_style";a.find("#"+n).remove();var o='<style id="'+n+'">'+function(){var i=".layui-tree-head{cursor: pointer;}";return i+=".layui-table-view {margin:0;}",t.model&&"tree"==t.model&&(e.layHeader.hide(),e.layFilter.hide(),i+="."+t.id+" .layui-table td,."+t.id+"{border-style: none;padding:0;}",i+="."+t.id+" .layui-table-view .layui-table{width:100%;}"),i}()+"</style>";a.append(o)},k.prototype.renderTrUpids=function(e){var t=this,i=t.config,a=i.treeUpId,n=(e.upIds,' u_id="'+e[a]+'" ');return i.isTree?n:""},k.prototype.renderTd=function(e,a,n,o){var r=this,l=r.config,d=null==e[a.field]?"":String(e[a.field]),s=a.field||o,f=d,u=(r.getColElem(r.layHeader,s),"");return l.isTree&&l.treeShowName==a.field&&(u=r.treeConvertShowName(e)),['<td data-field="'+s+'" '+function(){var e=[];return a.edit&&e.push('data-edit="'+a.edit+'"'),a.align&&e.push('align="'+a.align+'"'),a.templet&&e.push('data-content="'+f+'"'),a.toolbar&&e.push('data-off="true"'),a.event&&e.push('lay-event="'+a.event+'"'),a.style&&e.push('style="'+a.style+'"'),a.minWidth&&e.push('data-minwidth="'+a.minWidth+'"'),e.join(" ")}()+">",'<div class="layui-table-cell laytable-cell-'+function(){var e=l.index+"-"+s;return"normal"===a.type?e:e+" laytable-cell-"+a.type}()+'">'+u+'<p style="width: auto;height: 100%;">'+function(){var o=t.extend(!0,{LAY_INDEX:n},e);if("checkbox"===a.type)return o[c.config.cols.cheDisabled]?"":'<input type="checkbox" name="'+g+'" value="'+o[c.config.indexName]+'" lay-skin="primary" '+function(){var t=c.config.cols.isCheckName;return a[t]?(e[t]=a[t],a[t]?"checked":""):o[t]?"checked":""}()+">";if("numbers"===a.type)return n;if("drop"===a.type){var r=dl.ui.table.drop.findFieldObj(l.cols[0],s);if(r&&r.drop){dl.cache.code.get(r.drop);return dl.ui.table.drop.findDropLable(r.drop,f)}}else if("radio"===a.type)return o[c.config.cols.radDisabled]?"":'<input type="radio" name="'+y+'" '+function(){var t=c.config.cols.isRadio;return a[t]?(e[t]=a[t],a[t]?"checked":""):o[t]?"checked":""}()+' value="'+o[c.config.indexName]+'" title=" ">';return a.toolbar?i(t(a.toolbar).html()||"").render(o):a.templet?function(){return"function"==typeof a.templet?a.templet(o):i(t(a.templet).html()||String(f)).render(o)}():f}(),"</p></div></td>"].join("")},k.prototype.renderTr=function(e,t){var i=this,a=(i.config,[]);return i.eachCols(function(n,o){var r=o.field||n;e[r];if(!(o.colspan>1)){var l=i.renderTd(e,o,t,n);a.push(l)}}),a},k.prototype.renderData=function(e,t,i,a){var o=this,r=o.config,l=e[r.response.dataName]||[],d=[],s=[],f=[],h=function(){if(!a&&o.sortKey)return o.sort(o.sortKey.field,o.sortKey.sort,!0);layui.each(l,function(e,i){var n=(o.treeFindUpData(i),"");!i[c.config.cols.isShow]&&r.isTree&&(n="display: none;");var l=[],u=[],h=[],p=e+r.limit*(t-1)+1;0!==i.length&&(a||(i[c.config.indexName]=e),l=o.renderTr(i,p),d.push('<tr style="'+n+'" data-index="'+e+'" '+o.renderTrUpids(i)+">"+l.join("")+"</tr>"),s.push('<tr data-index="'+e+'">'+u.join("")+"</tr>"),f.push('<tr data-index="'+e+'">'+h.join("")+"</tr>"))}),o.layBody.scrollTop(0),o.layMain.find("."+u).remove(),o.layMain.find("tbody").html(d.join("")),o.layFixLeft.find("tbody").html(s.join("")),o.layFixRight.find("tbody").html(f.join("")),o.renderForm(),o.haveInit?o.scrollPatch():setTimeout(function(){o.scrollPatch()},50),o.haveInit=!0,n.close(o.tipsIndex)};return o.key=r.id||r.index,c.setDataList(o.key,l),o.layPage[0===l.length&&1==t?"addClass":"removeClass"]("layui-hide"),a?h():0===l.length?(o.renderForm(),o.layFixed.remove(),o.layMain.find("tbody").html(""),o.layMain.find("."+u).remove(),o.layMain.append('<div class="'+u+'">'+(e[r.response.msgName]?e[r.response.msgName]:r.text.none)+"</div>")):(h(),o.renderPage(i),void c.pushClassIds(r.id,!0))},k.prototype.renderPage=function(e){var i=this,n=i.config;n.isPage&&(n.page=t.extend({elem:"layui-table-page"+n.index,count:e,limit:n.limit,limits:n.limits||[10,15,20,30,40,50,60,70,80,90],groups:3,layout:["prev","page","next","skip","count","limit"],prev:'<i class="layui-icon"></i>',next:'<i class="layui-icon"></i>',jump:function(e,t){t||(i.page=e.curr,n.limit=e.limit,i.pullData(e.curr,i.loading()))}},n.page),n.page.count=e,a.render(n.page))},k.prototype.renderFilter=function(){var e=this,t=e.config,i=e.index,a=[];return a.push('<form method="post" id="'+t.id+'_filter_form">'),a.push('<table cellspacing="0" cellpadding="0" border="0" class="layui-table"><thead><tr>'),layui.each(t.cols,function(e,t){layui.each(t,function(e,t){var n=t.field||e,o=t.minWidth?"data-minwidth='"+t.minWidth+"'":"",r=t.colspan?'colspan="'+t.colspan+'"':"",l=t.rowspan?'rowspan="'+t.rowspan+'"':"",c=t.unresize?'data-unresize="true"':"";a.push('<th data-field="'+n+'"'+o+r+l+c+">"),a.push('<div class="layui-table-cell laytable-cell-'+function(){var e="";return t.colspan>1?e="group":(e=i+"-"+n,"normal"!==t.type&&(e+=" laytable-cell-"+t.type)),e}()+'">'),t.isFilter&&t.field?a.push('<input class="layui-input '+p+'" id="filter_'+t.field+'" name="filter_'+t.field+'">'):a.push(""),a.push("</div></th>")})}),a.push("</tr></thead></table>"),a.push("</form>"),a.join("")},k.prototype.renderRowCheck=function(){var e=this,t=e.config,i=(e.index,c.getDataList(t.id));i&&i.forEach(function(t){var i=e.layBody.find("tr[data-index="+t[c.config.indexName]+"]");t[c.config.cols.isRowCheck]?i.css("background-color","#ccc"):i.css("background-color","")})},k.prototype.getColElem=function(e,t){var i=this,a=i.config;return e.eq(0).find(".laytable-cell-"+a.index+"-"+t+":eq(0)")},k.prototype.renderForm=function(e){o.render(e,"LAY-table-"+this.index)},k.prototype.sortSet=function(e){var t=this,i=[];t.config.cols[0].forEach(function(e){if(e.sortType){var t={field:e.field,sort:e.sortType};i.push(t)}}),e.sort=JSON.stringify(i)},k.prototype.sort=function(e,i,a,n){var o,l=this,d=l.config;d.elem.attr("lay-filter"),c.getDataList(l.key);"string"==typeof e&&l.layHeader.find("th").each(function(i,a){var n=t(this),r=n.data("field");if(r===e)return e=n,o=r,!1});try{var o=o||e.data("field");if(l.sortKey&&!a&&o===l.sortKey.field&&i===l.sortKey.sort)return;l.layHeader.find("th .laytable-cell-"+d.index+"-"+o).find(".layui-table-sort").attr("lay-sort",i||null),l.layFixed.find("th")}catch(e){return r.error("Table modules: Did not match to field")}var s=l.getCols(o);s&&(s.sortType=i)},k.prototype.loading=function(){var e=this,t=e.config;if(t.loading&&t.url)return n.msg("数据请求中",{icon:16,offset:[e.elem.offset().top+e.elem.height()/2-35-x.scrollTop()+"px",e.elem.offset().left+e.elem.width()/2-90-x.scrollLeft()+"px"],time:-1,anim:-1,fixed:!1})},k.prototype.setCheckData=function(e,t){var i=this,a=(i.config,c.getDataList(i.key));a[e]&&a[e].constructor!==Array&&(a[e][c.config.cols.isCheckName]=t)},k.prototype.syncCheckAll=function(){var e=this,t=e.config,i=c.getDataList(e.config.id);if(i){var a=!0,n=0;if(i.forEach(function(t){if(!t[c.config.cols.cheDisabled])if(t[c.config.cols.isCheckName]){var i=e.layBody.find("tr[data-index="+t[c.config.indexName]+"]").find('input[name="'+g+'"]');i.prop("checked",!0),n++}else{a=!1;var i=e.layBody.find("tr[data-index="+t[c.config.indexName]+"]").find('input[name="'+g+'"]');i.prop("checked",!1)}}),a){var o=e.layHeader.find('input[name="'+g+'"]');o.prop("checked",!0)}if(n<i.length-t.cheDisabledNum){var o=e.layHeader.find('input[name="'+g+'"]');o.prop("checked",!1)}e.renderForm("checkbox")}},k.prototype.getCssRule=function(e,t){var i=this,a=i.elem.find("style")[0],n=a.sheet||a.styleSheet||{},o=n.cssRules||n.rules;layui.each(o,function(a,n){if(n.selectorText===".laytable-cell-"+i.index+"-"+e)return t(n),!0})},k.prototype.test=function(){},k.prototype.resize=function(){
|
||
var e=this;e.columnWidthInit(),e.tableHeight(),e.resizeHeight(),e.resizeWidth()},k.prototype.setArea=function(){var e=this;e.columnWidthInit(),e.tableHeight()},k.prototype.columnWidthInit=function(){var e=this,t=e.config,i=0,a=0,n=0,o=0,r=t.width||function(){return function e(i){var a,n;i=i||t.elem.parent(),a=i.width();try{n="none"===i.css("display")}catch(e){}return!i[0]||a&&!n?a:e(i.parent())}()}()-17;e.eachCols(function(){i++}),r-=function(){return"line"===t.skin||"nob"===t.skin?2:i+1}(),layui.each(t.cols,function(t,i){layui.each(i,function(t,n){var l;if(!n)return void i.splice(t,1);e.initOpts(n),l=n.width||0,n.colspan>1||(/\d+%$/.test(l)?n.width=l=Math.floor(parseFloat(l)/100*r):!n._is_width_dev&&l||(n._is_width_dev=!0,n.width=l=0,a++),o+=l)})}),e.autoColNums=a,r>o&&a&&(n=(r-o)/a),layui.each(t.cols,function(e,i){layui.each(i,function(e,i){var a=i.minWidth||t.cellMinWidth;i.colspan>1||0===i.width&&(i.width=Math.floor(n>=a?n:a))})})},k.prototype.resizeWidth=function(){this.renderTdCss()},k.prototype.tableHeight=function(){var e=this,i=e.config,a=e.configFirst;if(!c.kit.isNumber(a.height)){var n=0;if(i.heightRemove&&c.kit.isArray(i.heightRemove)){i.heightRemove.forEach(function(e){var i=c.kit.isNumber(e)?e:t(e).outerHeight(!0);c.kit.isNumber(i)&&(n+=i)})}var o=x.height()-n-1;e.fullHeightGap=0,i.height&&/^full-\d+$/.test(i.height)&&(e.fullHeightGap=i.height.split("-")[1]),i.height=o-e.fullHeightGap}},k.prototype.resizeHeight=function(){var e,t=this,i=t.config,a=i.height;a<135&&(a=135),t.elem.css("height",a-80);var n=i.isFilter?76:38;e=parseFloat(a)-("tree"==t.config.model?0:n)-1,i.toolbar&&(e-=t.layTool.outerHeight()),i.isPage&&(e=e-t.layPage.outerHeight()-1),t.layMain.css("height",e-80)},k.prototype.getScrollWidth=function(e){var t=0;return e?t=e.offsetWidth-e.clientWidth:(e=document.createElement("div"),e.style.width="100px",e.style.height="100px",e.style.overflowY="scroll",document.body.appendChild(e),t=e.offsetWidth-e.clientWidth,document.body.removeChild(e)),t},k.prototype.scrollPatch=function(){var e=this,i=e.layMain.children("table"),a=e.layMain.width()-e.layMain.prop("clientWidth"),n=e.layMain.height()-e.layMain.prop("clientHeight"),o=e.getScrollWidth(e.layMain[0]),r=i.outerWidth()-e.layMain.width();if(e.autoColNums&&r<5&&!e.scrollPatchWStatus){var l=e.layHeader.eq(0).find("thead th:last-child"),c=l.data("field");e.getCssRule(c,function(t){var i=t.style.width||l.outerWidth();t.style.width=parseFloat(i)-o-r+"px",e.layMain.height()-e.layMain.prop("clientHeight")>0&&(t.style.width=parseFloat(t.style.width)-1+"px"),e.scrollPatchWStatus=!0})}if(a&&n){if(e.elem.find(".layui-table-patch").length<=0){var d=t('<th class="layui-table-patch"><div class="layui-table-cell"></div></th>');d.find("div").css({width:a}),e.layHeader.eq(0).find("thead tr").append(d)}}else e.layFilter.eq(0).find(".layui-table-patch").remove(),e.layHeader.eq(0).find(".layui-table-patch").remove();var s=e.layMain.height(),f=s-n;e.layFixed.find(".layui-table-body").css("height",i.height()-80>f?f:"auto"),e.layFixRight[r>0?"removeClass":"addClass"]("layui-hide"),e.layFixRight.css("right",a-1)},k.prototype.events=function(){var e,i=this,a=i.config,o=t("body"),r={},l=i.layHeader.find("th"),d=i.layBody.find("tr");d.unbind("click").on("click",function(e){var a=t(this).attr("data-index");c.treeRowCheck(i.config.id,a)}),d.unbind("dblclick").on("dblclick",function(e){var n=t(this).attr("data-index"),o=c.getDataList(i.config.id),r=o[n];"function"==typeof a.onDblClickRow&&a.onDblClickRow(n,r)}),l.unbind("mousemove").on("mousemove",function(e){var i=t(this),a=i.offset().left,n=e.clientX-a;i.attr("colspan")>1||i.data("unresize")||r.resizeStart||(r.allowResize=i.width()-n<=10,o.css("cursor",r.allowResize?"col-resize":""))}),l.unbind("mouseleave").on("mouseleave",function(){t(this);r.resizeStart||o.css("cursor","")}),l.unbind("mousedown").on("mousedown",function(e){var n=t(this);if(r.allowResize){var o=n.data("field");e.preventDefault(),r.resizeStart=!0,r.offset=[e.clientX,e.clientY],i.getCssRule(o,function(e){var t=e.style.width||n.outerWidth();r.rule=e,r.ruleWidth=parseFloat(t),r.minWidth=n.data("minwidth")||a.cellMinWidth})}}),D.unbind("mousemove").on("mousemove",function(t){if(r.resizeStart){if(t.preventDefault(),r.rule){var a=r.ruleWidth+t.clientX-r.offset[0];a<r.minWidth&&(a=r.minWidth),r.rule.style.width=a+"px",n.close(i.tipsIndex)}e=1}}),D.unbind("mouseup").on("mouseup",function(t){r.resizeStart&&(r={},o.css("cursor",""),i.scrollPatch()),2===e&&(e=null)}),l.unbind("click").on("click",function(){var a,n=t(this),o=n.find(".layui-table-sort"),r=o.attr("lay-sort");if(!o[0]||1===e)return e=2;a="asc"===r?"desc":"desc"===r?null:"asc",i.sort(n,a,null,!0),c.query(i.key)}),l.find(".layui-table-sort .layui-edge ").unbind("click").on("click",function(e){var a=t(this),n=a.index(),o=a.parents("th").eq(0).data("field");layui.stope(e),0===n?i.sort(o,"asc",null,!0):i.sort(o,"desc",null,!0),c.query(i.key)}),i.eventsinitIsRun||(i.eventsinit(),i.eventsinitIsRun=!0),i.layMain.unbind("scroll").on("scroll",function(){var e=t(this),a=e.scrollLeft(),o=e.scrollTop();i.layHeader.scrollLeft(a),i.layFilter.scrollLeft(a),i.layFixed.find(".layui-table-body").scrollTop(o),n.close(i.tipsIndex)}),x.unbind("resize").on("resize",function(){i.resize()})},k.prototype.eventsinitIsRun=!1,k.prototype.eventsinit=function(){var e=this,a=e.config,o=".layui-table-cell",r=a.elem.attr("lay-filter");e.layFilter.on("keyup","[name^='filter_']",function(){e.page=1,e.pullData(e.page,e.loading())}),e.layBody.on("mouseenter","tr",function(){var i=t(this),a=i.index();e.layBody.find("tr:eq("+a+")").addClass("layui-table-hover")}),e.layBody.on("mouseleave","tr",function(){var i=t(this),a=i.index();e.layBody.find("tr:eq("+a+")").removeClass("layui-table-hover")}),e.layBody.on("click","td div.layui-table-cell p",function(){var i=t(this).parent().parent(),a=i.data("field"),r=i.data("edit"),d=i.parents("tr").eq(0).data("index"),s=(c.getDataList(e.key)[d],i.children(o)),f=e.config;if(n.close(e.tipsIndex),!i.data("off")){if(r&&"click"==f.editModel)return void e.renderTdEdit(d,a);var u=e.getCols(a);if(!c.config.initWidth[u.type]){if(s.find(".layui-form-switch,.layui-form-checkbox")[0])return;Math.round(s.prop("scrollWidth"))>Math.round(s.outerWidth())&&(e.tipsIndex=n.tips(['<div class="layui-table-tips-main" style="margin-top: -'+(s.height()+16)+"px;"+function(){return"sm"===f.size?"padding: 4px 15px; font-size: 12px;":"lg"===f.size?"padding: 14px 15px;":""}()+'">',s.html(),"</div>",'<i class="layui-icon layui-table-tips-c">ဆ</i>'].join(""),s[0],{tips:[3,""],time:-1,anim:-1,maxWidth:l.ios||l.android?300:600,isOutAnim:!1,skin:"layui-table-tips",success:function(e,t){e.find(".layui-table-tips-c").on("click",function(){n.close(t)})}}))}}}),e.layBody.on("dblclick","td div.layui-table-cell p",function(){var i=t(this).parent().parent(),a=i.data("field"),r=i.data("edit"),l=i.parents("tr").eq(0).data("index"),d=(c.getDataList(e.key)[l],i.children(o),e.config);if(n.close(e.tipsIndex),!i.data("off"))return r&&"dblclick"==d.editModel?void e.renderTdEdit(l,a):void 0}),e.layBody.on("change","."+p,function(){var i=t(this),a=this.value,n=i.parent().data("field"),o=i.parents("tr").eq(0).data("index"),l=c.getDataList(e.key)[o];l[n]=a,layui.event.call(this,s,"edit("+r+")",{value:a,data:l,field:n})}),e.layBody.on("blur","."+p,function(){var a,n=t(this),r=n.parent().data("field"),l=n.parents("tr").eq(0).data("index"),d=n.parent().data("edit"),s=c.getDataList(e.key)[l],f=e.config;e.eachCols(function(e,t){t.field==r&&t.templet&&(a=t.templet)});var u="";if("select"===d){var h=dl.ui.table.drop.findFieldObj(f.cols[0],r);if(h&&h.drop){dl.cache.code.get(h.drop);u=dl.ui.table.drop.findDropLable(h.drop,this.value)}n.parent().find(o+" p").html(a?i(t(a).html()||u).render(s):u)}else n.parent().find(o+" p").html(a?i(t(a).html()||this.value).render(s):this.value);n.parent().data("content",this.value),n.remove()}),e.elem.on("click","i.layui-tree-head",function(){var i=t(this),a=i.parents("tr").eq(0).data("index"),n=(e.config,c.getDataList(e.key)),o=n[a];e.treeNodeOpen(o,!o[c.config.cols.isOpen]),e.resize()}),e.elem.on("click",'input[name="'+g+'"]+',function(){var i=t(this).prev(),n=(e.layBody.find('input[name="'+g+'"]'),i.parents("tr").eq(0).data("index")),o=i[0].checked,l=c.getDataList(e.config.id)[n],d="layTableAllChoose"===i.attr("lay-filter");if(d){c.getDataList(e.key).forEach(function(t){t[c.config.cols.cheDisabled]||e.setCheckData(t[c.config.indexName],o)})}else if(e.setCheckData(n,o),a.isTree){var f=e.treeFindSonData(l);f.forEach(function(t){t[c.config.cols.cheDisabled]||e.setCheckData(t[c.config.indexName],o)});var u=e.treeFindUpData(l);!function t(i){if(null!=i&&i&&i.children.length>0){var a=!0;i.children.forEach(function(e){e[c.config.cols.isCheckName]||(a=!1)}),a&&e.setCheckData(i[c.config.indexName],o);var n=e.treeFindUpData(i);n&&t(n)}}(u)}e.syncCheckAll(),layui.event.call(this,s,"checkbox("+r+")",{checked:o,data:c.getDataList(e.key)?l||{}:{},type:d?"all":"one"}),"function"==typeof a.onCheck&&a.onCheck(l,o,d)}),e.elem.on("click",'input[name="'+y+'"]+',function(){var i=t(this).prev(),n=i.parents("tr").eq(0).data("index"),o=c.getDataList(e.config.id)[n];"function"==typeof a.onRadio&&a.onRadio(o)}),e.layBody.on("click","*[lay-event]",function(){var n=t(this),l=n.parents("tr").eq(0).data("index"),d=e.layBody.find('tr[data-index="'+l+'"]'),f=(c.getDataList(e.key),c.getDataList(e.key)[l]);layui.event.call(this,s,"tool("+r+")",{data:f,event:n.attr("lay-event"),tr:d,del:function(){c.delRow(a.id,f)},update:function(a){a=a||{},layui.each(a,function(a,n){if(a in f){var r,l=d.children('td[data-field="'+a+'"]');f[a]=n,e.eachCols(function(e,t){t.field==a&&t.templet&&(r=t.templet)}),l.children(o).html(r?i(t(r).html()||n).render(f):n),l.data("content",n)}})}}),d.addClass("layui-table-click").siblings("tr").removeClass("layui-table-click")})},d.config={},c.init(),e(s,c)}); |