[ISSUE #8755] add default fuzzy search feature (#8757)

* 默认模糊查询

* 删除多余字符

* 英语翻译

* 英语翻译

* 英语翻译
This commit is contained in:
gogogo 2022-07-19 10:21:45 +08:00 committed by GitHub
parent 26f86e8da3
commit a7b9d8b72d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 7 deletions

View File

@ -291,7 +291,9 @@ const I18N_CONF = {
queryResults: 'Search Results: Found',
articleMeetRequirements: 'configuration items',
fuzzyd: "Add wildcard '*' for fuzzy query",
defaultFuzzyd: 'Default fuzzy query mode opened',
fuzzyg: "Add wildcard '*' for fuzzy query",
defaultFuzzyg: 'Default fuzzy query mode opened',
query: 'Search',
advancedQuery9: 'Advanced Query',
application0: 'Application:',

View File

@ -289,7 +289,9 @@ const I18N_CONF = {
queryResults: '查询结果共查询到',
articleMeetRequirements: '条满足要求的配置',
fuzzyd: "添加通配符'*'进行模糊查询",
defaultFuzzyd: '已开启默认模糊查询',
fuzzyg: "添加通配符'*'进行模糊查询",
defaultFuzzyg: '已开启默认模糊查询',
query: '查询',
advancedQuery9: '高级查询',
application0: '归属应用:',

View File

@ -35,6 +35,7 @@ import {
Message,
MenuButton,
Box,
Switch,
} from '@alifd/next';
import BatchHandle from 'components/BatchHandle';
import RegionGroup from 'components/RegionGroup';
@ -115,6 +116,7 @@ class ConfigurationManagement extends React.Component {
selectedRowKeys: [],
},
isPageEnter: false,
defaultFuzzySearch: true,
};
const obj = {
dataId: this.dataId || '',
@ -236,6 +238,22 @@ class ConfigurationManagement extends React.Component {
this.setState({ rowSelection });
}
changeParamsBySearchType(params) {
if (this.state.defaultFuzzySearch) {
if (params.dataId && params.dataId !== '') {
params.dataId = '*' + params.dataId + '*';
}
if (params.group && params.group !== '') {
params.group = '*' + params.group + '*';
}
}
if (params.dataId.indexOf('*') !== -1 || params.group.indexOf('*') !== -1) {
params.search = 'blur';
} else {
params.search = 'accurate';
}
}
getData(pageNo = 1, clearSelect = true) {
if (this.state.loading) {
return;
@ -258,11 +276,7 @@ class ConfigurationManagement extends React.Component {
};
setParams('pageSize', null);
setParams('pageNo', null);
if (this.dataId.indexOf('*') !== -1 || this.group.indexOf('*') !== -1) {
params.search = 'blur';
} else {
params.search = 'accurate';
}
this.changeParamsBySearchType(params);
this.setState({ loading: true });
this.props
.getConfigs(params)
@ -448,6 +462,12 @@ class ConfigurationManagement extends React.Component {
});
}
handleDefaultFuzzySwitchChange = () => {
this.setState({
defaultFuzzySearch: !this.state.defaultFuzzySearch,
});
};
selectAll() {
setParams('dataId', this.dataId);
setParams('group', this.group);
@ -1135,7 +1155,9 @@ class ConfigurationManagement extends React.Component {
<Input
value={this.dataId}
htmlType="text"
placeholder={locale.fuzzyd}
placeholder={
this.state.defaultFuzzySearch ? locale.defaultFuzzyd : locale.fuzzyd
}
style={{ width: 200 }}
onChange={dataId => {
this.dataId = dataId;
@ -1149,7 +1171,9 @@ class ConfigurationManagement extends React.Component {
<Select.AutoComplete
style={{ width: 200 }}
size={'medium'}
placeholder={locale.fuzzyg}
placeholder={
this.state.defaultFuzzySearch ? locale.defaultFuzzyg : locale.fuzzyg
}
dataSource={this.state.groups}
value={this.state.group}
onChange={this.setGroup.bind(this)}
@ -1157,6 +1181,17 @@ class ConfigurationManagement extends React.Component {
hasClear
/>
</Form.Item>
<Form.Item label="默认模糊匹配:">
<Switch
checkedChildren=""
unCheckedChildren=""
defaultChecked={this.state.defaultFuzzySearch}
onChange={this.handleDefaultFuzzySwitchChange}
title={'自动在搜索参数前后加上*'}
/>
</Form.Item>
<Form.Item label={''}>
<Button
type={'primary'}