From cbfbc11dd8c0134c70c74cfe34142267bca5d001 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <470459819@qq.com> Date: Sun, 28 May 2023 12:39:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20table=20`setRowChecked`=20?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=97=A0=E6=B3=95=E8=A7=A6=E5=8F=91=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E7=9A=84=E4=BA=8B=E4=BB=B6=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 | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index 1712f5d7..62844c8d 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -1459,9 +1459,6 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ tr.addClass(ELEM_CLICK).siblings('tr').removeClass(ELEM_CLICK); } - // 仅设置样式状态 - if(opts.selectedStyle || selectedStyle) return; - // 同步数据选中属性值 var thisData = table.cache[that.key]; @@ -1475,13 +1472,28 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ }); // 若存在复选框或单选框,则标注选中样式 - tr.find('input[lay-type="'+ ({ + var checkedElem = tr.find('input[lay-type="'+ ({ radio: 'layTableRadio', checkbox: 'layTableCheckbox' }[opts.type] || 'checkbox') +'"]').prop('checked', opts.checked); that.syncCheckAll(); that.renderForm(opts.type); + + // 仅设置样式状态 + if(opts.selectedStyle || selectedStyle) return; + + layui.event.call( + checkedElem[0], + MOD_NAME, opts.type + '('+ options.elem.attr('lay-filter') +')', + that.commonMember.call(checkedElem[0], { + checked: opts.checked, + type: opts.index === 'all' ? 'all' : 'one', + getCol: function(){ // 获取当前列的表头配置信息 + return that.col(checkedElem.closest('td').data('key')); + } + }) + ); }; // 数据排序