import React from 'react' ; import SchemaForm , { Field , Submit , Reset , FormButtonGroup } from '@uform/antd' ; interface searchFormProps { handleSubmit : ( data : any ) => void ; } const SearchForm = ( props ) => { const { handleSubmit } = props ; const submit = ( value ) => { handleSubmit ( value ) ; } ; const categoryList = [ { label : '按商品名' , value : 'productName' } , { label : '按商品ID' , value : 'productId' } , ] ; return ( < SchemaForm layout = "inline" onSubmit = { submit } effects = { ( $ ) => { $ ( 'onFormReset' ) . subscribe ( ( { values } ) => { submit ( values ) ; } ) ; } } > < Field default = "productName" type = "string" enum = { categoryList } name = "searchType" / > < Field type = "string" name = "searchValue" / > < FormButtonGroup > < Submit > 搜索 < /Submit> < Reset / > < /FormButtonGroup> < /SchemaForm>); } ; export default SearchForm ;