This commit is contained in:
sentsin
2017-11-16 07:34:22 +08:00
parent 3a6735e32b
commit cbcf3db7bb
31 changed files with 272 additions and 66 deletions

View File

@@ -586,8 +586,8 @@ hr, .layui-timeline-item:before{background-color: #e6e6e6;}
.layui-table th, .layui-table td{position: relative; padding: 9px 15px; min-height: 20px; line-height: 20px; font-size: 14px;}
.layui-table[lay-even] tr:nth-child(even){background-color: #f8f8f8;}
.layui-table tbody tr:hover,
.layui-table-hover{background-color: #f8f8f8!important;}
.layui-table-click{background-color: #FFEEE8!important;}
.layui-table-hover{background-color: #f8f8f8;}
.layui-table-click{background-color: #f8f8f8;}
.layui-table[lay-skin="line"] th, .layui-table[lay-skin="line"] td{border-width: 0; border-bottom-width: 1px;}
.layui-table[lay-skin="row"] th, .layui-table[lay-skin="row"] td{border-width: 0;border-right-width: 1px;}
@@ -624,7 +624,7 @@ hr, .layui-timeline-item:before{background-color: #e6e6e6;}
.layui-table-sort .layui-table-sort-desc:hover{border-top-color: #666;}
.layui-table-sort[lay-sort="asc"] .layui-table-sort-asc{border-bottom-color: #000;}
.layui-table-sort[lay-sort="desc"] .layui-table-sort-desc{border-top-color: #000;}
.layui-table-cell{height: 28px; line-height: 28px; padding: 0 15px; position: relative; overflow: hidden; /*text-overflow: ellipsis;*/ white-space: nowrap; box-sizing: border-box;}
.layui-table-cell{height: 28px; line-height: 28px; padding: 0 15px; position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; box-sizing: border-box;}
.layui-table-cell .layui-form-checkbox[lay-skin="primary"]{top: -1px; vertical-align: middle;}
.layui-table-cell .layui-table-link{color: #01AAED;}
@@ -643,7 +643,7 @@ hr, .layui-timeline-item:before{background-color: #e6e6e6;}
.layui-table-tool{position: relative; width: 100%; height: 50px; line-height: 30px; padding: 10px 15px; border-width: 0; border-bottom-width: 1px;}
.layui-table-page{position: relative; width: 100%; padding: 7px 10px 0 0; border-width: 0; border-top-width: 1px; height: 41px; margin-bottom: -1px; font-size: 12px; white-space: nowrap;}
.layui-table-page{position: relative; width: 100%; padding: 7px 7px 0; border-width: 0; border-top-width: 1px; height: 41px; margin-bottom: -1px; font-size: 12px; white-space: nowrap;}
.layui-table-page:hover{overflow-x: auto;}
.layui-table-page>div{height: 26px;}
.layui-table-page .layui-laypage{margin: 0;}
@@ -652,6 +652,7 @@ hr, .layui-timeline-item:before{background-color: #e6e6e6;}
.layui-table-page .layui-laypage a,
.layui-table-page .layui-laypage span.layui-laypage-curr{padding: 0 12px;}
.layui-table-page .layui-laypage span{margin-left: 0; padding: 0;}
.layui-table-page .layui-laypage .layui-laypage-prev{margin-left: -7px!important;}
.layui-table-page .layui-laypage .layui-laypage-curr .layui-laypage-em{left: 0; top: 0; padding: 0;}
.layui-table-page .layui-laypage input,
.layui-table-page .layui-laypage button{height: 26px; line-height: 26px; }
@@ -668,7 +669,7 @@ select.layui-table-edit{padding: 0 0 0 10px; border-color: #C9C9C9;}
.layui-table-view .layui-form-switch,
.layui-table-view .layui-form-checkbox,
.layui-table-view .layui-form-radio{top: 0; margin: 0; box-sizing: content-box;}
.layui-table-view .layui-form-checkbox{height: 26px; line-height: 26px; vertical-align: top;}
.layui-table-view .layui-form-checkbox{top: -1px; height: 26px; line-height: 26px;}
body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-shadow: 0 1px 6px rgba(0,0,0,.1);}

View File

@@ -82,7 +82,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
}
return '';
}()
,'<th data-field="{{ item2.field||i2 }}" '+ rowCols +' {{# if(item2.unresize){ }}unresize="true"{{# } }}>'
,'<th data-field="{{ item2.field||i2 }}" {{# if(item2.minWidth){ }}data-minwidth="{{item2.minWidth}}"{{# } }} '+ rowCols +' {{# if(item2.unresize){ }}data-unresize="true"{{# } }}>'
,'<div class="layui-table-cell laytable-cell-'
,'{{# if(item2.colspan > 1){ }}'
,'group'
@@ -191,12 +191,13 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
Class.prototype.config = {
limit: 10 //每页显示的数量
,loading: true //请求数据时是否显示loading
,cellMinWidth: 60 //所有单元格默认最小宽度
};
//表格渲染
Class.prototype.render = function(){
var that = this,
options = that.config;
var that = this
,options = that.config;
options.elem = $(options.elem);
options.where = options.where || {};
@@ -217,7 +218,14 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
,countName: 'count'
}, options.response);
if(typeof options.page === 'object') delete options.page.jump;
//如果 page 传入 laypage 对象
if(typeof options.page === 'object'){
options.limit = options.page.limit || options.limit;
options.limits = options.page.limits || options.limits;
that.page = options.page.curr || that.page;
delete options.page.elem;
delete options.page.jump;
}
if(!options.elem[0]) return that;
@@ -263,7 +271,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
}
//请求数据
that.pullData(1);
that.pullData(that.page);
that.events();
};
@@ -346,15 +354,16 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
});
//如果未填充满,则将剩余宽度平分。否则,给未设定宽度的列赋值一个默认宽
autoWidth = cntrWidth > countWidth
? (cntrWidth - countWidth) / autoColNums
: 200;
(cntrWidth > countWidth && autoColNums) && (
autoWidth = (cntrWidth - countWidth) / autoColNums
);
layui.each(options.cols, function(i1, item1){
layui.each(item1, function(i2, item2){
var minWidth = item2.minWidth || options.cellMinWidth;
if(item2.colspan > 1) return;
if(item2.width === 0){
item2.width = Math.floor(autoWidth);
item2.width = Math.floor(autoWidth >= minWidth ? autoWidth : minWidth); //不能低于设定的最小宽度
}
});
});
@@ -499,7 +508,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
if(item3.toolbar) attr.push('data-off="true"'); //自定义模板
if(item3.event) attr.push('lay-event="'+ item3.event +'"'); //自定义事件
if(item3.style) attr.push('style="'+ item3.style +'"'); //自定义样式
if(cell.data('autowidth')) attr.push('data-autowidth="true"'); //自适应宽度
if(item3.minWidth) attr.push('data-minwidth="'+ item3.minWidth +'"'); //单元格最小宽度
return attr.join(' ');
}() +'>'
,'<div class="layui-table-cell laytable-cell-'+ function(){ //返回对应的CSS类标识
@@ -582,7 +591,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
if(options.page){
that.page = curr;
that.count = count;
laypage.render($.extend({
options.page = $.extend({
elem: 'layui-table-page' + options.index
,count: count
,groups: 3
@@ -599,7 +608,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
that.pullData(obj.curr, that.loading());
}
}
}, options.page));
}, options.page);
laypage.render(options.page);
}
};
@@ -851,7 +861,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
var othis = $(this)
,oLeft = othis.offset().left
,pLeft = e.clientX - oLeft;
if(othis.attr('colspan') > 1 || othis.attr('unresize') || dict.resizeStart){
if(othis.attr('colspan') > 1 || othis.data('unresize') || dict.resizeStart){
return;
}
dict.allowResize = othis.width() - pLeft <= 10; //是否处于拖拽允许区域
@@ -863,7 +873,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
}).on('mousedown', function(e){
var othis = $(this);
if(dict.allowResize){
var field = $(this).data('field');
var field = othis.data('field');
e.preventDefault();
dict.resizeStart = true; //开始拖拽
dict.offset = [e.clientX, e.clientY]; //记录初始坐标
@@ -872,6 +882,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
var width = item.style.width || othis.outerWidth();
dict.rule = item;
dict.ruleWidth = parseFloat(width);
dict.minWidth = othis.data('minwidth') || config.cellMinWidth;
});
}
});
@@ -881,6 +892,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
e.preventDefault();
if(dict.rule){
var setWidth = dict.ruleWidth + e.clientX - dict.offset[0];
if(setWidth < dict.minWidth) setWidth = dict.minWidth;
dict.rule.style.width = setWidth + 'px';
layer.close(that.tipsIndex);
}
@@ -1022,7 +1034,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
}
//如果出现省略,则可查看更多
if(elemCell.children().length > 0) return;
if(elemCell.find('.layui-form-switch,.layui-form-checkbox')[0]) return; //限制不出现更多(暂时)
if(Math.round(elemCell.prop('scrollWidth')) > Math.round(elemCell.outerWidth())){
that.tipsIndex = layer.tips([
'<div class="layui-table-tips-main" style="margin-top: -'+ (elemCell.height() + 16) +'px;'+ function(){

View File

@@ -19,13 +19,23 @@
}
,Layui = function(){
this.v = '2.2.0'; //版本号
this.v = '2.2.1'; //版本号
}
//获取layui所在目录
,getPath = function(){
var js = doc.scripts
,jsPath = js[js.length - 1].src;
var jsPath = doc.currentScript ? doc.currentScript.src : function(){
var js = doc.scripts
,last = js.length - 1
,src;
for(var i = last; i > 0; i--){
if(js[i].readyState === 'interactive'){
src = js[i].src;
break;
}
}
return src || js[last].src;
}();
return jsPath.substring(0, jsPath.lastIndexOf('/') + 1);
}()