diff --git a/src/components/table/cell.vue b/src/components/table/cell.vue index 6e91625..8e68af4 100644 --- a/src/components/table/cell.vue +++ b/src/components/table/cell.vue @@ -2,7 +2,7 @@
@@ -19,6 +19,7 @@ naturalIndex: Number, // index of rebuildData index: Number, // _index of data checked: Boolean, + disabled:Boolean, fixed: { type: [Boolean, String], default: false diff --git a/src/components/table/table-body.vue b/src/components/table/table-body.vue index b6bb8d3..e543ccc 100644 --- a/src/components/table/table-body.vue +++ b/src/components/table/table-body.vue @@ -19,7 +19,9 @@ :column="column" :natural-index="index" :index="row._index" - :checked="rowChecked(row._index)"> + :checked="rowChecked(row._index)" + :disabled="rowDisabled(row._index)" + > @@ -51,13 +53,17 @@ this.rowClsName(_index), { [`${this.prefixCls}-row-highlight`]: this.objData[_index] && this.objData[_index]._isHighlight, - [`${this.prefixCls}-row-hover`]: this.objData[_index] && this.objData[_index]._isHover + [`${this.prefixCls}-row-hover`]: this.objData[_index] && this.objData[_index]._isHover, + [`${this.prefixCls}-row-disabled`]: this.objData[_index] && this.objData[_index]._isDisabled } ]; }, rowChecked (_index) { return this.objData[_index] && this.objData[_index]._isChecked; }, + rowDisabled(_index){ + return this.objData[_index] && this.objData[_index]._isDisabled; + }, rowClsName (_index) { return this.$parent.rowClassName(this.objData[_index], _index); }, diff --git a/src/components/table/table.vue b/src/components/table/table.vue index 50a700e..9f3e325 100644 --- a/src/components/table/table.vue +++ b/src/components/table/table.vue @@ -392,7 +392,12 @@ }, selectAll (status) { this.rebuildData.forEach((data) => { - this.objData[data._index]._isChecked = status; + if(this.objData[data._index]._isDisabled){ + this.objData[data._index]._isChecked = false + }else{ + this.objData[data._index]._isChecked = status; + } + }); const selection = this.getSelection(); @@ -558,6 +563,12 @@ } else { newRow._isHighlight = false; } + + if(newRow._disabled){ + newRow._isDisabled = newRow._disabled; + }else{ + newRow._isDisabled = false; + } data[index] = newRow; }); return data; diff --git a/src/styles/components/table.less b/src/styles/components/table.less index 576deb5..20a84bb 100644 --- a/src/styles/components/table.less +++ b/src/styles/components/table.less @@ -209,6 +209,14 @@ } } + &-row-disabled, + tr&-row-disabled, + { + td{ + background-color: @table-td-disabled-ng; + } + } + &-fixed, &-fixed-right{ position: absolute; top: 0; diff --git a/src/styles/custom.less b/src/styles/custom.less index fb3367f..3e51cfd 100644 --- a/src/styles/custom.less +++ b/src/styles/custom.less @@ -43,6 +43,7 @@ @table-td-stripe-bg : #f5f7f9; @table-td-hover-bg : #ebf7ff; @table-td-highlight-bg : #ebf7ff; +@table-td-disabled-ng : #c3cbd6; @menu-dark-active-bg : #313540; @date-picker-cell-hover-bg : #e1f0fe; diff --git a/test/routers/table.vue b/test/routers/table.vue index be1f25c..b55a79b 100644 --- a/test/routers/table.vue +++ b/test/routers/table.vue @@ -66,7 +66,8 @@ name: '李小红', age: 30, address: '上海市浦东新区世纪大道', - _checked: true + _checked: false, + _disabled: true }, { name: '周小伟', -- libgit2 0.21.4