table修复多级表头存在自动分配宽度列的时候在某些场景下没有占满表格容器的问题;treeTable添加set方法用于设置全局默认属性。

pull/1224/head
sunxiaobin89 2023-04-10 15:55:55 +08:00
parent 9b945da25f
commit 9044647dc2
2 changed files with 19 additions and 11 deletions

View File

@ -811,13 +811,20 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
if(that.autoColNums > 0 && patchNums >= -colNums && patchNums <= colNums){
var getEndTh = function(th){
var field;
th = th || that.layHeader.eq(0).find('thead > tr:first-child > th:last-child')
field = th.data('field');
var field, thRet;
th = th || that.layHeader.eq(0).find('thead th:last-child')
layui.each(th, function (thIndex, thElem) {
thElem = $(thElem);
if (!thElem.children('.'+ELEM_GROUP).length) { // 排除合并表头
field = thElem.attr('data-field');
thRet = thElem;
}
})
if(!field && th.prev()[0]){
return getEndTh(th.prev())
}
return th
return thRet
};
var th = getEndTh();
var key = th.data('key');
@ -897,6 +904,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
table.cache[that.key] = []; //格式化缓存数据
that.syncCheckAll();
that.renderForm();
that.setColsWidth();
};
// 初始页码
@ -957,7 +966,6 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
}
// 检查数据格式是否符合规范
if(res[response.statusName] != response.statusCode){
that.renderForm();
that.errorView(
res[response.msgName] ||
('返回的数据不符合规范,正确的成功状态码应为:"'+ response.statusName +'": '+ response.statusCode)
@ -980,10 +988,6 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
}
,error: function(e, msg){
that.errorView('请求异常,错误提示:'+ msg);
that.renderForm();
that.setColsWidth();
typeof options.error === 'function' && options.error(e, msg);
}
});
@ -1269,7 +1273,6 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
//如果无数据
if(data.length === 0){
that.renderForm();
return that.errorView(options.text.none);
} else {
that.layFixLeft.removeClass(HIDE);

View File

@ -19,6 +19,11 @@ layui.define(['table'], function (exports) {
// 遍历字段
eachCols: table.eachCols,
index: table.index,
set: function(options){
var that = this;
that.config = $.extend({}, that.config, options);
return that;
},
};
// 操作当前实例
@ -1034,4 +1039,4 @@ layui.define(['table'], function (exports) {
};
exports(MOD_NAME, treeTable);
});
});