Commit 0ad95539123bc5b877722f69625eee9d29d0d770
Committed by
GitHub
Merge pull request #5230 from bitqiang/2.0
优化 如果数据全部不可以选,表头的选择也禁用。
Showing
1 changed file
with
8 additions
and
2 deletions
Show diff stats
src/components/table/table-head.vue
@@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
16 | <span v-if="!column.renderHeader">{{ column.title || '' }}</span> | 16 | <span v-if="!column.renderHeader">{{ column.title || '' }}</span> |
17 | <render-header v-else :render="column.renderHeader" :column="column" :index="index"></render-header> | 17 | <render-header v-else :render="column.renderHeader" :column="column" :index="index"></render-header> |
18 | </template> | 18 | </template> |
19 | - <template v-else-if="column.type === 'selection'"><Checkbox :value="isSelectAll" :disabled="!data.length" @on-change="selectAll"></Checkbox></template> | 19 | + <template v-else-if="column.type === 'selection'"><Checkbox :value="isSelectAll" :disabled="isSelectDisabled" @on-change="selectAll"></Checkbox></template> |
20 | <template v-else> | 20 | <template v-else> |
21 | <span v-if="!column.renderHeader" :class="{[prefixCls + '-cell-sort']: column.sortable}" @click="handleSortByHead(getColumn(rowIndex, index)._index)">{{ column.title || '#' }}</span> | 21 | <span v-if="!column.renderHeader" :class="{[prefixCls + '-cell-sort']: column.sortable}" @click="handleSortByHead(getColumn(rowIndex, index)._index)">{{ column.title || '#' }}</span> |
22 | <render-header v-else :render="column.renderHeader" :column="column" :index="index"></render-header> | 22 | <render-header v-else :render="column.renderHeader" :column="column" :index="index"></render-header> |
@@ -61,7 +61,7 @@ | @@ -61,7 +61,7 @@ | ||
61 | </template> | 61 | </template> |
62 | </div> | 62 | </div> |
63 | </th> | 63 | </th> |
64 | - | 64 | + |
65 | <th v-if="$parent.showVerticalScrollBar && rowIndex===0" :class='scrollBarCellClass()' :rowspan="headRows.length"></th> | 65 | <th v-if="$parent.showVerticalScrollBar && rowIndex===0" :class='scrollBarCellClass()' :rowspan="headRows.length"></th> |
66 | </tr> | 66 | </tr> |
67 | </thead> | 67 | </thead> |
@@ -121,6 +121,12 @@ | @@ -121,6 +121,12 @@ | ||
121 | } else { | 121 | } else { |
122 | return [this.columns]; | 122 | return [this.columns]; |
123 | } | 123 | } |
124 | + }, | ||
125 | + isSelectDisabled () { | ||
126 | + let isSelectDisabled = false; | ||
127 | + if (!this.data.length) isSelectDisabled = true; | ||
128 | + if (!this.data.find(item => !item._disabled)) isSelectDisabled = true; | ||
129 | + return isSelectDisabled; | ||
124 | } | 130 | } |
125 | }, | 131 | }, |
126 | methods: { | 132 | methods: { |