|
@@ -2,7 +2,7 @@ import Vue from 'vue';
|
|
|
import debounce from 'throttle-debounce/debounce';
|
|
|
import merge from 'element-ui/src/utils/merge';
|
|
|
import { hasClass, addClass, removeClass } from 'element-ui/src/utils/dom';
|
|
|
-import { orderBy, getColumnById, getRowIdentity } from './util';
|
|
|
+import { orderBy, getColumnById, getRowIdentity, getColumnByKey } from './util';
|
|
|
|
|
|
const sortData = (data, states) => {
|
|
|
const sortingColumn = states.sortingColumn;
|
|
@@ -238,17 +238,24 @@ TableStore.prototype.mutations = {
|
|
|
},
|
|
|
|
|
|
filterChange(states, options) {
|
|
|
- let { column, values, silent } = options;
|
|
|
+ let { column, values, silent, multi } = options;
|
|
|
if (values && !Array.isArray(values)) {
|
|
|
values = [values];
|
|
|
}
|
|
|
-
|
|
|
- const prop = column.property;
|
|
|
const filters = {};
|
|
|
|
|
|
- if (prop) {
|
|
|
- states.filters[column.id] = values;
|
|
|
- filters[column.columnKey || column.id] = values;
|
|
|
+ if (multi) {
|
|
|
+ column.forEach(col => {
|
|
|
+ states.filters[col.id] = values;
|
|
|
+ filters[col.columnKey || col.id] = values;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ const prop = column.property;
|
|
|
+
|
|
|
+ if (prop) {
|
|
|
+ states.filters[column.id] = values;
|
|
|
+ filters[column.columnKey || column.id] = values;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
let data = states._data;
|
|
@@ -495,7 +502,7 @@ TableStore.prototype.cleanSelection = function() {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-TableStore.prototype.clearFilter = function() {
|
|
|
+TableStore.prototype.clearFilter = function(columnKeys) {
|
|
|
const states = this.states;
|
|
|
const { tableHeader, fixedTableHeader, rightFixedTableHeader } = this.table.$refs;
|
|
|
let panels = {};
|
|
@@ -507,17 +514,36 @@ TableStore.prototype.clearFilter = function() {
|
|
|
const keys = Object.keys(panels);
|
|
|
if (!keys.length) return;
|
|
|
|
|
|
- keys.forEach(key => {
|
|
|
- panels[key].filteredValue = [];
|
|
|
- });
|
|
|
+ if (typeof columnKeys === 'string') {
|
|
|
+ columnKeys = [columnKeys];
|
|
|
+ }
|
|
|
+ if (Array.isArray(columnKeys)) {
|
|
|
+ const columns = columnKeys.map(key => getColumnByKey(states, key));
|
|
|
+ keys.forEach(key => {
|
|
|
+ const column = columns.find(col => col.id === key);
|
|
|
+ if (column) {
|
|
|
+ panels[key].filteredValue = [];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.commit('filterChange', {
|
|
|
+ column: columns,
|
|
|
+ value: [],
|
|
|
+ silent: true,
|
|
|
+ multi: true
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ keys.forEach(key => {
|
|
|
+ panels[key].filteredValue = [];
|
|
|
+ });
|
|
|
|
|
|
- states.filters = {};
|
|
|
+ states.filters = {};
|
|
|
|
|
|
- this.commit('filterChange', {
|
|
|
- column: {},
|
|
|
- values: [],
|
|
|
- silent: true
|
|
|
- });
|
|
|
+ this.commit('filterChange', {
|
|
|
+ column: {},
|
|
|
+ values: [],
|
|
|
+ silent: true
|
|
|
+ });
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
TableStore.prototype.clearSort = function() {
|