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) {
|
_filterFun(value, data, node) {
|
||||||
if (!value) return true
|
if (!value) return true
|
||||||
return data[this.propsLabel].indexOf(value) !== -1
|
return data[this.propsLabel?.toLocaleUpperCase()].indexOf(value.toLocaleUpperCase()) !== -1
|
||||||
},
|
},
|
||||||
_treeNodeClickFun(data, node, vm) {
|
_treeNodeClickFun(data, node, vm) {
|
||||||
const { multiple } = this.selectParams
|
const { multiple } = this.selectParams
|
||||||
|
@ -121,7 +121,7 @@ export default {
|
|||||||
},
|
},
|
||||||
keyWord(val, old) {
|
keyWord(val, old) {
|
||||||
if (val === old) return
|
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.resetList(results)
|
||||||
this.reCacularHeight()
|
this.reCacularHeight()
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
@ -136,6 +136,11 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
vagueFilter(val, nodes) {
|
||||||
|
if (!val || !val.trim()) return nodes
|
||||||
|
const results = nodes.filter(item => item.text?.toLocaleUpperCase().includes(val.toLocaleUpperCase()))
|
||||||
|
return results
|
||||||
|
},
|
||||||
resetSelectAll() {
|
resetSelectAll() {
|
||||||
this.selectAll = false
|
this.selectAll = false
|
||||||
},
|
},
|
||||||
@ -148,7 +153,7 @@ export default {
|
|||||||
selectAllChange(val) {
|
selectAllChange(val) {
|
||||||
let vals = val ? [...this.list.map(ele => ele.id)] : []
|
let vals = val ? [...this.list.map(ele => ele.id)] : []
|
||||||
if (this.keyWord.trim() && val) {
|
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.visualChange(vals)
|
||||||
this.selectValue = vals
|
this.selectValue = vals
|
||||||
@ -233,14 +238,14 @@ export default {
|
|||||||
isAllSelect() {
|
isAllSelect() {
|
||||||
let vals = this.list.length
|
let vals = this.list.length
|
||||||
if (this.keyWord.trim()) {
|
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
|
return vals
|
||||||
},
|
},
|
||||||
halfSelect() {
|
halfSelect() {
|
||||||
let vals = this.list.length
|
let vals = this.list.length
|
||||||
if (this.keyWord.trim()) {
|
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
|
return vals
|
||||||
},
|
},
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
v-model="value"
|
v-model="value"
|
||||||
@change="handleCheckedChange"
|
@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
|
<el-checkbox
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.id"
|
:label="item.id"
|
||||||
@ -51,7 +51,7 @@
|
|||||||
@change="changeRadioBox"
|
@change="changeRadioBox"
|
||||||
>
|
>
|
||||||
<el-radio
|
<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"
|
:key="index"
|
||||||
:label="item.id"
|
:label="item.id"
|
||||||
@click.native.prevent="testChange(item)"
|
@click.native.prevent="testChange(item)"
|
||||||
|
@ -381,7 +381,7 @@ export default {
|
|||||||
|
|
||||||
_filterFun(value, data, node) {
|
_filterFun(value, data, node) {
|
||||||
if (!value) return true
|
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) {
|
_nodeClickFun(data, node, vm) {
|
||||||
|
Loading…
Reference in New Issue
Block a user