forked from github/dataease
Merge pull request #5707 from dataease/pr@dev@perf_filter_vague_search
perf(过滤器): 下拉过滤器模糊搜索选项忽略大小写
This commit is contained in:
commit
78cc58929b
@ -410,7 +410,7 @@ export default {
|
||||
},
|
||||
_filterFun(value, data, node) {
|
||||
if (!value) return true
|
||||
return data[this.propsLabel].indexOf(value) !== -1
|
||||
return data[this.propsLabel?.toLocaleUpperCase()].indexOf(value.toLocaleUpperCase()) !== -1
|
||||
},
|
||||
_treeNodeClickFun(data, node, vm) {
|
||||
const { multiple } = this.selectParams
|
||||
|
@ -121,7 +121,7 @@ export default {
|
||||
},
|
||||
keyWord(val, old) {
|
||||
if (val === old) return
|
||||
const results = val ? this.list.filter(item => item.text.includes(val)) : null
|
||||
const results = val ? this.vagueFilter(val, this.list) : null
|
||||
this.resetList(results)
|
||||
this.reCacularHeight()
|
||||
this.$nextTick(() => {
|
||||
@ -136,6 +136,11 @@ export default {
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
vagueFilter(val, nodes) {
|
||||
if (!val || !val.trim()) return nodes
|
||||
const results = nodes.filter(item => item.text?.toLocaleUpperCase().includes(val.toLocaleUpperCase()))
|
||||
return results
|
||||
},
|
||||
resetSelectAll() {
|
||||
this.selectAll = false
|
||||
},
|
||||
@ -148,7 +153,7 @@ export default {
|
||||
selectAllChange(val) {
|
||||
let vals = val ? [...this.list.map(ele => ele.id)] : []
|
||||
if (this.keyWord.trim() && val) {
|
||||
vals = this.list.filter(item => item.text.includes(this.keyWord.trim())).map(ele => ele.id)
|
||||
vals = this.vagueFilter(this.keyWord.trim(), this.list).map(ele => ele.id)
|
||||
}
|
||||
this.visualChange(vals)
|
||||
this.selectValue = vals
|
||||
@ -233,14 +238,14 @@ export default {
|
||||
isAllSelect() {
|
||||
let vals = this.list.length
|
||||
if (this.keyWord.trim()) {
|
||||
vals = this.list.filter(item => item.text.includes(this.keyWord.trim())).map(ele => ele.id).filter(ele => this.selectValue.includes(ele)).length
|
||||
vals = this.vagueFilter(this.keyWord.trim(), this.list).map(ele => ele.id).filter(ele => this.selectValue.includes(ele)).length
|
||||
}
|
||||
return vals
|
||||
},
|
||||
halfSelect() {
|
||||
let vals = this.list.length
|
||||
if (this.keyWord.trim()) {
|
||||
vals = this.list.filter(item => item.text.includes(this.keyWord.trim())).map(ele => ele.id).length
|
||||
vals = this.vagueFilter(this.keyWord.trim(), this.list).map(ele => ele.id).length
|
||||
}
|
||||
return vals
|
||||
},
|
||||
|
@ -31,7 +31,7 @@
|
||||
v-model="value"
|
||||
@change="handleCheckedChange"
|
||||
>
|
||||
<template v-for="item in data.filter(node => !keyWord || (node.id && node.id.includes(keyWord)))">
|
||||
<template v-for="item in data.filter(node => !keyWord || (node.id && node.id.toLocaleUpperCase().includes(keyWord.toLocaleUpperCase())))">
|
||||
<el-checkbox
|
||||
:key="item.id"
|
||||
:label="item.id"
|
||||
@ -51,7 +51,7 @@
|
||||
@change="changeRadioBox"
|
||||
>
|
||||
<el-radio
|
||||
v-for="(item, index) in data.filter(node => !keyWord || (node.id && node.id.includes(keyWord)))"
|
||||
v-for="(item, index) in data.filter(node => !keyWord || (node.id && node.id.toLocaleUpperCase().includes(keyWord.toLocaleUpperCase())))"
|
||||
:key="index"
|
||||
:label="item.id"
|
||||
@click.native.prevent="testChange(item)"
|
||||
|
@ -381,7 +381,7 @@ export default {
|
||||
|
||||
_filterFun(value, data, node) {
|
||||
if (!value) return true
|
||||
return data.id.toString().indexOf(value.toString()) !== -1
|
||||
return data.id.toString().toLocaleUpperCase().indexOf(value.toString().toLocaleUpperCase()) !== -1
|
||||
},
|
||||
// 树点击
|
||||
_nodeClickFun(data, node, vm) {
|
||||
|
Loading…
Reference in New Issue
Block a user