From 451a1df48b1da58cb7c125731f99b53eab99bccf Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Wed, 14 Jun 2023 11:38:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20treeTable=20`expandAllDefa?= =?UTF-8?q?ult`=20=E6=98=AF=E5=90=A6=E9=BB=98=E8=AE=A4=E5=B1=95=E5=BC=80?= =?UTF-8?q?=E5=85=A8=E9=83=A8=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, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 0da38eac..c5cc0f6c 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -230,6 +230,7 @@ layui.define(['table'], function (exports) { id: "id", // 唯一标识的属性名称 pid: "parentId", // 父节点唯一标识的属性名称 icon: "icon", // 图标的属性名称 + expandAllDefault: false, // 默认展开所有节点 }, view: { indent: 14, // 层级缩进量 @@ -738,6 +739,7 @@ layui.define(['table'], function (exports) { } } } else { + treeTableThat.isExpandAll = false; // 关闭 if (sonSign && !isToggle) { // 非状态切换的情况下 layui.each(childNodes, function (i1, item1) { @@ -812,8 +814,9 @@ layui.define(['table'], function (exports) { } var that = getThisTable(id); - if(!that) return; + if (!that) return; + that.isExpandAll = expandFlag; var options = that.getOptions(); var treeOptions = options.tree; var tableView = options.elem.next(); @@ -1014,6 +1017,10 @@ layui.define(['table'], function (exports) { }); }); + if (!level && treeOptions.view.expandAllDefault && that.isExpandAll === undefined) { + return treeTable.expandAll(tableId, true); // 默认展开全部 + } + // 当前层的数据看看是否需要展开 if (sonSign !== false && dataExpand) { layui.each(dataExpand, function (index, item) {