多选都为disable时全选不可以点击

This commit is contained in:
wanghaoo 2018-12-04 10:04:26 +08:00
parent f6a9a2dac6
commit 3bcbdcfa42
1 changed files with 28 additions and 7 deletions

View File

@ -91,21 +91,31 @@ export default function multiSelect(Table, Checkbox) {
if(checkedAll){ if(checkedAll){
check = false; check = false;
}else{ }else{
if(indeterminate){ // if(indeterminate){
// check = true;
// }else{
// check = true;
// }
check = true; check = true;
}else{
check = true;
}
} }
let selectList = []; let selectList = [];
data.forEach(item => { data.forEach(item => {
if(!item._disabled){
item._checked = check; item._checked = check;
}
if(item._checked){ if(item._checked){
selectList.push(item); selectList.push(item);
} }
}); });
if(selectList.length > 0){
indeterminate = true;
}else{
indeterminate = false;
}
this.setState({ this.setState({
indeterminate:false, indeterminate:indeterminate,
checkedAll:check checkedAll:check
}); });
this.props.getSelectedDataFunc(selectList); this.props.getSelectedDataFunc(selectList);
@ -137,12 +147,23 @@ export default function multiSelect(Table, Checkbox) {
getDefaultColumns=(columns)=>{ getDefaultColumns=(columns)=>{
let {checkedAll,indeterminate} = this.state; let {checkedAll,indeterminate} = this.state;
let checkAttr = {checked:checkedAll?true:false}; let checkAttr = {checked:checkedAll?true:false};
const data = this.props.data;
const dataLength = data.length;
let disabledCount = 0;
indeterminate?checkAttr.indeterminate = true:""; indeterminate?checkAttr.indeterminate = true:"";
//设置表头Checkbox是否可以点击
data.forEach((item,index,arr)=>{
if(item._disabled){
disabledCount++;
}
})
let _defaultColumns =[{ let _defaultColumns =[{
title: ( title: (
<Checkbox <Checkbox
className="table-checkbox" className="table-checkbox"
{...checkAttr} {...checkAttr}
disabled={disabledCount==dataLength?true:false}
onChange={this.onAllCheckChange} onChange={this.onAllCheckChange}
/> />
), ),