From 751c5cbe7b7169f414896e0a70673b950aeffabf Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <470459819@qq.com> Date: Mon, 28 Nov 2022 14:47:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtable=E6=9C=89=E5=9B=BA?= =?UTF-8?q?=E5=AE=9A=E5=88=97=E7=9A=84=E5=A4=8D=E6=9D=82=E8=A1=A8=E5=A4=B4?= =?UTF-8?q?=EF=BC=8C=E7=AD=9B=E9=80=89=E5=88=97=E4=B9=8B=E5=90=8E=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E7=9A=84=E5=9B=BA=E5=AE=9A=E5=88=97=E9=AB=98=E5=BA=A6?= =?UTF-8?q?=E8=B7=9F=E6=9C=AC=E4=BD=93=E4=B8=8D=E4=B8=80=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9Btable=E5=AD=97=E6=AE=B5=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=B0=E5=A2=9EfieldTitle=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E7=AD=9B=E9=80=89=E5=88=97=E5=92=8C=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E7=9A=84=E6=97=B6=E5=80=99=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E8=A1=A8=E5=A4=B4=E4=BF=A1=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index 9e407a1b..a36b2880 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -629,10 +629,10 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ hide ? parentColspan-- : parentColspan++; parentTh.attr('colspan', parentColspan); - parentTh[parentColspan < 1 ? 'addClass' : 'removeClass'](HIDE); - + parentTh[parentColspan >= 1 || !hide ? 'removeClass' : 'addClass'](HIDE); // 如果子列显示,父列必然需要显示 + getThisCol.colspan = parentColspan; //同步 colspan 参数 - getThisCol.hide = parentColspan < 1; //同步 hide 参数 + getThisCol.hide = parentColspan >= 1 || !hide; //同步 hide 参数 //递归,继续往上查询是否有父列 var nextParentKey = parentTh.data('parentkey'); @@ -1550,6 +1550,19 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ if (height < 135) height = 135; that.elem.css("height", height); } + + // debugger; + // 如果多级表头,则填补表头高度 + if(options.cols.length > 1){ + // 补全高度 + var th = that.layFixed.find(ELEM_HEADER).find('th'); + // 固定列表头同步跟本体 th 一致高度 + var headerMain = that.layHeader.first(); + layui.each(th, function (thIndex, thElem) { + thElem = $(thElem); + thElem.height(headerMain.find('th[data-key="' + thElem.attr('data-key') + '"]').height() + 'px'); + }) + } if(!height) return; @@ -1581,18 +1594,6 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ } else { that.layMain.outerHeight(bodyHeight); } - - // 如果多级表头,则填补表头高度 - if(options.cols.length > 1){ - // 补全高度 - var th = that.layFixed.find(ELEM_HEADER).find('th'); - // 固定列表头同步跟本体 th 一致高度 - var headerMain = that.layHeader.first(); - layui.each(th, function (thIndex, thElem) { - thElem = $(thElem); - thElem.height(headerMain.find('th[data-key="' + thElem.attr('data-key') + '"]').height() + 'px'); - }) - } }; //获取滚动条宽度 @@ -1725,6 +1726,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ ](HIDE); // 根据列的显示隐藏,同步多级表头的父级相关属性值 + debugger; if(hide != col.hide){ that.setParentCol(!checked, parentKey); }