Browse Source

优化 table 局部代码书写规范

pull/1368/head
火烈鸟 1 year ago committed by GitHub
parent
commit
689866c483
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      src/modules/table.js

22
src/modules/table.js

@ -1111,7 +1111,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
curr = curr || 1
layui.each(data, function(i1, item1){
var tds = [];
var tds = [];
var tds_fixed = [];
var tds_fixed_r = [];
var numbers = i1 + options.limit*(curr - 1) + 1; // 序号
@ -1208,7 +1208,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
case 'numbers':
return numbers;
//break;
};
}
//解析工具列模板
if(item3.toolbar){
@ -1771,7 +1771,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
//获取滚动条宽度
Class.prototype.getScrollWidth = function(elem){
var width = 0;
var width;
if(elem){
width = elem.offsetWidth - elem.clientWidth;
} else {
@ -1791,19 +1791,19 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
Class.prototype.scrollPatch = function(){
var that = this;
var layMainTable = that.layMain.children('table');
var scollWidth = that.layMain.width() - that.layMain.prop('clientWidth'); // 纵向滚动条宽度
var scollHeight = that.layMain.height() - that.layMain.prop('clientHeight'); // 横向滚动条高度
var scrollWidth = that.layMain.width() - that.layMain.prop('clientWidth'); // 纵向滚动条宽度
var scrollHeight = that.layMain.height() - that.layMain.prop('clientHeight'); // 横向滚动条高度
var getScrollWidth = that.getScrollWidth(that.layMain[0]); // 获取主容器滚动条宽度,如果有的话
var outWidth = layMainTable.outerWidth() - that.layMain.width(); // 表格内容器的超出宽度
// 添加补丁
var addPatch = function(elem){
if(scollWidth && scollHeight){
if(scrollWidth && scrollHeight){
elem = elem.eq(0);
if(!elem.find('.layui-table-patch')[0]){
var patchElem = $('<th class="layui-table-patch"><div class="layui-table-cell"></div></th>'); // 补丁元素
patchElem.find('div').css({
width: scollWidth
width: scrollWidth
});
elem.find('tr').append(patchElem);
}
@ -1817,7 +1817,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
// 固定列区域高度
var mainHeight = that.layMain.height();
var fixHeight = mainHeight - scollHeight;
var fixHeight = mainHeight - scrollHeight;
that.layFixed.find(ELEM_BODY).css(
'height',
@ -1832,7 +1832,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
](HIDE);
// 操作栏
that.layFixRight.css('right', scollWidth - 1);
that.layFixRight.css('right', scrollWidth - 1);
};
// 事件处理
@ -1972,7 +1972,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
printWin.document.write(style + html.prop('outerHTML'));
printWin.document.close();
if(layui.device('edg').edg){
printWin.onafterprint = printWin.close;
printWin.print();
@ -2319,7 +2319,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
].join(',');
if( $(e.target).is(UNROW) || $(e.target).closest(UNROW)[0]){
return;
};
}
setRowEvent.call(this, 'row');
}).on('dblclick', 'tr', function(){ // 双击行
setRowEvent.call(this, 'rowDouble');

Loading…
Cancel
Save