From 4cae7241d2849766632a4fbd656ae53238ccaa53 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <470459819@qq.com> Date: Thu, 3 Aug 2023 00:07:22 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20treeTable=20=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=93=8D=E4=BD=9C=E4=B9=8B=E5=90=8E=20`radio`=20?= =?UTF-8?q?=E5=88=97=E9=80=89=E4=B8=AD=E7=8A=B6=E6=80=81=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 01def596..51c2daca 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -1526,6 +1526,9 @@ layui.define(['table'], function (exports) { Class.prototype.updateCheckStatus = function (dataP, checked) { var that = this; var options = that.getOptions(); + if (!options.hasChecboxCol) { + return false; // 如果没有复选列则不需要更新状态 + } var treeOptions = options.tree; var tableId = options.id; var tableView = options.elem.next(); From 697b3ce7bffe376c362970c8b632a8c5c2d1518e Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <470459819@qq.com> Date: Sun, 13 Aug 2023 23:14:22 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=20treeTable=20`cascade`?= =?UTF-8?q?=20=E6=96=B0=E5=A2=9E=20`none`=20=E6=97=A0=E7=BA=A7=E8=81=94?= =?UTF-8?q?=E7=9A=84=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/treeTable.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 6e880337..0898be1f 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -78,6 +78,7 @@ layui.define(['table'], function (exports) { var LAY_EXPAND = 'LAY_EXPAND'; var LAY_HAS_EXPANDED = 'LAY_HAS_EXPANDED'; var LAY_ASYNC_STATUS = 'LAY_ASYNC_STATUS'; + var LAY_CASCADE = ['all', 'parent', 'children', 'none']; // 构造器 var Class = function (options) { @@ -204,7 +205,7 @@ layui.define(['table'], function (exports) { var that = this; var options = that.config; var cascade = options.tree.data.cascade; - if (cascade !== 'parent' && cascade !== 'children') { + if (LAY_CASCADE.indexOf(cascade) === -1) { options.tree.data.cascade = 'all'; // 超出范围的都重置为全联动 } @@ -1722,7 +1723,7 @@ layui.define(['table'], function (exports) { } } - var trs = that.updateStatus(trData ? [trData] : table.cache[tableId], checkedStatusFn, trData && treeOptions.data.cascade === 'parent'); + var trs = that.updateStatus(trData ? [trData] : table.cache[tableId], checkedStatusFn, trData && ['parent', 'none'].indexOf(treeOptions.data.cascade) !== -1); var checkboxElem = tableView.find(trs.map(function (value) { return 'tr[lay-data-index="' + value[LAY_DATA_INDEX] + '"] input[name="layTableCheckbox"]:not(:disabled)'; }).join(',')); From 917159cd1d55e6956d3cbb869b39855cece34a5e Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <470459819@qq.com> Date: Tue, 29 Aug 2023 02:35:12 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20table=20pullData=20?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=9C=A8=20renderData=20=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8B=E6=89=A7=E8=A1=8C=E4=BA=86=E5=A4=9A=E4=BD=99=E7=9A=84?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=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/table.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/table.js b/src/modules/table.js index 1b269ce1..db4f75f9 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -1001,7 +1001,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ curr: curr, count: res[response.countName], type: opts.type, - }), sort(), done(res, 'renderData'); + sort: true, + }), done(res, 'renderData'); } else if(options.url){ // Ajax请求 var params = {}; // 当 page 开启,默认自动传递 page、limit 参数 From c9d67979f506a37ac69d3ecb1215b22a360460d0 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <470459819@qq.com> Date: Tue, 29 Aug 2023 02:38:09 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20treeTable=20data=20?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E6=8E=92=E5=BA=8F=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E8=8A=82=E7=82=B9=E7=BB=93=E6=9E=84=E9=94=99?= =?UTF-8?q?=E4=B9=B1=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 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 291366b8..0696c86b 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -190,6 +190,9 @@ layui.define(['table'], function (exports) { indeterminate: !checkStatus.isAll && checkStatus.data.length }) } + if (!isRenderData && thatOptionsTemp.autoSort && thatOptionsTemp.initSort && thatOptionsTemp.initSort.type) { + treeTable.sort(id); + } that.renderTreeTable(tableView); @@ -909,7 +912,7 @@ layui.define(['table'], function (exports) { d[idKey] !== undefined && (that.status.expand[d[idKey]] = true); } }); - if (options.initSort && options.initSort.type && (!options.url || options.autoSort)) { + if (options.initSort && options.initSort.type && options.autoSort) { return treeTable.sort(id); } var trAll = table.getTrHtml(id, tableDataFlat); @@ -1126,7 +1129,8 @@ layui.define(['table'], function (exports) { Class.prototype.getTableData = function () { var that = this; var options = that.getOptions(); - return options.url ? table.cache[options.id] : options.data; + // return options.url ? table.cache[options.id] : options.data; + return table.cache[options.id]; } treeTable.updateStatus = function (id, statusObj, data) { @@ -1147,7 +1151,7 @@ layui.define(['table'], function (exports) { if(!that) return; var options = that.getOptions(); - if (!options.url || options.autoSort) { + if (options.autoSort) { that.initData(); treeTable.renderData(id); }