设计规则
<Form.Item label="code:" {...FormItemLayout} >
{getFieldDecorator('code', {
rules: [{required: true, message: '请选择!'},
{validator:(rule:any,value:any,callback:any)=>{
HttpClient(env.server + '/code/unique?code='+value.toString()).then(data=>{
if(data.status==200){
if(data.data.msg=='错误'){
callback('code错误')
}else if(data.data.msg=='重复') {
callback('code重复')
}else{
callback()
}
}
})
}}
]
})(
<Input style={{ width: '65%' }} />
)}
<Upload {...props1}>
<Button type="primary" style={{width:100}}>
<Icon type="upload" /> 导入code
</Button>
</Upload>
</Form.Item>