From 1ecefbabca9bb65bcbe7049a8880cc1bc6472315 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Sat, 6 Aug 2022 02:11:34 +0800 Subject: [PATCH 1/5] =?UTF-8?q?table=20=E4=BF=AE=E5=A4=8D=E5=A4=9A?= =?UTF-8?q?=E7=BA=A7=E8=A1=A8=E5=A4=B4=E9=9A=90=E8=97=8F=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=88=97=E9=87=8D=E8=BD=BD=E4=B9=8B=E5=90=8E=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E9=9A=90=E8=97=8F=E7=9A=84=E5=88=97=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E5=87=BA=E7=8E=B0=E7=9A=84=E9=94=99=E5=88=97=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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index 0e301342..fadb6159 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -491,8 +491,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){ item2.key = i1 + '-' + i2; item2.hide = item2.hide || false; - item2.colspan = item2.colspan || 1; - item2.rowspan = item2.rowspan || 1; + item2.colspan = item2.colspan || 0; + item2.rowspan = item2.rowspan || 0; //根据列类型,定制化参数 that.initOpts(item2); @@ -2140,8 +2140,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){ var row = $.extend({ title: th.text() - ,colspan: th.attr('colspan') || 1 //列单元格 - ,rowspan: th.attr('rowspan') || 1 //行单元格 + ,colspan: th.attr('colspan') || 0 //列单元格 + ,rowspan: th.attr('rowspan') || 0 //行单元格 }, itemData); if(row.colspan < 2) cols.push(row); From 19871595bb024b133843f5668a6f1f7d8c8da644 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Sun, 7 Aug 2022 01:15:27 +0800 Subject: [PATCH 2/5] =?UTF-8?q?table=20=E4=BF=AE=E5=A4=8D=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E9=97=AE=E9=A2=98=E4=BB=A5=E5=8F=8A=E5=8A=A0=E5=BC=BA?= =?UTF-8?q?=E5=92=8C=E5=B9=B6=E5=88=97=E8=A1=A8=E5=A4=B4=E7=9A=84=E5=AE=BD?= =?UTF-8?q?=E5=BA=A6=E8=87=AA=E9=80=82=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/layui.css | 2 +- src/modules/table.js | 54 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/css/layui.css b/src/css/layui.css index 12ba1d30..f4c406b1 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -900,7 +900,7 @@ a cite{font-style: normal; *cursor:pointer;} /* 小表格 */ .layui-table[lay-size="sm"] th, .layui-table[lay-size="sm"] td{padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-size: 12px;} -.layui-table-view .layui-table[lay-size="sm"] .layui-table-cell{height: 30px; line-height: 20px; padding-top: 5px; padding-right: 5px;} +.layui-table-view .layui-table[lay-size="sm"] .layui-table-cell{height: 30px; line-height: 20px; padding-top: 5px; padding-right: 15px;} /* 数据表格 */ .layui-table[lay-data]{display: none;} diff --git a/src/modules/table.js b/src/modules/table.js index fadb6159..840ad933 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -154,7 +154,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){ return ''; }() ,'{{# var isSort = !(item2.colGroup) && item2.sort; }}' - ,'' + ,'' ,'
'); + lis.push('
  • '); } }); return lis.join(''); @@ -1721,6 +1761,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){ var setWidth = dict.ruleWidth + e.clientX - dict.offset[0]; if(setWidth < dict.minWidth) setWidth = dict.minWidth; dict.rule.style.width = setWidth + 'px'; + thisTable.that[thisTable.eventMoveElem.closest('.' + ELEM_VIEW).attr('lay-id')].setGroupWidth(); layer.close(that.tipsIndex); } } @@ -1728,7 +1769,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){ if(thisTable.eventMoveElem){ dict = {}; _BODY.css('cursor', ''); - that.scrollPatch(); + thisTable.that[thisTable.eventMoveElem.closest('.' + ELEM_VIEW).attr('lay-id')].scrollPatch(); // 清除当前拖拽信息 thisTable.eventMoveElem.removeData(DATA_MOVE_NAME); @@ -1920,11 +1961,12 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){ var field = othis.parent().data('field'); var index = othis.parents('tr').eq(0).data('index'); var data = table.cache[that.key][index]; - + var oldValue = data[field]; data[field] = value; // 更新缓存中的值 layui.event.call(this, MOD_NAME, 'edit('+ filter +')', commonMember.call(this, { value: value ,field: field + ,oldValue: oldValue })); }).on('blur', '.'+ELEM_EDIT, function(){ var othis = $(this); From 2bf2493a1d00cc94f531e162a6e3b88b48e17da2 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Sun, 7 Aug 2022 01:26:55 +0800 Subject: [PATCH 3/5] =?UTF-8?q?table=20=E4=BF=AE=E5=A4=8D=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E9=97=AE=E9=A2=98=E4=BB=A5=E5=8F=8A=E5=8A=A0=E5=BC=BA?= =?UTF-8?q?=E5=92=8C=E5=B9=B6=E5=88=97=E8=A1=A8=E5=A4=B4=E7=9A=84=E5=AE=BD?= =?UTF-8?q?=E5=BA=A6=E8=87=AA=E9=80=82=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/table.js b/src/modules/table.js index 840ad933..4908b6d0 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -644,7 +644,6 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){ if (options.cols.length > 1) { for (var i = options.cols.length - 1; i >= 0; i--) { // 自下向上处理合并表头的宽度 - debugger; layui.each(that.layHeader.first().find('tr').eq(i).find('>th>div.laytable-cell-group'), function (i1, item1) { item1 = $(item1); var thElem = item1.parent(); From 5b37d0165c146e6e73a79dc8e621b9711ce0b414 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Sun, 7 Aug 2022 01:47:04 +0800 Subject: [PATCH 4/5] =?UTF-8?q?table=20=E4=BF=AE=E5=A4=8D=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E9=97=AE=E9=A2=98=E4=BB=A5=E5=8F=8A=E5=8A=A0=E5=BC=BA?= =?UTF-8?q?=E5=92=8C=E5=B9=B6=E5=88=97=E8=A1=A8=E5=A4=B4=E7=9A=84=E5=AE=BD?= =?UTF-8?q?=E5=BA=A6=E8=87=AA=E9=80=82=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/layui.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/css/layui.css b/src/css/layui.css index f4c406b1..51ffc0ae 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -900,7 +900,7 @@ a cite{font-style: normal; *cursor:pointer;} /* 小表格 */ .layui-table[lay-size="sm"] th, .layui-table[lay-size="sm"] td{padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-size: 12px;} -.layui-table-view .layui-table[lay-size="sm"] .layui-table-cell{height: 30px; line-height: 20px; padding-top: 5px; padding-right: 15px;} +.layui-table-view .layui-table[lay-size="sm"] .layui-table-cell{height: 30px; line-height: 20px; padding-top: 5px; padding-left: 5px; padding-right: 5px;} /* 数据表格 */ .layui-table[lay-data]{display: none;} From e585a20964c845d3cdfce31b1368fe6f2755a5d3 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <470459819@qq.com> Date: Mon, 8 Aug 2022 16:59:47 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BC=98=E5=8C=96setGroupWidth=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E6=8F=90=E9=AB=98=E6=8B=96=E5=8A=A8=E6=94=B9?= =?UTF-8?q?=E5=8F=98=E5=88=97=E5=AE=BD=E6=97=B6=E5=80=99=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E8=A1=A8=E5=A4=B4=E5=AE=BD=E5=BA=A6=E8=B0=83=E6=95=B4=E7=9A=84?= =?UTF-8?q?=E6=95=88=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index 4908b6d0..25cd0f60 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -638,17 +638,18 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){ }; // 设置合并表头的宽度 - Class.prototype.setGroupWidth = function () { + Class.prototype.setGroupWidth = function (thElem) { var that = this; var options = that.config; + var parentKey; if (options.cols.length > 1) { - for (var i = options.cols.length - 1; i >= 0; i--) { + for (var i = thElem ? thElem.closest('tr').index() - 1 : options.cols.length - 1; i >= 0; i--) { // 自下向上处理合并表头的宽度 - layui.each(that.layHeader.first().find('tr').eq(i).find('>th>div.laytable-cell-group'), function (i1, item1) { + parentKey = thElem ? thElem.attr('data-parentkey') : ''; + layui.each(that.layHeader.first().find('tr').eq(i).find('>th' + (parentKey && '[data-key="' + that.index + '-' + parentKey + '"]') + '>div.laytable-cell-group'), function (i1, item1) { item1 = $(item1); - var thElem = item1.parent(); var width = 0; - var key = thElem.attr('data-key'); + var key = item1.parent().attr('data-key'); layui.each(that.layHeader.first().find('th[data-parentkey="' + key.substr(key.indexOf('-') + 1) + '"]'), function (i2, item2) { item2 = $(item2); if (item2.hasClass(HIDE)) { @@ -656,8 +657,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){ } width += item2.children('div.layui-table-cell').outerWidth(); }); - // item1.outerWidth(width); that.layHeader.find('th[data-key="'+key+'"]').children('div.layui-table-cell').outerWidth(width); + thElem && (thElem = item1.parent()); }) } @@ -1760,7 +1761,7 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){ var setWidth = dict.ruleWidth + e.clientX - dict.offset[0]; if(setWidth < dict.minWidth) setWidth = dict.minWidth; dict.rule.style.width = setWidth + 'px'; - thisTable.that[thisTable.eventMoveElem.closest('.' + ELEM_VIEW).attr('lay-id')].setGroupWidth(); + thisTable.that[thisTable.eventMoveElem.closest('.' + ELEM_VIEW).attr('lay-id')].setGroupWidth(thisTable.eventMoveElem); layer.close(that.tipsIndex); } }