From 58f7c19ca526e3d79b32dcfb5044a2661081e8e1 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Mon, 27 Jun 2022 06:15:29 +0800 Subject: [PATCH] =?UTF-8?q?table=20=E4=BF=AE=E5=A4=8DLAY=5FDISABLED?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E7=9A=84=E4=B8=80=E4=BA=9B=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/json/table/demo1.json | 3 ++- src/modules/table.js | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/json/table/demo1.json b/examples/json/table/demo1.json index e53682f6..ae07a368 100644 --- a/examples/json/table/demo1.json +++ b/examples/json/table/demo1.json @@ -29,7 +29,8 @@ ,"checkin": "106" ,"joinTime": "2016-10-14" ,"LAY_CHECKED": true - }, { + ,"LAY_DISABLED": true +}, { "id": "10003" ,"username": "苏轼" ,"email": "test3@email.com" diff --git a/src/modules/table.js b/src/modules/table.js index dd6a1ccc..d3eea9cf 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -1724,8 +1724,10 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){ //全选 if(isAll){ childs.each(function(i, item){ - item.checked = checked; - that.setCheckData(i, checked); + if (!item.disabled) { + item.checked = checked; + that.setCheckData(i, checked); + } }); that.syncCheckAll(); that.renderForm('checkbox'); @@ -2113,14 +2115,13 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){ //计算全选个数 layui.each(data, function(i, item){ - if(layui.type(item) === 'array'){ + if(layui.type(item) === 'array' || item[table.config.disabledName]){ // 不可操作的节点对于统计来说也属于无效 invalidNum++; //无效数据,或已删除的 - return; } if(item[table.config.checkName]){ - nums++; + arr.push(table.clearCacheKey(item)); if(!item[table.config.disabledName]){ - arr.push(table.clearCacheKey(item)); + nums++; } } });