From 60e1ebae8cc8600244b92db17d0d9f49359a7358 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Tue, 23 May 2023 16:57:41 +0800 Subject: [PATCH 01/15] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20treeTable=20?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E6=8A=98=E5=8F=A0=E7=8A=B6=E6=80=81=E8=AE=B0?= =?UTF-8?q?=E5=BF=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/treeTable.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index c3bd6958..9bff8b5e 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -106,9 +106,13 @@ layui.define(['table'], function (exports) { var updateOptions = function (id, options, reload) { var that = getThisTable(id); - var thatOptionsTemp = $.extend(true, {} , that.getOptions(), options); + reload === 'reloadData' || (that.status = { // 用于记录一些状态信息 + expand: {} // 折叠状态 + }); + var thatOptionsTemp = $.extend(true, {}, that.getOptions(), options); var treeOptions = thatOptionsTemp.tree; var childrenKey = treeOptions.customName.children; + var idKey = treeOptions.customName.id; // 处理属性 delete options.hasNumberCol; delete options.hasChecboxCol; @@ -141,6 +145,10 @@ layui.define(['table'], function (exports) { if (treeOptions.data.isSimpleData && !treeOptions.async.enable) { // 异步加载和 isSimpleData 不应该一起使用 retData[dataName] = that.flatToTree(retData[dataName]); } + // 处理节点状态 + updateStatus(retData[dataName], function (item) { + item[LAY_EXPAND] = that.status.expand[item[idKey]] + }, childrenKey); if (parseDataThat.autoSort && parseDataThat.initSort && parseDataThat.initSort.type) { layui.sort(retData[dataName], parseDataThat.initSort.field, parseDataThat.initSort.type === 'desc', true) @@ -943,7 +951,7 @@ layui.define(['table'], function (exports) { }); // 根据需要处理options中的一些参数 - updateOptions(that.config.id, options, true); + updateOptions(that.config.id, options, type || true); // 对参数进行深度或浅扩展 that.config = $.extend(deep, {}, that.config, options); From 33d87d9840d9723ac7c3f0ec13f88d0b41a770eb Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Tue, 23 May 2023 17:12:12 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20treeTable=20?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=9B=BE=E6=A0=87=E7=9A=84=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/treeTable.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 9bff8b5e..f5705f6b 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -229,6 +229,7 @@ layui.define(['table'], function (exports) { name: "name", // 节点数据保存节点名称的属性名称 id: "id", // 唯一标识的属性名称 pid: "parentId", // 父节点唯一标识的属性名称 + icon: "icon", // 图标的属性名称 }, view: { indent: 14, // 层级缩进量 From 1d87009241cb1501fbd501c91100e447965142fb Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Tue, 23 May 2023 17:14:40 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20treeTable=20`isSimpl?= =?UTF-8?q?eData`=20=E6=A8=A1=E5=BC=8F=E6=B8=B2=E6=9F=93=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=A1=BA=E5=BA=8F=E8=B7=9F=E5=8E=9F=E5=A7=8B?= =?UTF-8?q?=E5=B1=9E=E4=BA=8E=E4=B8=8D=E5=90=8C=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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index f5705f6b..dc6f7a0e 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -279,14 +279,18 @@ layui.define(['table'], function (exports) { // 创建一个空的 nodes 对象,用于保存所有的节点 var nodes = {}; // 遍历所有节点,将其加入 nodes 对象中 + var idTemp = ''; layui.each(flatArr, function (index, item) { - nodes[item[idKey]] = $.extend({}, item); - nodes[item[idKey]][childrenKey] = []; + idTemp = idKey + item[idKey]; + nodes[idTemp] = $.extend({}, item); + nodes[idTemp][childrenKey] = []; }) // 遍历所有节点,将其父子关系加入 nodes 对象 + var pidTemp = ''; layui.each(nodes, function (index, item) { - if (item[pIdKey] && nodes[item[pIdKey]]) { - nodes[item[pIdKey]][childrenKey].push(item); + pidTemp = idKey + item[pIdKey]; + if (pidTemp && nodes[pidTemp]) { + nodes[pidTemp][childrenKey].push(item); } }) // 返回顶层节点 From 504b6c78fe04be1025e2717c78cb18799bebe225 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Tue, 23 May 2023 17:23:09 +0800 Subject: [PATCH 04/15] =?UTF-8?q?=E4=BC=98=E5=8C=96=20treeTable=20`checkSt?= =?UTF-8?q?atus`=20=E6=96=B0=E5=A2=9E=E7=AC=AC=E4=BA=8C=E4=B8=AA=E5=8F=82?= =?UTF-8?q?=E6=95=B0=20includeHalfCheck=20=E6=94=AF=E6=8C=81=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=9A=84=E9=80=89=E4=B8=AD=E8=8A=82=E7=82=B9=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=8C=85=E6=8B=AC=E5=8D=8A=E9=80=89=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E7=9A=84=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/treeTable.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index dc6f7a0e..c821b7ce 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -1290,19 +1290,20 @@ layui.define(['table'], function (exports) { } // 获取表格选中状态 - treeTable.checkStatus = function (id) { + treeTable.checkStatus = function (id, includeHalfCheck) { var that = getThisTable(id); - if(!that) return; + if (!that) return; + var checkName = table.config.checkName; // 需要区分单双选 var tableData = treeTable.getData(id, true); var checkedData = tableData.filter(function (value, index, array) { - return value[table.config.checkName]; + return value[checkName] || (includeHalfCheck && value[LAY_CHECKBOX_HALF]); }); var isAll = true; layui.each(table.cache[id], function (i1, item1) { - if (!item1[table.config.checkName]) { + if (!item1[checkName]) { isAll = false; return true; } From 2d7b9c020ee1eb20be770cd462e658de1df2ebc7 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Tue, 23 May 2023 18:08:35 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20treeTable=20?= =?UTF-8?q?=E5=B1=95=E5=BC=80=E5=85=A8=E9=83=A8=E8=8A=82=E7=82=B9=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E6=97=B6=E6=95=88=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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index c821b7ce..f0b21c79 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -474,9 +474,15 @@ 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,.layui-table-tree-iconLeaf)') + 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; + if (retValue === null) { + return retValue; + } + var childNodes = trData[customName.children] || []; // 处理子节点展示与否 if (trExpand) { @@ -485,7 +491,6 @@ layui.define(['table'], function (exports) { trsElem.nextAll(childNodes.map(function (value, index, array) { return 'tr[lay-data-index="' + value[LAY_DATA_INDEX] + '"]' }).join(',')).removeClass(HIDE); - trData[LAY_EXPAND] = trExpand; layui.each(childNodes, function (i1, item1) { if (!item1[isParentKey]) { return; From 1b31ba87fc35e58fb7712c5dd73b4c9aa240118a Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Wed, 24 May 2023 14:52:47 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E4=BC=98=E5=8C=96=20treeTable=20?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=8E=92=E5=BA=8F=E5=92=8C=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E5=86=85=E8=A1=A8=E5=8D=95=E5=88=9D=E5=A7=8B=E5=8C=96=E7=9A=84?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/treeTable.js | 51 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index f0b21c79..0484b448 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -10,7 +10,6 @@ layui.define(['table'], function (exports) { var form = layui.form; var table = layui.table; var hint = layui.hint(); - var timer = {}; // 记录定时器 index // api var treeTable = { @@ -427,7 +426,9 @@ layui.define(['table'], function (exports) { var debounceFn = (function () { var fn = {}; return function (tableId, func, wait) { - fn[tableId] = fn[tableId] || layui.debounce(func, wait); + if (!fn[tableId]) { + fn[tableId] = layui.debounce(func, wait); + } return fn[tableId]; } })() @@ -667,13 +668,15 @@ layui.define(['table'], function (exports) { }).join(',')).addClass(HIDE); } } - debounceFn(tableId, function () { + + + debounceFn('resize-' + tableId, function () { treeTable.resize(tableId); - }, 25)(); + }, 0)(); if (callbackFlag && trData[LAY_ASYNC_STATUS] !== 'loading') { var onExpand = treeOptions.callback.onExpand; - layui.type(onExpand) === 'function' && onExpand(tableId, trData, expandFlag); + layui.type(onExpand) === 'function' && onExpand(tableId, trData, trExpand); } return retValue; @@ -908,14 +911,18 @@ 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(treeOptionsView.flexIconOpen); - expandNode({trElem: trDefaultExpand.first()}, true); - }); - - options.hasNumberCol && that.formatNumber(tableId); - form.render(null, tableFilterId); + if (sonSign !== false && dataExpand) { + layui.each(dataExpand, function (index, item) { + var trDefaultExpand = tableViewElem.find('tr[lay-data-index="' + index + '"]'); + trDefaultExpand.find('.layui-table-tree-flexIcon').html(treeOptionsView.flexIconOpen); + expandNode({trElem: trDefaultExpand.first()}, true); + }); + } else { + debounceFn('renderTreeTable-' + tableId, function () { + options.hasNumberCol && formatNumber(that); + form.render(null, tableFilterId); + }, 0)(); + } } var formatNumber = function (that) { @@ -923,24 +930,18 @@ layui.define(['table'], function (exports) { var tableViewElem = options.elem.next(); var num = 0; + var trMain = tableViewElem.find('.layui-table-main tbody tr'); + 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 (layui.isArray(item1)) { - return; - } var itemData = that.getNodeDataByIndex(item1[LAY_DATA_INDEX]); itemData['LAY_NUM'] = ++num; - tableViewElem.find('tr[lay-data-index="' + item1[LAY_DATA_INDEX] + '"] .laytable-cell-numbers').html(itemData['LAY_NUM']); + trMain.eq(i1).find('.laytable-cell-numbers').html(num); + trFixedL.eq(i1).find('.laytable-cell-numbers').html(num); + trFixedR.eq(i1).find('.laytable-cell-numbers').html(num); }) } - Class.prototype.formatNumber = function (id) { - var that = this; - clearTimeout(id); - timer[id] = setTimeout(function () { - formatNumber(that); - }, 10) - } - // 树表渲染 Class.prototype.render = function (type) { var that = this; From 394f34efce5bf8fca1de3eafb986ac985b094024 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Wed, 24 May 2023 15:02:34 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20treeTable=20?= =?UTF-8?q?=E6=8A=98=E5=8F=A0=E5=8F=B6=E5=AD=90=E8=8A=82=E7=82=B9=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=8A=98=E5=8F=A0=E5=9B=BE=E6=A0=87=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=8F=98=E5=8C=96=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 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 0484b448..636eab6a 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -453,9 +453,6 @@ layui.define(['table'], function (exports) { var isToggle = layui.type(expandFlag) !== 'boolean'; var trExpand = isToggle ? !trData[LAY_EXPAND] : expandFlag; var retValue = trData[isParentKey] ? trExpand : null; - if (retValue === null) { - return retValue; - } if (callbackFlag && trExpand != trData[LAY_EXPAND] && (!trData[LAY_ASYNC_STATUS] || trData[LAY_ASYNC_STATUS] === 'local')) { var beforeExpand = treeOptions.callback.beforeExpand; @@ -580,7 +577,6 @@ layui.define(['table'], function (exports) { }); return retValue; } - trData[LAY_EXPAND] = trExpand; trExpanded = trData[LAY_HAS_EXPANDED] = true; if (childNodes.length) { // 判断是否需要排序 @@ -646,7 +642,6 @@ layui.define(['table'], function (exports) { } } } else { - trData[LAY_EXPAND] = trExpand; // 关闭 if (sonSign && !isToggle) { // 非状态切换的情况下 layui.each(childNodes, function (i1, item1) { @@ -740,7 +735,9 @@ 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,.layui-table-tree-iconLeaf)').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); // 展开所有 From 5b54593d840fb6e101a770bea46dc14ae4d541a5 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Wed, 24 May 2023 16:46:56 +0800 Subject: [PATCH 08/15] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20treeTable=20`expandA?= =?UTF-8?q?ll`=20=E5=B1=95=E5=BC=80=E8=8A=82=E7=82=B9=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E5=87=BA=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 | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 636eab6a..15d362a8 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -784,15 +784,20 @@ 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,.layui-table-tree-iconLeaf)').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 { - // 如果有未打开过的父节点,将内容全部生成 + // 如果有未打开过的父节点,将 tr 内容全部重新生成 that.updateStatus(null, function (d) { if (d[isParentKey]) { d[LAY_EXPAND] = true; d[LAY_HAS_EXPANDED] = true; } - }); // {LAY_EXPAND: true, LAY_HAS_EXPANDED: true}); + }); + if (options.initSort && options.initSort.type && (!options.url || options.autoSort)) { + return treeTable.sort(id); + } var trAll = table.getTrHtml(id, tableDataFlat); var trAllObj = { @@ -800,23 +805,17 @@ layui.define(['table'], function (exports) { trs_fixed: $(trAll.trs_fixed.join('')), trs_fixed_r: $(trAll.trs_fixed_r.join('')) } + var props; layui.each(tableDataFlat, function (dataIndex, dataItem) { var dataLevel = dataItem[LAY_DATA_INDEX].split('-').length - 1; - trAllObj.trs.eq(dataIndex).attr({ + props = { 'data-index': dataItem[LAY_DATA_INDEX], 'lay-data-index': dataItem[LAY_DATA_INDEX], 'data-level': dataLevel - }) - trAllObj.trs_fixed.eq(dataIndex).attr({ - 'data-index': dataItem[LAY_DATA_INDEX], - 'lay-data-index': dataItem[LAY_DATA_INDEX], - 'data-level': dataLevel - }) - trAllObj.trs_fixed_r.eq(dataIndex).attr({ - 'data-index': dataItem[LAY_DATA_INDEX], - 'lay-data-index': dataItem[LAY_DATA_INDEX], - 'data-level': dataLevel - }) + }; + trAllObj.trs.eq(dataIndex).attr(props) + trAllObj.trs_fixed.eq(dataIndex).attr(props) + trAllObj.trs_fixed_r.eq(dataIndex).attr(props) }) layui.each(['main', 'fixed-l', 'fixed-r'], function (i, item) { tableView.find('.layui-table-' + item + ' tbody').html(trAllObj[['trs', 'trs_fixed', 'trs_fixed_r'][i]]); From cdd8934d6dfdd06bed16e61e6ea1ddc45bec8074 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Wed, 24 May 2023 16:52:57 +0800 Subject: [PATCH 09/15] =?UTF-8?q?=E4=BC=98=E5=8C=96=20treeTable=20?= =?UTF-8?q?=E6=A0=91=E8=A1=A8=E8=8A=82=E7=82=B9=E6=B8=B2=E6=9F=93=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/treeTable.js | 45 +++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 15d362a8..27492c5e 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -623,9 +623,7 @@ layui.define(['table'], function (exports) { tableViewElem.find(ELEM_FIXR).find('tbody tr[lay-data-index="' + dataIndex + '"]').after(str2Obj.trs_fixed_r); // 初始化新增的节点中的内容 - layui.each(str2Obj, function (key, item) { - treeTableThat.renderTreeTable(item, dataLevelNew); - }) + treeTableThat.renderTreeTable(str2Obj.trs, dataLevelNew); if (sonSign && !isToggle) { // 非状态切换的情况下 // 级联展开/关闭子节点 @@ -830,7 +828,7 @@ layui.define(['table'], function (exports) { var that = this; var options = that.getOptions(); var tableViewElem = options.elem.next(); - tableViewElem.addClass(TABLE_TREE); + !tableViewElem.hasClass(TABLE_TREE) && tableViewElem.addClass(TABLE_TREE); var tableId = options.id; var treeOptions = options.tree || {}; var treeOptionsData = treeOptions.data || {}; @@ -853,7 +851,7 @@ layui.define(['table'], function (exports) { }) } - var dataExpand = {}; // 记录需要展开的数据 + var dataExpand = null; // 记录需要展开的数据 var nameKey = customName.name; var indent = treeOptionsView.indent || 14; layui.each(tableView.find('td[data-field="' + nameKey + '"]'), function (index, item) { @@ -863,21 +861,26 @@ layui.define(['table'], function (exports) { if (itemCell.hasClass('layui-table-tree-item')) { return; } - itemCell.addClass('layui-table-tree-item'); var trIndex = trElem.attr('lay-data-index'); if (!trIndex) { // 排除在统计行中的节点 return; } + trElem = tableViewElem.find('tr[lay-data-index="' + trIndex + '"]'); var trData = treeTableThat.getNodeDataByIndex(trIndex); + if (trData[LAY_EXPAND]) { // 需要展开 + dataExpand = dataExpand || {}; dataExpand[trIndex] = true; } + if (trData[LAY_CHECKBOX_HALF]) { + trElem.find('input[type="checkbox"][name="layTableCheckbox"]').prop('indeterminate', true); + } - var tableCellElem = item.find('div.layui-table-cell'); - var htmlTemp = tableCellElem.html(); - - var flexIconElem = item.find('div.layui-table-cell') + var htmlTemp = itemCell.html(); + itemCell = trElem.find('td[data-field="' + nameKey + '"]>div.layui-table-cell'); + itemCell.addClass('layui-table-tree-item'); + var flexIconElem = itemCell .html(['