update Table
update Table
This commit is contained in:
parent
45e7ed7ef5
commit
cb31ede039
2 changed files with 41 additions and 16 deletions
|
@ -358,18 +358,32 @@
|
||||||
handleFilterHide (index) { // clear checked that not filter now
|
handleFilterHide (index) { // clear checked that not filter now
|
||||||
if (!this.cloneColumns[index]._isFiltered) this.cloneColumns[index]._filterChecked = [];
|
if (!this.cloneColumns[index]._isFiltered) this.cloneColumns[index]._filterChecked = [];
|
||||||
},
|
},
|
||||||
handleFilter (index) {
|
filterData (data, column) {
|
||||||
const column = this.cloneColumns[index];
|
return data.filter((row) => {
|
||||||
const filterData = this.makeData();
|
let status = !column._filterChecked.length;
|
||||||
|
|
||||||
this.rebuildData = filterData.filter((row) => {
|
|
||||||
let status = false;
|
|
||||||
for (let i = 0; i < column._filterChecked.length; i++) {
|
for (let i = 0; i < column._filterChecked.length; i++) {
|
||||||
status = column.filterMethod(column._filterChecked[i], row);
|
status = column.filterMethod(column._filterChecked[i], row);
|
||||||
if (status) break;
|
if (status) break;
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
filterOtherData (data, index) {
|
||||||
|
this.cloneColumns.forEach((col, colIndex) => {
|
||||||
|
if (colIndex !== index) {
|
||||||
|
data = this.filterData(data, col);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
handleFilter (index) {
|
||||||
|
const column = this.cloneColumns[index];
|
||||||
|
let filterData = this.makeData();
|
||||||
|
|
||||||
|
// filter others first, after filter this column
|
||||||
|
filterData = this.filterOtherData(filterData, index);
|
||||||
|
this.rebuildData = this.filterData(filterData, column);
|
||||||
|
|
||||||
this.cloneColumns[index]._isFiltered = true;
|
this.cloneColumns[index]._isFiltered = true;
|
||||||
this.cloneColumns[index]._filterVisible = false;
|
this.cloneColumns[index]._filterVisible = false;
|
||||||
},
|
},
|
||||||
|
@ -381,7 +395,10 @@
|
||||||
this.cloneColumns[index]._isFiltered = false;
|
this.cloneColumns[index]._isFiltered = false;
|
||||||
this.cloneColumns[index]._filterVisible = false;
|
this.cloneColumns[index]._filterVisible = false;
|
||||||
this.cloneColumns[index]._filterChecked = [];
|
this.cloneColumns[index]._filterChecked = [];
|
||||||
this.rebuildData = this.makeData();
|
|
||||||
|
let filterData = this.makeData();
|
||||||
|
filterData = this.filterOtherData(filterData, index);
|
||||||
|
this.rebuildData = filterData;
|
||||||
},
|
},
|
||||||
makeData () {
|
makeData () {
|
||||||
let data = deepCopy(this.data);
|
let data = deepCopy(this.data);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<!--<i-table size="large" border stripe :columns="columns" :data="data"></i-table>-->
|
<!--<i-table size="large" border stripe :columns="columns" :data="data"></i-table>-->
|
||||||
<br>
|
<br>
|
||||||
<i-table
|
<i-table
|
||||||
width="450"
|
width="850"
|
||||||
stripe
|
stripe
|
||||||
border
|
border
|
||||||
highlight-row
|
highlight-row
|
||||||
|
@ -55,20 +55,20 @@
|
||||||
width: 100,
|
width: 100,
|
||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
label: '大于25岁',
|
label: '两个字',
|
||||||
value: 1
|
value: 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '小于25岁',
|
label: '三个字',
|
||||||
value: 2
|
value: 2
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
filterMultiple: false,
|
filterMultiple: false,
|
||||||
filterMethod (value, row) {
|
filterMethod (value, row) {
|
||||||
if (value === 1) {
|
if (value === 1) {
|
||||||
return row.age >= 25;
|
return row.name.length == 2;
|
||||||
} else if (value === 2) {
|
} else if (value === 2) {
|
||||||
return row.age < 25;
|
return row.name.length == 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -103,14 +103,22 @@
|
||||||
width: 100,
|
width: 100,
|
||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
label: '家',
|
label: '大于25岁',
|
||||||
value: 'home'
|
value: 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '公司',
|
label: '小于25岁',
|
||||||
value: 'company'
|
value: 2
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
filterMultiple: false,
|
||||||
|
filterMethod (value, row) {
|
||||||
|
if (value === 1) {
|
||||||
|
return row.age >= 25;
|
||||||
|
} else if (value === 2) {
|
||||||
|
return row.age < 25;
|
||||||
|
}
|
||||||
|
}
|
||||||
// render (row) {
|
// render (row) {
|
||||||
// return `<i-button>${row.age}</i-button>`
|
// return `<i-button>${row.age}</i-button>`
|
||||||
// }
|
// }
|
||||||
|
|
Loading…
Add table
Reference in a new issue