From 7453b7c6b3b754b6d8fd452e53633279218818f7 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Thu, 4 May 2023 12:51:03 +0800 Subject: [PATCH 01/54] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20treeTable=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=9A=84=E8=8A=82=E7=82=B9=20icon=20?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E7=94=A8=E9=94=99=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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 40cf0f9d..1e59df4e 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -224,8 +224,8 @@ layui.define(['table'], function (exports) { flexIconOpen: '', // 打开时候的折叠图标 showIcon: true, // 是否显示图标(节点类型图标) icon: '', // 节点图标,如果设置了这个属性或者数据中有这个字段信息,不管打开还是关闭都以这个图标的值为准 - iconClose: '', // 打开时候的图标 - iconOpen: '', // 关闭时候的图标 + iconClose: '', // 关闭时候的图标 + iconOpen: '', // 打开时候的图标 iconLeaf: '', // 叶子节点的图标 showFlexIconIfNotParent: false, // 当节点不是父节点的时候是否显示折叠图标 dblClickExpand: true, // 双击节点时,是否自动展开父节点的标识 From 6bed8c86adec8dd5783035a020a8be1ac68d9c13 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Thu, 4 May 2023 12:58:06 +0800 Subject: [PATCH 02/54] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20treeTable=20`showIco?= =?UTF-8?q?n`=20=E4=B8=BA=20false=20=E7=9A=84=E4=B9=8B=E5=90=8E=E5=9C=A8?= =?UTF-8?q?=E6=9F=90=E4=BA=9B=E6=93=8D=E4=BD=9C=E4=B9=8B=E5=90=8E=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E5=9B=BE=E6=A0=87=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 | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 1e59df4e..2b71b02e 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -448,10 +448,8 @@ layui.define(['table'], function (exports) { flexIconElem.html(trExpand ? treeOptions.view.flexIconOpen : treeOptions.view.flexIconClose) trData[isParentKey] && flexIconElem.css('visibility', 'visible'); // 处理节点图标 - if (treeOptions.view.showIcon && trData[isParentKey] && !trData.icon && !treeOptions.view.icon) { - var nodeIconElem = trsElem.find('.layui-table-tree-nodeIcon'); - nodeIconElem.html(trExpand ? treeOptions.view.iconOpen : treeOptions.view.iconClose); - } + treeOptions.view.showIcon && trsElem.find('.layui-table-tree-nodeIcon:not(.layui-table-tree-iconCustom)') + .html(trExpand ? treeOptions.view.iconOpen : treeOptions.view.iconClose); var childNodes = trData[customName.children] || []; // 测试用后续需要改成子节点的字段名称 // 处理子节点展示与否 @@ -669,11 +667,9 @@ layui.define(['table'], function (exports) { that.updateStatus(null, {LAY_EXPAND: false}); // 只处理当前页,如果需要处理全部表格,需要用treeTable.updateStatus // 隐藏所有非顶层的节点 tableView.find('.layui-table-box tbody tr[data-level!="0"]').addClass(HIDE); - // 处理顶层节点的图标 - var trLevel0 = tableView.find('tbody tr[data-level="0"]'); - trLevel0.find('.layui-table-tree-flexIcon').html(treeOptions.view.flexIconClose); - treeOptions.view.showIcon && trLevel0.find('.layui-table-tree-nodeIcon').html(treeOptions.view.iconClose); + 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); } else { var tableDataFlat = treeTable.getData(id, true); // 展开所有 @@ -713,12 +709,11 @@ layui.define(['table'], function (exports) { // 如果全部节点已经都打开过,就可以简单处理跟隐藏所有节点反操作 if (isAllExpanded) { that.updateStatus(null, {LAY_EXPAND: true}); - // 隐藏所有非顶层的节点 + // 显示所有子节点 tableView.find('tbody tr[data-level!="0"]').removeClass(HIDE); - // 处理顶层节点的图标 - // var trLevel0 = tableView.find('tbody tr[data-level="0"]'); + // 处理节点的图标 tableView.find('.layui-table-tree-flexIcon').html(treeOptions.view.flexIconOpen); - tableView.find('.layui-table-tree-nodeIcon').html(treeOptions.view.iconOpen); + treeOptions.view.showIcon && tableView.find('.layui-table-tree-nodeIcon:not(.layui-table-tree-iconCustom)').html(treeOptions.view.iconOpen); } else { // 如果有未打开过的父节点,将内容全部生成 that.updateStatus(null, {LAY_EXPAND: true, LAY_HAS_EXPANDED: true}); @@ -730,7 +725,6 @@ layui.define(['table'], function (exports) { trs_fixed_r: $(trAll.trs_fixed_r.join('')) } layui.each(tableDataFlat, function (dataIndex, dataItem) { - // debugger; var dataLevel = dataItem[LAY_DATA_INDEX].split('-').length - 1; trAllObj.trs.eq(dataIndex).attr({ 'data-index': dataItem[LAY_DATA_INDEX], @@ -816,9 +810,8 @@ layui.define(['table'], function (exports) { '">', trData[LAY_EXPAND] ? treeOptions.view.flexIconOpen : treeOptions.view.flexIconClose, // 折叠图标 '', - '