Merge pull request #6902 from dataease/pr@dev@fix_select_grid_filter

fix: 列表过滤器模糊搜索缺少选项
This commit is contained in:
fit2cloud-chenyw 2023-11-28 17:07:51 +08:00 committed by GitHub
commit 9aecfe0960
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,8 @@
:size="size"
prefix-icon="el-icon-search"
clearable
@input="filterMethod"
@clear="filterMethod"
/>
</div>
<div class="list">
@ -31,7 +33,7 @@
v-model="value"
@change="handleCheckedChange"
>
<template v-for="item in data.filter(node => !keyWord || (node.id && node.id.toLocaleUpperCase().includes(keyWord.toLocaleUpperCase())))">
<template v-for="item in data">
<el-checkbox
:key="item.id"
:label="item.id"
@ -51,7 +53,7 @@
@change="changeRadioBox"
>
<el-radio
v-for="(item, index) in data.filter(node => !keyWord || (node.id && node.id.toLocaleUpperCase().includes(keyWord.toLocaleUpperCase())))"
v-for="(item, index) in data"
:key="index"
:label="item.id"
@click.native.prevent="testChange(item)"
@ -118,7 +120,9 @@ export default {
show: true,
data: [],
isIndeterminate: false,
checkAll: false
checkAll: false,
timeMachine: null,
changeIndex: 0
}
},
computed: {
@ -220,7 +224,7 @@ export default {
if (!token && linkToken) {
method = linkMultFieldValues
}
const param = { fieldIds: this.element.options.attrs.fieldId.split(','), sort: this.element.options.attrs.sort }
const param = { fieldIds: this.element.options.attrs.fieldId.split(','), sort: this.element.options.attrs.sort, keyword: this.keyWord }
if (this.panelInfo.proxy) {
param.userId = this.panelInfo.proxy
}
@ -238,8 +242,7 @@ export default {
cssArr: {
handler: 'changeInputStyle',
deep: true
},
keyWord: 'changeInputStyle'
}
},
created() {
if (!this.element.options.attrs.sort) {
@ -256,6 +259,23 @@ export default {
bus.$off('reset-default-value', this.resetDefaultValue)
},
methods: {
searchWithKey(index) {
this.timeMachine = setTimeout(() => {
if (index === this.changeIndex) {
this.initOptions()
}
this.destroyTimeMachine()
}, 1500)
},
destroyTimeMachine() {
this.timeMachine && clearTimeout(this.timeMachine)
this.timeMachine = null
},
filterMethod() {
this.destroyTimeMachine()
this.changeIndex++
this.searchWithKey(this.changeIndex)
},
clearDefault(optionList) {
const emptyOption = !optionList?.length
@ -334,7 +354,7 @@ export default {
}
method({
fieldIds: this.element.options.attrs.fieldId.split(','),
sort: this.element.options.attrs.sort
sort: this.element.options.attrs.sort, keyword: this.keyWord
}).then(res => {
this.data = this.optionData(res.data)
this.changeInputStyle()