Skip to content

Commit

Permalink
Merge f0b69b9 into 5390f40
Browse files Browse the repository at this point in the history
  • Loading branch information
jpglmart committed Nov 8, 2021
2 parents 5390f40 + f0b69b9 commit 507b813
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/table/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export const cellStarts = {
// 这些选项不应该被覆盖
export const cellForced = {
selection: {
renderHeader: function(h, { store }) {
renderHeader: function(h, { store, column }) {
return <el-checkbox
disabled={ store.states.data && store.states.data.length === 0 }
disabled={ store.states.data && store.states.data.length === 0 || column.disabled }
indeterminate={ store.states.selection.length > 0 && !this.isAllSelected }
nativeOn-click={ this.toggleAllSelection }
nativeOn-click={ !column.disabled ? this.toggleAllSelection : ()=>{} }
value={ this.isAllSelected } />;
},
renderCell: function(h, { row, column, store, $index }) {
Expand Down
10 changes: 10 additions & 0 deletions packages/table/src/store/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ export default Vue.extend({
if (oldSelection.length) {
states.selection = [];
this.table.$emit('selection-change', []);
states.unselection = [];
this.table.$emit('unselection-change', []);
}
},

Expand Down Expand Up @@ -165,6 +167,14 @@ export default Vue.extend({
}
this.table.$emit('selection-change', newSelection);
}
if (!this.isSelected(row)) {
if (!this.states.unselection) this.states.unselection = [];
this.states.unselection.push(row);
} else if (this.states.unselection) {
let indx = this.states.unselection.findIndex(v => v.ns_id === row.ns_id);
this.states.unselection.splice(indx, indx >= 0 ? 1 : 0);
}
if (this.states.unselection && this.states.unselection.length > 0) this.table.$emit('unselection-change', this.states.unselection);
},

_toggleAllSelection() {
Expand Down
11 changes: 8 additions & 3 deletions packages/table/src/table-column.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ export default {
validator(val) {
return val.every(order => ['ascending', 'descending', null].indexOf(order) > -1);
}
},
disabled: {
type: Boolean,
default: false
}
},

Expand Down Expand Up @@ -195,13 +199,14 @@ export default {
},

registerNormalWatchers() {
const props = ['label', 'property', 'filters', 'filterMultiple', 'sortable', 'index', 'formatter', 'className', 'labelClassName', 'showOverflowTooltip'];
const props = ['label', 'property', 'filters', 'filterMultiple', 'sortable', 'index', 'formatter', 'className', 'labelClassName', 'showOverflowTooltip', 'disabled'];
// 一些属性具有别名
const aliases = {
prop: 'property',
realAlign: 'align',
realHeaderAlign: 'headerAlign',
realWidth: 'width'
realWidth: 'width',
disabled: 'disabled'
};
const allAliases = props.reduce((prev, cur) => {
prev[cur] = cur;
Expand Down Expand Up @@ -280,7 +285,7 @@ export default {

const basicProps = ['columnKey', 'label', 'className', 'labelClassName', 'type', 'renderHeader', 'formatter', 'fixed', 'resizable'];
const sortProps = ['sortMethod', 'sortBy', 'sortOrders'];
const selectProps = ['selectable', 'reserveSelection'];
const selectProps = ['selectable', 'reserveSelection', 'disabled'];
const filterProps = ['filterMethod', 'filters', 'filterMultiple', 'filterOpened', 'filteredValue', 'filterPlacement'];

let column = this.getPropsData(basicProps, sortProps, selectProps, filterProps);
Expand Down

0 comments on commit 507b813

Please sign in to comment.