From b2d789baae0325c2fc85f68bc20d0f085acfc61f Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <470459819@qq.com> Date: Thu, 4 May 2023 23:41:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20treeTable=20=E5=B1=95?= =?UTF-8?q?=E5=BC=80=E5=85=A8=E9=83=A8=E8=8A=82=E7=82=B9=E6=97=B6=E5=80=99?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=9B=BE=E6=A0=87=E5=87=BA=E9=94=99=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/treeTable.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 2b71b02e..1fe2f945 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -448,7 +448,7 @@ layui.define(['table'], function (exports) { flexIconElem.html(trExpand ? treeOptions.view.flexIconOpen : treeOptions.view.flexIconClose) trData[isParentKey] && flexIconElem.css('visibility', 'visible'); // 处理节点图标 - treeOptions.view.showIcon && trsElem.find('.layui-table-tree-nodeIcon:not(.layui-table-tree-iconCustom)') + 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); var childNodes = trData[customName.children] || []; // 测试用后续需要改成子节点的字段名称 @@ -669,7 +669,7 @@ layui.define(['table'], function (exports) { tableView.find('.layui-table-box tbody tr[data-level!="0"]').addClass(HIDE); tableView.find('.layui-table-tree-flexIcon').html(treeOptions.view.flexIconClose); - treeOptions.view.showIcon && tableView.find('.layui-table-tree-nodeIcon:not(.layui-table-tree-iconCustom)').html(treeOptions.view.iconClose); + treeOptions.view.showIcon && tableView.find('.layui-table-tree-nodeIcon:not(.layui-table-tree-iconCustom,.layui-table-tree-iconLeaf)').html(treeOptions.view.iconClose); } else { var tableDataFlat = treeTable.getData(id, true); // 展开所有 @@ -713,7 +713,7 @@ layui.define(['table'], function (exports) { tableView.find('tbody tr[data-level!="0"]').removeClass(HIDE); // 处理节点的图标 tableView.find('.layui-table-tree-flexIcon').html(treeOptions.view.flexIconOpen); - treeOptions.view.showIcon && tableView.find('.layui-table-tree-nodeIcon:not(.layui-table-tree-iconCustom)').html(treeOptions.view.iconOpen); + treeOptions.view.showIcon && tableView.find('.layui-table-tree-nodeIcon:not(.layui-table-tree-iconCustom,.layui-table-tree-iconLeaf)').html(treeOptions.view.iconOpen); } else { // 如果有未打开过的父节点,将内容全部生成 that.updateStatus(null, {LAY_EXPAND: true, LAY_HAS_EXPANDED: true}); @@ -780,7 +780,7 @@ layui.define(['table'], function (exports) { var dataExpand = {}; // 记录需要展开的数据 var nameKey = customName.name; - var indent = treeOptions.view.indent || 14; + var indent = treeOptionsView.indent || 14; layui.each(tableView.find('td[data-field="' + nameKey + '"]'), function (index, item) { item = $(item); var trElem = item.closest('tr'); @@ -808,10 +808,17 @@ layui.define(['table'], function (exports) { 'margin-left: ' + (indent * trElem.attr('data-level')) + 'px;', (trData[isParentKey] || treeOptionsView.showFlexIconIfNotParent) ? '' : ' visibility: hidden;', '">', - trData[LAY_EXPAND] ? treeOptions.view.flexIconOpen : treeOptions.view.flexIconClose, // 折叠图标 + trData[LAY_EXPAND] ? treeOptionsView.flexIconOpen : treeOptionsView.flexIconClose, // 折叠图标 '', - treeOptions.view.showIcon ? '
' : '', // 区分父子节点 + treeOptionsView.showIcon ? ' ' : '', // 区分父子节点 htmlTemp].join('')) // 图标要可定制 .find('.layui-table-tree-flexIcon'); @@ -827,7 +834,7 @@ layui.define(['table'], function (exports) { // 当前层的数据看看是否需要展开 sonSign !== false && layui.each(dataExpand, function (index, item) { var trDefaultExpand = tableViewElem.find('tr[lay-data-index="' + index + '"]'); - trDefaultExpand.find('.layui-table-tree-flexIcon').html(treeOptions.view.flexIconOpen); + trDefaultExpand.find('.layui-table-tree-flexIcon').html(treeOptionsView.flexIconOpen); expandNode({trElem: trDefaultExpand.first()}, true); });