-
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
17 changed files
with
321 additions
and
144 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 21 | ||
title: | ||
zh: 非法搜索项转换为关键字 | ||
en: Convert Illegal Search Value To Keyword | ||
--- | ||
|
||
## zh | ||
|
||
使用 `onItemConfirm` 事件将非法搜索项转换为关键字。 | ||
|
||
## en | ||
|
||
convert illgale search value to keyword via `onItemConfirm` 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,117 @@ | ||
<template> | ||
<IxProSearch | ||
v-model:value="searchValues" | ||
style="width: 100%" | ||
:searchFields="searchFields" | ||
:onChange="onChange" | ||
:onSearch="onSearch" | ||
:onItemConfirm="onItemConfirm" | ||
></IxProSearch> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { SearchField, SearchItemConfirmContext, 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 onItemConfirm = (context: SearchItemConfirmContext) => { | ||
const { removed, nameInput, operatorInput, valueInput } = context | ||
if (removed) { | ||
return | ||
} | ||
searchValues.value.push({ | ||
key: 'keyword', | ||
value: (nameInput ?? '') + (operatorInput ?? '') + (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
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
Oops, something went wrong.