From 0154c99fd8b29476b8ca9aad6184f86082f701b5 Mon Sep 17 00:00:00 2001 From: Diyar-IT <136627746+Diyar-IT@users.noreply.github.com> Date: Tue, 22 Aug 2023 15:22:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DtreeTable=E8=AE=BE=E7=BD=AEco?= =?UTF-8?q?ls=E7=9A=84type:=20'numbers'=E6=8A=98=E5=8F=A0=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复treeTable设置cols的type: 'numbers'折叠时不更新问题 --- src/modules/treeTable.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index a599b553..38b123a2 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -602,7 +602,11 @@ layui.define(['table'], function (exports) { options: options, }, true); } - }) + }); + treeTableThat.updateStatus(childNodes, function (d) { + d['LAY_HIDE'] = false; + }); + options.hasNumberCol && formatNumber(tableId); } else { var asyncSetting = treeOptions.async || {}; var asyncUrl = asyncSetting.url || options.url; @@ -760,6 +764,11 @@ layui.define(['table'], function (exports) { tableViewElem.find(childNodesFlat.map(function (value, index, array) { return 'tr[lay-data-index="' + value[LAY_DATA_INDEX] + '"]' }).join(',')).addClass(HIDE); + + treeTableThat.updateStatus(childNodes, function (d) { + d['LAY_HIDE'] = true; + }); + options.hasNumberCol && formatNumber(tableId); } } @@ -1029,13 +1038,14 @@ layui.define(['table'], function (exports) { }); } else { debounceFn('renderTreeTable-' + tableId, function () { - options.hasNumberCol && formatNumber(that); + options.hasNumberCol && formatNumber(tableId); form.render($('.layui-table-tree[lay-id="' + tableId + '"]')); }, 0)(); } } - var formatNumber = function (that) { + var formatNumber = function (id) { + var that = getThisTable(id); var options = that.getOptions(); var tableViewElem = options.elem.next(); @@ -1044,6 +1054,7 @@ layui.define(['table'], function (exports) { var trFixedL = tableViewElem.find('.layui-table-fixed-l tbody tr'); var trFixedR = tableViewElem.find('.layui-table-fixed-r tbody tr'); layui.each(that.treeToFlat(table.cache[options.id]), function (i1, item1) { + if (item1['LAY_HIDE']) return; var itemData = that.getNodeDataByIndex(item1[LAY_DATA_INDEX]); itemData['LAY_NUM'] = ++num; trMain.eq(i1).find('.laytable-cell-numbers').html(num); @@ -1242,7 +1253,7 @@ layui.define(['table'], function (exports) { layui.each(table.cache[id], function (i4, item4) { tableView.find('tr[data-level="0"][lay-data-index="' + item4[LAY_DATA_INDEX] + '"]').attr('data-index', i4); }) - options.hasNumberCol && formatNumber(that); + options.hasNumberCol && formatNumber(id); // 重新适配尺寸 treeTable.resize(id);