From b79f66c529e96ebf7ad98029047f162c4d1fe3bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B2=81=E6=9C=88=E5=B0=8F=E5=81=B7?= <470459819@qq.com> Date: Wed, 8 Jun 2022 00:46:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=8D=E6=9D=82=E8=A1=A8?= =?UTF-8?q?=E5=A4=B4=E7=9A=84=E8=A1=A8=E6=A0=BC=E8=A1=A8=E5=A4=B4=E5=92=8C?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=88=97=E9=94=99=E4=BD=8D=E7=9A=84=E9=97=AE?= =?UTF-8?q?=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, 12 insertions(+), 10 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index 351fc16..32f2ae5 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -397,7 +397,9 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){ //初始化列参数 layui.each(options.cols, function(i1, item1){ layui.each(item1, function(i2, item2){ - + item2.colspan = item2.colspan || 1; + item2.rowspan = item2.rowspan || 1; + //如果列参数为空,则移除 if(!item2){ item1.splice(i2, 1); @@ -411,10 +413,10 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){ //如果是组合列,则捕获对应的子列 if(item2.colGroup || item2.colspan > 1){ var childIndex = 0; - layui.each(options.cols[i1 + 1], function(i22, item22){ + layui.each(options.cols[i1 + item2.rowspan], function(i22, item22){ //如果子列已经被标注为{HAS_PARENT},或者子列累计 colspan 数等于父列定义的 colspan,则跳出当前子列循环 - if(item22.HAS_PARENT || (childIndex > 1 && childIndex == item2.colspan)) return; - + if(item22.HAS_PARENT || (childIndex >= 1 && childIndex == item2.colspan)) return; + item22.HAS_PARENT = true; item22.parentKey = i1 + '-' + i2; @@ -1847,8 +1849,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){ var row = $.extend({ title: th.text() - ,colspan: th.attr('colspan') || 0 //列单元格 - ,rowspan: th.attr('rowspan') || 0 //行单元格 + ,colspan: th.attr('colspan') || 1 //列单元格 + ,rowspan: th.attr('rowspan') || 1 //行单元格 }, itemData); if(row.colspan < 2) cols.push(row); @@ -1902,11 +1904,11 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){ var childIndex = 0; index++ item2.CHILD_COLS = []; - - layui.each(cols[i1 + 1], function(i22, item22){ + + layui.each(cols[i1 + item2.rowspan], function(i22, item22){ //如果子列已经被标注为{PARENT_COL_INDEX},或者子列累计 colspan 数等于父列定义的 colspan,则跳出当前子列循环 - if(item22.PARENT_COL_INDEX || (childIndex > 1 && childIndex == item2.colspan)) return; - + if(item22.PARENT_COL_INDEX || (childIndex >= 1 && childIndex == item2.colspan)) return; + item22.PARENT_COL_INDEX = index; item2.CHILD_COLS.push(item22);