// data查询条件,在这里是个对象
getDataList(data) {
var dept = data.budgetDeptName;
var employee = data.budgetEmployeeName;
var account = data.budgetAccountName;
// 当条件是空的情况
if (dept == "" && employee == "" && account == "") {
// this.dataListCopy 备份的查询结果
this.totalPage = this.dataListCopy.length;
return this.dataList = this.dataListCopy;
} else {
// 三个条件可以不分先后顺序依次筛选
if(account != "") {
this.dataList = this.dataList.filter(p => !!p.budgetAccountName ? p.budgetAccountName.indexOf(account) > -1 : '');
}
if(dept != "") {
this.dataList = this.dataList.filter(p => !!p.budgetDeptName ? p.budgetDeptName.indexOf(dept) > -1 : '');
}
if(employee != "") {
this.dataList = this.dataList.filter(p => !!p.budgetEmployeeName ? p.budgetEmployeeName.indexOf(employee) > -1 : '');
}
}
// 因为用到了前台分页,在这里给出总条数
this.totalPage = this.dataList.length;
},
前端实现多条件筛选
于 2021-12-13 21:35:51 首次发布