-
Notifications
You must be signed in to change notification settings - Fork 141
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): add validate function
- Loading branch information
Showing
13 changed files
with
260 additions
and
117 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 21 | ||
title: | ||
zh: 非法搜索项转换为关键字 | ||
en: Convert Invalid Search Value To Keyword | ||
--- | ||
|
||
## zh | ||
|
||
使用 `onItemInvalid` 事件将非法搜索项转换为关键字。 | ||
|
||
## en | ||
|
||
convert invalid search value to keyword via `onItemInvalid` event. |
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,112 @@ | ||
<template> | ||
<IxProSearch | ||
v-model:value="searchValues" | ||
style="width: 100%" | ||
:searchFields="searchFields" | ||
:onChange="onChange" | ||
:onSearch="onSearch" | ||
:onItemInvalid="onInvalid" | ||
></IxProSearch> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { InvalidSearchValue, SearchField, SearchValue } from '@idux/pro/search' | ||
import { ref } from 'vue' | ||
const searchValues = ref<SearchValue[]>([]) | ||
const searchFields: SearchField[] = [ | ||
{ | ||
key: 'keyword', | ||
type: 'input', | ||
label: 'Keyword', | ||
multiple: true, | ||
fieldConfig: { | ||
trim: true, | ||
}, | ||
}, | ||
{ | ||
type: 'select', | ||
label: 'Level', | ||
key: 'level', | ||
operators: ['=', '!='], | ||
defaultOperator: '=', | ||
fieldConfig: { | ||
multiple: false, | ||
searchable: true, | ||
dataSource: [ | ||
{ | ||
key: 'level1', | ||
label: 'Level 1', | ||
}, | ||
{ | ||
key: 'level2', | ||
label: 'Level 2', | ||
}, | ||
{ | ||
key: 'level3', | ||
label: 'Level 3', | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
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') | ||
} | ||
const onInvalid = (value: InvalidSearchValue) => { | ||
searchValues.value.push({ | ||
key: 'keyword', | ||
value: (value.nameInput ?? '') + (value.operatorInput ?? '') + (value.valueInput ?? ''), | ||
}) | ||
} | ||
</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
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.