优化 table 内部选中值的相关想法

pull/1267/head
贤心 2023-05-30 09:52:51 +08:00
parent 82e0740423
commit d8789d68d5
1 changed files with 17 additions and 9 deletions

View File

@ -1576,10 +1576,10 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
} }
}; };
//请求loading // 请求 loading
Class.prototype.loading = function(hide){ Class.prototype.loading = function(hide){
var that = this var that = this;
,options = that.config; var options = that.config;
if(options.loading){ if(options.loading){
if(hide){ if(hide){
that.layInit && that.layInit.remove(); that.layInit && that.layInit.remove();
@ -1594,14 +1594,22 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
} }
}; };
//同步选中值状态 // 同步选中值状态
Class.prototype.setCheckData = function(index, checked){ Class.prototype.setCheckData = function(index, checked, radio){
var that = this var that = this;
,options = that.config var options = that.config;
,thisData = table.cache[that.key]; var thisData = table.cache[that.key];
if(!thisData[index]) return; if(!thisData[index]) return;
if(layui.type(thisData[index]) === 'array') return; if(layui.type(thisData[index]) === 'array') return;
thisData[index][options.checkName] = checked;
layui.each(thisData, function(i, item){
if(index === i){
item[options.checkName] = checked;
} else if(radio) { // 是否单选
delete item[options.checkName];
}
});
}; };
// 同步全选按钮状态 // 同步全选按钮状态