Table: not emit triggers sort-change during initialization (#14625)

pull/15022/head
peanut 2019-04-22 16:22:31 +08:00 committed by hetech
parent b9c63eecf9
commit 1967cd2b9e
2 changed files with 7 additions and 4 deletions

View File

@ -210,7 +210,8 @@ export default {
mounted() {
const { prop, order } = this.defaultSort;
this.store.commit('sort', { prop, order });
const init = true;
this.store.commit('sort', { prop, order, init });
},
beforeDestroy() {

View File

@ -259,7 +259,7 @@ TableStore.prototype.mutations = {
changeSortCondition(states, options) {
states.data = sortData((states.filteredData || states._data || []), states);
if (!options || !options.silent) {
if (!options || !(options.silent || options.init)) {
this.table.$emit('sort-change', {
column: this.states.sortingColumn,
prop: this.states.sortProp,
@ -271,7 +271,7 @@ TableStore.prototype.mutations = {
},
sort(states, options) {
const { prop, order } = options;
const { prop, order, init } = options;
if (prop) {
states.sortProp = prop;
states.sortOrder = order || 'ascending';
@ -286,7 +286,9 @@ TableStore.prototype.mutations = {
}
if (states.sortingColumn) {
this.commit('changeSortCondition');
this.commit('changeSortCondition', {
init: init
});
}
});
}