feat: search inputs trigger search on Enter
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
1699fee4a8
commit
d9f1a4d17e
@ -58,6 +58,7 @@
|
|||||||
:placeholder="prop.placeholder"
|
:placeholder="prop.placeholder"
|
||||||
:disabled="isReadonly(key, prop)"
|
:disabled="isReadonly(key, prop)"
|
||||||
:style="widgetStyle(prop)"
|
:style="widgetStyle(prop)"
|
||||||
|
@keyup.enter="onEnter"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
@ -82,18 +83,29 @@ const props = withDefaults(
|
|||||||
inline?: boolean
|
inline?: boolean
|
||||||
/** 表单模式(create/edit),用于 showOn 字段过滤。 */
|
/** 表单模式(create/edit),用于 showOn 字段过滤。 */
|
||||||
mode?: 'create' | 'edit'
|
mode?: 'create' | 'edit'
|
||||||
|
/** 输入框回车触发 submit 事件。 */
|
||||||
|
enterToSubmit?: boolean
|
||||||
/** 强制只读的字段名(如编辑模式下的 username)。 */
|
/** 强制只读的字段名(如编辑模式下的 username)。 */
|
||||||
readonlyKeys?: string[]
|
readonlyKeys?: string[]
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
inline: false,
|
inline: false,
|
||||||
mode: undefined,
|
mode: undefined,
|
||||||
|
enterToSubmit: false,
|
||||||
readonlyKeys: () => [],
|
readonlyKeys: () => [],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'submit'): void
|
||||||
|
}>()
|
||||||
|
|
||||||
const formRef = ref<FormInstance>()
|
const formRef = ref<FormInstance>()
|
||||||
|
|
||||||
|
function onEnter(): void {
|
||||||
|
if (props.enterToSubmit) emit('submit')
|
||||||
|
}
|
||||||
|
|
||||||
/** 按 mode 过滤 showOn 字段。 */
|
/** 按 mode 过滤 showOn 字段。 */
|
||||||
const visibleProperties = computed(() => {
|
const visibleProperties = computed(() => {
|
||||||
const result: Record<string, JsonSchemaProperty> = {}
|
const result: Record<string, JsonSchemaProperty> = {}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<ty-form :schema="visibleSchema" :model-value="modelValue" inline>
|
<ty-form :schema="visibleSchema" :model-value="modelValue" inline enter-to-submit @submit="emit('search')">
|
||||||
<el-form-item class="ty-search-form__actions">
|
<el-form-item class="ty-search-form__actions">
|
||||||
<el-button v-if="collapsible" link type="primary" @click="expanded = !expanded">
|
<el-button v-if="collapsible" link type="primary" @click="expanded = !expanded">
|
||||||
{{ expanded ? '收起' : '展开' }}
|
{{ expanded ? '收起' : '展开' }}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user