From be07581d63d02679430ab01f53e758789694721b Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Tue, 30 May 2023 18:07:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20treeTable=20expandAll=20?= =?UTF-8?q?=E5=B1=95=E5=BC=80=E5=85=A8=E9=83=A8=E4=B9=8B=E5=90=8E=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E7=9A=84=E6=8A=98=E5=8F=A0=E7=8A=B6=E6=80=81=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E8=AE=B0=E5=BF=86=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/treeTable.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 92a90c84..96220df3 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -146,7 +146,7 @@ layui.define(['table'], function (exports) { } // 处理节点状态 updateStatus(retData[dataName], function (item) { - item[LAY_EXPAND] = that.status.expand[item[idKey]] + item[LAY_EXPAND] = LAY_EXPAND in item ? item[LAY_EXPAND] : (item[idKey] !== undefined && that.status.expand[item[idKey]]) }, childrenKey); if (parseDataThat.autoSort && parseDataThat.initSort && parseDataThat.initSort.type) { @@ -561,8 +561,9 @@ layui.define(['table'], function (exports) { treeOptions.view.showIcon && trsElem .find('.layui-table-tree-nodeIcon:not(.layui-table-tree-iconCustom,.layui-table-tree-iconLeaf)') .html(trExpand ? treeOptions.view.iconOpen : treeOptions.view.iconClose); - - treeTableThat.status.expand[trData[customName.id]] = trData[LAY_EXPAND] = trExpand; + trData[LAY_EXPAND] = trExpand; + var trDataId = trData[customName.id]; + trDataId !== undefined && (treeTableThat.status.expand[trDataId] = trExpand); if (retValue === null) { return retValue; } @@ -964,7 +965,7 @@ layui.define(['table'], function (exports) { trElem = tableViewElem.find('tr[lay-data-index="' + trIndex + '"]'); var trData = treeTableThat.getNodeDataByIndex(trIndex); - if (trData[LAY_EXPAND]) { + if (trData[LAY_EXPAND] && trData[isParentKey]) { // 需要展开 dataExpand = dataExpand || {}; dataExpand[trIndex] = true; @@ -1360,7 +1361,7 @@ layui.define(['table'], function (exports) { } // 删除已经存在的同级节点以及他们的子节点,并且把中间节点的已展开过的状态设置为false that.updateStatus(childrenNodes, function (d) { - if (d[isParentKey]) { + if (d[isParentKey] || treeOptions.view.showFlexIconIfNotParent) { d[LAY_HAS_EXPANDED] = false; } });