修改设置多选上限后, 不能取消的问题
This commit is contained in:
maplemei 2019-09-30 15:14:05 +08:00
parent 6feee42b47
commit 583caf1179
2 changed files with 12 additions and 12 deletions

2
dist/xm-select.js vendored

File diff suppressed because one or more lines are too long

View File

@ -139,17 +139,6 @@ class Framework extends Component{
//如果是禁用状态, 不能进行操作
if(disabled) return;
//查看是否设置了多选上限
let maxCount = toNum(max);
if(maxCount > 0 && sels.length >= maxCount){
this.updateBorderColor(theme.maxColor);
//恢复正常
setTimeout(() => this.updateBorderColor(''), 300);
//查看是否需要回调
maxMethod && isFunction(maxMethod) && maxMethod(sels, item);
return ;
}
//如果现在是选中状态
if(selected && (!repeat || mandatoryDelete)){
let index = sels.findIndex(sel => sel[valueProp] == item[valueProp])
@ -158,6 +147,17 @@ class Framework extends Component{
this.setState({ sels });
}
}else{
//查看是否设置了多选上限
let maxCount = toNum(max);
if(maxCount > 0 && sels.length >= maxCount){
this.updateBorderColor(theme.maxColor);
//恢复正常
setTimeout(() => this.updateBorderColor(''), 300);
//查看是否需要回调
maxMethod && isFunction(maxMethod) && maxMethod(sels, item);
return ;
}
//如果是单选模式
if(radio){
this.setState({ sels: [item] });