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