diff --git a/src/components/Form/src/Form.vue b/src/components/Form/src/Form.vue index d8421d87c..1a9076d65 100644 --- a/src/components/Form/src/Form.vue +++ b/src/components/Form/src/Form.vue @@ -400,6 +400,12 @@ export default defineComponent({ onBlur={(e) => { onBlur(item.field, e) }} onFocus={(e) => { onFocus(item.field) }} onInput={(value)=>{onInput(item.field,value)}} + onKeyup={(event)=>{ + if(event.keyCode === 13){ + //回车 + emit('onEnter',item.field,formModel.value[item.field],event) + } + }} {...(notRenderOptions.includes(item?.component as string) && item?.componentProps?.options ? { options: item?.componentProps?.options || [] } diff --git a/src/components/Search/src/Search.vue b/src/components/Search/src/Search.vue index c233dd92c..f75d6fa2f 100644 --- a/src/components/Search/src/Search.vue +++ b/src/components/Search/src/Search.vue @@ -63,9 +63,15 @@ const props = defineProps({ required: false, default: [] }, + //回车触发搜索。默认true + enterSearch:{ + type: Boolean, + required: false, + default: true + }, }) -const emit = defineEmits(['search', 'reset','onInput','onChange','searchTableSuccess']) +const emit = defineEmits(['search', 'reset','onInput','onChange','onEnter','searchTableSuccess']) const visible = ref(true) @@ -116,6 +122,13 @@ const onInput = (field,value) => { const onChange = (field, value)=>{ emit('onChange', field,value) } +const onEnter = async (field, value, e) => { + if(props.enterSearch){ + search() + }else{ + emit('onEnter', field, value, e) + } +} const searchTableRef = ref() const opensearchTable = ( formField, @@ -291,6 +304,7 @@ defineExpose({setFormValues,search}) // 提供 open 方法,用于打开弹窗 @onInput="onInput" @opensearchTable="opensearchTable" @onChange="onChange" + @onEnter="onEnter" >