-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pro:search): searchField supports
keywordFallback
option (#1698)
- Loading branch information
Showing
21 changed files
with
569 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 22 | ||
title: | ||
zh: 内置自由输入转关键字功能 | ||
en: Convert unmatched input to keywords | ||
--- | ||
|
||
## zh | ||
|
||
使用 `searchField` 中的 `keywordFallback` 选项支持将未匹配到的自由输入转换该搜索项进行搜索。 | ||
|
||
## en | ||
|
||
convert unmatched casual input to keyword search field value by setting `keywordFallback` of a `searchField`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<template> | ||
<IxProSearch | ||
v-model:value="searchValues" | ||
style="width: 100%" | ||
:searchFields="searchFields" | ||
:onChange="onChange" | ||
:onSearch="onSearch" | ||
></IxProSearch> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { SearchField, SearchValue } from '@idux/pro/search' | ||
import { ref } from 'vue' | ||
const levelDataSource = [ | ||
{ | ||
key: 'level1', | ||
label: 'Level 1', | ||
}, | ||
{ | ||
key: 'level2', | ||
label: 'Level 2', | ||
}, | ||
{ | ||
key: 'level3', | ||
label: 'Level 3', | ||
}, | ||
] | ||
const searchValues = ref<SearchValue[]>([]) | ||
const searchFields: SearchField[] = [ | ||
{ | ||
key: 'keyword', | ||
type: 'input', | ||
label: 'Keyword', | ||
multiple: true, | ||
keywordFallback: true, | ||
fieldConfig: { | ||
trim: true, | ||
}, | ||
}, | ||
{ | ||
key: 'asset_name', | ||
type: 'input', | ||
label: 'Asset Name', | ||
multiple: true, | ||
keywordFallback: true, | ||
fieldConfig: { | ||
trim: true, | ||
}, | ||
}, | ||
{ | ||
type: 'select', | ||
label: 'Level', | ||
key: 'level', | ||
operators: ['=', '!='], | ||
defaultOperator: '=', | ||
keywordFallback: { | ||
parse: input => { | ||
const item = levelDataSource.find(data => data.key === input || data.label === input) | ||
if (item) { | ||
return item.key | ||
} | ||
return 'level1' | ||
}, | ||
}, | ||
fieldConfig: { | ||
multiple: false, | ||
searchable: true, | ||
dataSource: levelDataSource, | ||
}, | ||
}, | ||
{ | ||
type: 'select', | ||
label: 'Security State', | ||
key: 'security_state', | ||
fieldConfig: { | ||
multiple: true, | ||
searchable: true, | ||
dataSource: [ | ||
{ | ||
key: 'fatal', | ||
label: 'fatal', | ||
}, | ||
{ | ||
key: 'high', | ||
label: 'high', | ||
}, | ||
{ | ||
key: 'mediumn', | ||
label: 'mediumn', | ||
}, | ||
{ | ||
key: 'low', | ||
label: 'low', | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
type: 'datePicker', | ||
label: 'Date', | ||
key: 'date', | ||
fieldConfig: { | ||
type: 'datetime', | ||
}, | ||
}, | ||
{ | ||
type: 'dateRangePicker', | ||
label: 'Date Range', | ||
key: 'date_range', | ||
fieldConfig: { | ||
type: 'datetime', | ||
}, | ||
}, | ||
] | ||
const onChange = (value: SearchValue[] | undefined, oldValue: SearchValue[] | undefined) => { | ||
console.log(value, oldValue) | ||
} | ||
const onSearch = () => { | ||
console.log('onSearch') | ||
} | ||
</script> | ||
|
||
<style scoped lang="less"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.