From afda133ef7a9e3cbed180f51ee063bf520e0d1d8 Mon Sep 17 00:00:00 2001 From: XuYang <14706323104@163.com> Date: Tue, 6 Aug 2024 17:39:15 +0800 Subject: [PATCH] =?UTF-8?q?bootstrapTreeTable=E5=A2=9E=E5=8A=A0=E3=80=90re?= =?UTF-8?q?memberExpanded=EF=BC=9A=E8=AE=B0=E4=BD=8F=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E5=89=8D=E8=A1=8C=E7=9A=84=E5=B1=95=E5=BC=80=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E3=80=91=E9=85=8D=E7=BD=AE=E9=A1=B9=EF=BC=8C=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2=E5=90=8E?= =?UTF-8?q?=E6=A0=91=E8=A1=A8=E4=BC=9A=E6=81=A2=E5=A4=8D=E4=B8=BA=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E5=89=8D=E7=9A=84=E5=B1=95=E5=BC=80=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/static/ruoyi/js/ry-ui.js | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js index 1d8bc88aa..27900752b 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js @@ -616,7 +616,8 @@ var table = { showRefresh: true, showColumns: true, expandAll: true, - expandFirst: true + expandFirst: true, + rememberExpanded: false }; var options = $.extend(defaults, options); table.options = options; @@ -644,8 +645,9 @@ var table = { showColumns: options.showColumns, // 是否显示隐藏某列下拉框 expandAll: options.expandAll, // 是否全部展开 expandFirst: options.expandFirst, // 是否默认第一级展开--expandAll为false时生效 + rememberExpanded: options.rememberExpanded, // 是否记住已展开的行信息 columns: options.columns, // 显示列信息(*) - onClickRow: options.onClickRow, // 单击某行事件 + onClickRow: $.treeTable.onClickRow, // 单击某行事件 responseHandler: $.treeTable.responseHandler, // 在加载服务器发送来的数据之前处理函数 onLoadSuccess: $.treeTable.onLoadSuccess // 当所有数据被加载时触发处理函数 }); @@ -668,6 +670,17 @@ var table = { }); return distinct ? $.common.uniqueFn(rows) : rows; }, + // 单击某行事件 + onClickRow: function(item) { + if (table.options.rememberExpanded){ + sessionStorage.setItem('ryExpandedRows', $('span[class*="glyphicon-chevron-down"]').map(function() { + return $(this).closest('tr').attr('data-id'); + }).get().toString()); + } + if (typeof table.options.onClickRow == "function") { + table.options.onClickRow(item); + } + }, // 请求获取数据后处理回调函数,校验异常状态提醒 responseHandler: function(res) { if (typeof table.options.responseHandler == "function") { @@ -682,6 +695,14 @@ var table = { }, // 当所有数据被加载时触发 onLoadSuccess: function(data) { + if (table.options.rememberExpanded){ + let storedValue = sessionStorage.getItem('ryExpandedRows'); + if ($.common.isNotEmpty(storedValue)){ + for (let id of storedValue.split(",")) { + $("tr[data-id='" + id +"']").find('span[class*="glyphicon-chevron-right"]').click(); + } + } + } if (typeof table.options.onLoadSuccess == "function") { table.options.onLoadSuccess(data); }