添加 remoteFilter方法,支持用户远程筛选数据
This commit is contained in:
parent
15b72d31b0
commit
12bcf7bd14
2 changed files with 47 additions and 1 deletions
|
@ -15,7 +15,28 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '年龄',
|
title: '年龄',
|
||||||
key: 'age'
|
key: 'age',
|
||||||
|
filters:[
|
||||||
|
{
|
||||||
|
label: '小学',
|
||||||
|
value: '小学'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '中学',
|
||||||
|
value: '大学'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '中学',
|
||||||
|
value: '中学'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
filterRemote:function(value,key,column){
|
||||||
|
var that = this;
|
||||||
|
this.$Notice.open({title:`正在远程过滤${key}`,desc:value,duration:3,onClose:function(){
|
||||||
|
that.remoteFilter(value,key,column)
|
||||||
|
}})
|
||||||
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '地址',
|
title: '地址',
|
||||||
|
@ -45,6 +66,23 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
methods:{
|
||||||
|
remoteFilter:function(val,age,column){
|
||||||
|
this.data1 = [
|
||||||
|
{
|
||||||
|
name: '模拟1',
|
||||||
|
age: 18,
|
||||||
|
address: '北京市朝阳区芍药居'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '模拟2',
|
||||||
|
age: 25,
|
||||||
|
address: '北京市海淀区西二旗'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -496,6 +496,9 @@
|
||||||
},
|
},
|
||||||
filterData (data, column) {
|
filterData (data, column) {
|
||||||
return data.filter((row) => {
|
return data.filter((row) => {
|
||||||
|
if(typeof column.filterRemote == 'function'){ //如果定义了远程过滤方法则忽略此方法
|
||||||
|
return true;
|
||||||
|
}
|
||||||
let status = !column._filterChecked.length;
|
let status = !column._filterChecked.length;
|
||||||
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);
|
||||||
|
@ -505,6 +508,11 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
filterOtherData (data, index) {
|
filterOtherData (data, index) {
|
||||||
|
let column = this.cloneColumns[index];
|
||||||
|
if(typeof column.filterRemote == 'function'){
|
||||||
|
column.filterRemote.call(this.currentContext,column._filterChecked,column.key,column);
|
||||||
|
}
|
||||||
|
|
||||||
this.cloneColumns.forEach((col, colIndex) => {
|
this.cloneColumns.forEach((col, colIndex) => {
|
||||||
if (colIndex !== index) {
|
if (colIndex !== index) {
|
||||||
data = this.filterData(data, col);
|
data = this.filterData(data, col);
|
||||||
|
|
Loading…
Add table
Reference in a new issue