|
|
|
@ -15,13 +15,13 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|
|
|
|
var hint = layui.hint(); |
|
|
|
|
var device = layui.device(); |
|
|
|
|
|
|
|
|
|
//外部接口
|
|
|
|
|
// api
|
|
|
|
|
var table = { |
|
|
|
|
config: { |
|
|
|
|
config: { // 全局配置项
|
|
|
|
|
checkName: 'LAY_CHECKED' // 是否选中状态的字段名
|
|
|
|
|
,indexName: 'LAY_TABLE_INDEX' // 初始下标索引名,用于恢复排序
|
|
|
|
|
,disabledName: 'LAY_DISABLED' |
|
|
|
|
} //全局配置项
|
|
|
|
|
} |
|
|
|
|
,cache: {} // 数据缓存
|
|
|
|
|
,index: layui.table ? (layui.table.index + 10000) : 0 |
|
|
|
|
|
|
|
|
@ -98,10 +98,32 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|
|
|
|
return obj.text ? $('<div>'+ content +'</div>').text() : content; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//字符常量
|
|
|
|
|
,MOD_NAME = 'table', ELEM = '.layui-table', THIS = 'layui-this', SHOW = 'layui-show', HIDE = 'layui-hide', HIDE_V = 'layui-hide-v', DISABLED = 'layui-disabled', NONE = 'layui-none' |
|
|
|
|
|
|
|
|
|
,ELEM_VIEW = 'layui-table-view', ELEM_TOOL = '.layui-table-tool', ELEM_BOX = '.layui-table-box', ELEM_INIT = '.layui-table-init', ELEM_HEADER = '.layui-table-header', ELEM_BODY = '.layui-table-body', ELEM_MAIN = '.layui-table-main', ELEM_FIXED = '.layui-table-fixed', ELEM_FIXL = '.layui-table-fixed-l', ELEM_FIXR = '.layui-table-fixed-r', ELEM_TOTAL = '.layui-table-total', ELEM_PAGE = '.layui-table-page', ELEM_PAGE_VIEW = '.layui-table-pageview', ELEM_SORT = '.layui-table-sort', ELEM_EDIT = 'layui-table-edit', ELEM_HOVER = 'layui-table-hover' |
|
|
|
|
// 字符
|
|
|
|
|
,MOD_NAME = 'table' |
|
|
|
|
,ELEM = '.layui-table' |
|
|
|
|
,THIS = 'layui-this' |
|
|
|
|
,SHOW = 'layui-show' |
|
|
|
|
,HIDE = 'layui-hide' |
|
|
|
|
,HIDE_V = 'layui-hide-v' |
|
|
|
|
,DISABLED = 'layui-disabled' |
|
|
|
|
,NONE = 'layui-none' |
|
|
|
|
|
|
|
|
|
,ELEM_VIEW = 'layui-table-view' |
|
|
|
|
,ELEM_TOOL = '.layui-table-tool' |
|
|
|
|
,ELEM_BOX = '.layui-table-box' |
|
|
|
|
,ELEM_INIT = '.layui-table-init' |
|
|
|
|
,ELEM_HEADER = '.layui-table-header' |
|
|
|
|
,ELEM_BODY = '.layui-table-body' |
|
|
|
|
,ELEM_MAIN = '.layui-table-main' |
|
|
|
|
,ELEM_FIXED = '.layui-table-fixed' |
|
|
|
|
,ELEM_FIXL = '.layui-table-fixed-l' |
|
|
|
|
,ELEM_FIXR = '.layui-table-fixed-r' |
|
|
|
|
,ELEM_TOTAL = '.layui-table-total' |
|
|
|
|
,ELEM_PAGE = '.layui-table-page' |
|
|
|
|
,ELEM_PAGE_VIEW = '.layui-table-pageview' |
|
|
|
|
,ELEM_SORT = '.layui-table-sort' |
|
|
|
|
,ELEM_EDIT = 'layui-table-edit' |
|
|
|
|
,ELEM_HOVER = 'layui-table-hover' |
|
|
|
|
|
|
|
|
|
// thead 区域模板
|
|
|
|
|
,TPL_HEADER = function(options){ |
|
|
|
@ -326,10 +348,15 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|
|
|
|
,hasRender = othis.next('.' + ELEM_VIEW) |
|
|
|
|
|
|
|
|
|
//主容器
|
|
|
|
|
,reElem = that.elem = $('<div class="layui-form layui-border-box"></div>'); |
|
|
|
|
,reElem = that.elem = $('<div></div>'); |
|
|
|
|
|
|
|
|
|
reElem.addClass(function(){ |
|
|
|
|
var arr = [ELEM_VIEW, ELEM_VIEW +'-'+ that.index]; |
|
|
|
|
var arr = [ |
|
|
|
|
ELEM_VIEW, |
|
|
|
|
ELEM_VIEW +'-'+ that.index, |
|
|
|
|
'layui-form', |
|
|
|
|
'layui-border-box' |
|
|
|
|
]; |
|
|
|
|
if(options.className) arr.push(options.className); |
|
|
|
|
return arr.join(' '); |
|
|
|
|
}()).attr({ |
|
|
|
@ -603,13 +630,13 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|
|
|
|
|
|
|
|
|
//动态分配列宽
|
|
|
|
|
Class.prototype.setColsWidth = function(){ |
|
|
|
|
var that = this |
|
|
|
|
,options = that.config |
|
|
|
|
,colNums = 0 //列个数
|
|
|
|
|
,autoColNums = 0 //自动列宽的列个数
|
|
|
|
|
,autoWidth = 0 //自动列分配的宽度
|
|
|
|
|
,countWidth = 0 //所有列总宽度和
|
|
|
|
|
,cntrWidth = that.setInit('width'); |
|
|
|
|
var that = this; |
|
|
|
|
var options = that.config; |
|
|
|
|
var colNums = 0; // 列个数
|
|
|
|
|
var autoColNums = 0; // 自动列宽的列个数
|
|
|
|
|
var autoWidth = 0; // 自动列分配的宽度
|
|
|
|
|
var countWidth = 0; // 所有列总宽度和
|
|
|
|
|
var cntrWidth = that.setInit('width'); |
|
|
|
|
|
|
|
|
|
// 统计列个数
|
|
|
|
|
that.eachCols(function(i, item){ |
|
|
|
@ -672,7 +699,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|
|
|
|
var minWidth = item3.minWidth || options.cellMinWidth; |
|
|
|
|
if(item3.colGroup || item3.hide) return; |
|
|
|
|
|
|
|
|
|
//给位分配宽的列平均分配宽
|
|
|
|
|
// 给未分配宽的列平均分配宽
|
|
|
|
|
if(item3.width === 0){ |
|
|
|
|
that.getCssRule(options.index +'-'+ item3.key, function(item){ |
|
|
|
|
item.style.width = Math.floor(autoWidth >= minWidth ? autoWidth : minWidth) + 'px'; |
|
|
|
@ -1008,6 +1035,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|
|
|
|
|
|
|
|
|
// 因为 page 参数有可能发生变化 先重新铺满
|
|
|
|
|
that.fullSize(); |
|
|
|
|
|
|
|
|
|
// 滚动条补丁
|
|
|
|
|
that.haveInit ? that.scrollPatch() : setTimeout(function(){ |
|
|
|
|
that.scrollPatch(); |
|
|
|
|