@@ -1560,8 +1560,9 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
15601560 Class . prototype . setRowChecked = function ( opts ) {
15611561 var that = this ;
15621562 var options = that . config ;
1563+ var isCheckAll = opts . index === 'all' ;
15631564 var tr = that . layBody . find ( 'tr' + (
1564- opts . index === 'all' ? '' : '[data-index="' + opts . index + '"]'
1565+ isCheckAll ? '' : '[data-index="' + opts . index + '"]'
15651566 ) ) ;
15661567
15671568 // 默认属性
@@ -1580,12 +1581,13 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
15801581 // 设置数据选中属性
15811582 layui . each ( thisData , function ( i , item ) {
15821583 if ( layui . type ( item ) === 'array' || item [ options . disabledName ] ) return ; // 空项
1583- if ( Number ( opts . index ) === i || opts . index === 'all' ) {
1584+ if ( Number ( opts . index ) === i || isCheckAll ) {
15841585 var checked = item [ options . checkName ] = getChecked ( item [ options . checkName ] ) ;
1585- tr [ checked ? 'addClass' : 'removeClass' ] ( ELEM_CHECKED ) ; // 标记当前选中行背景色
1586+ var currTr = isCheckAll ? tr . filter ( '[data-index="' + i + '"]' ) : tr ;
1587+ currTr [ checked ? 'addClass' : 'removeClass' ] ( ELEM_CHECKED ) ; // 标记当前选中行背景色
15861588 // 若为 radio 类型,则取消其他行选中背景色
15871589 if ( opts . type === 'radio' ) {
1588- tr . siblings ( ) . removeClass ( ELEM_CHECKED ) ;
1590+ currTr . siblings ( ) . removeClass ( ELEM_CHECKED ) ;
15891591 }
15901592 } else if ( opts . type === 'radio' ) {
15911593 delete item [ options . checkName ] ;
0 commit comments