From 1f5781e55f0b4b2277e84dd99bb8cb759a377ed0 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Mon, 27 Jun 2022 07:32:09 +0800 Subject: [PATCH] =?UTF-8?q?table=20=E5=A4=84=E7=90=86LAY=5FDISABLED?= =?UTF-8?q?=E5=9C=A8=E4=B8=80=E4=BA=9B=E7=89=B9=E6=AE=8A=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=A2=83=E6=AF=94=E5=A6=82=E5=BD=93=E5=89=8D=E9=A1=B5=E6=89=80?= =?UTF-8?q?=E6=9C=89=E8=AE=B0=E5=BD=95=E9=83=BD=E4=B8=8D=E5=8F=AF=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E7=9A=84=E6=97=B6=E5=80=99=E5=85=A8=E9=80=89=E6=A1=86?= =?UTF-8?q?=E7=9A=84=E7=8A=B6=E6=80=81=EF=BC=88disabled=E5=92=8Cchecked?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index d3eea9cf..bd017b68 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -997,8 +997,15 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){ that.renderForm(); typeof thisCheckedRowIndex === 'number' && that.setThisRowChecked(thisCheckedRowIndex); - that.syncCheckAll(); - + if (that.layBody.find('input[name="layTableCheckbox"]:not(:disabled)').length) { + // 当前有可操作的单项复选框才需要同步状态 + that.syncCheckAll(); + } else { + // 没有任何可操作的时候禁止全选框操作并且设置其选中状态 此时不宜用table.checkStatus获取是否全选状态 + form.render(that.layHeader.find('input[name="layTableCheckbox"]').prop('disabled', true) + .prop('checked', !that.layBody.find('input[name="layTableCheckbox"]:not(:checked)').length)); + } + //滚动条补丁 that.haveInit ? that.scrollPatch() : setTimeout(function(){ that.scrollPatch();