修改设置多选上限后, 不能取消的问题
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,6 +139,14 @@ class Framework extends Component{
//如果是禁用状态, 不能进行操作
if(disabled) return;
//如果现在是选中状态
if(selected && (!repeat || mandatoryDelete)){
let index = sels.findIndex(sel => sel[valueProp] == item[valueProp])
if(index != -1){
sels.splice(index, 1);
this.setState({ sels });
}
}else{
//查看是否设置了多选上限
let maxCount = toNum(max);
if(maxCount > 0 && sels.length >= maxCount){
@ -150,14 +158,6 @@ class Framework extends Component{
return ;
}
//如果现在是选中状态
if(selected && (!repeat || mandatoryDelete)){
let index = sels.findIndex(sel => sel[valueProp] == item[valueProp])
if(index != -1){
sels.splice(index, 1);
this.setState({ sels });
}
}else{
//如果是单选模式
if(radio){
this.setState({ sels: [item] });