From 3bcbdcfa426cafc0059eac8028be5914f3652624 Mon Sep 17 00:00:00 2001 From: wanghaoo Date: Tue, 4 Dec 2018 10:04:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E9=80=89=E9=83=BD=E4=B8=BAdisable?= =?UTF-8?q?=E6=97=B6=E5=85=A8=E9=80=89=E4=B8=8D=E5=8F=AF=E4=BB=A5=E7=82=B9?= =?UTF-8?q?=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/multiSelect.js | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/lib/multiSelect.js b/src/lib/multiSelect.js index cd10ccd..8d614de 100644 --- a/src/lib/multiSelect.js +++ b/src/lib/multiSelect.js @@ -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: ( ),