From f86ef95201a1c426747ba8599906dcc0ff8c2fda Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Mon, 27 Jun 2022 21:55:06 +0800 Subject: [PATCH] =?UTF-8?q?table=20=E4=BF=AE=E5=A4=8D=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=AD=98=E5=9C=A8hide=E5=AD=97=E6=AE=B5=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99table.eachCols=E9=83=A8=E5=88=86=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E6=B2=A1=E6=9C=89=E9=81=8D=E5=8E=86=E5=88=B0=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index 90a1b0ea..d8d52f50 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -2077,13 +2077,21 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){ // 找到它的子列所在cols的下标 var i2 = i1 + (parseInt(item2.rowspan) || 1); layui.each(cols[i2], function (i22, item22) { - //如果子列已经被标注为{PARENT_COL_INDEX},或者子列累计 colspan 数等于父列定义的 colspan,则跳出当前子列循环 - if (item22.PARENT_COL_INDEX || (childIndex >= 1 && childIndex == (item2.colspan || 1))) return; - item22.PARENT_COL_INDEX = index; - - item2.CHILD_COLS.push(item22); - childIndex = childIndex + (item22.hide ? 0 : parseInt(item22.colspan > 1 ? item22.colspan : 1)); - eachChildCols(index, cols, i2, item22); + if (item22.parentKey) { // 如果字段信息中包含了parentKey和key信息 + if (item22.parentKey === item2.key) { + item22.PARENT_COL_INDEX = index; + item2.CHILD_COLS.push(item22); + eachChildCols(index, cols, i2, item22); + } + } else { + // 没有key信息以colspan数量所谓判断标准 + //如果子列已经被标注为{PARENT_COL_INDEX},或者子列累计 colspan 数等于父列定义的 colspan,则跳出当前子列循环 + if (item22.PARENT_COL_INDEX || (childIndex >= 1 && childIndex == (item2.colspan || 1))) return; + item22.PARENT_COL_INDEX = index; + item2.CHILD_COLS.push(item22); + childIndex = childIndex + (item22.hide ? 0 : parseInt(item22.colspan > 1 ? item22.colspan : 1)); + eachChildCols(index, cols, i2, item22); + } }); } };