|
|
@@ -6,14 +6,18 @@ const FormItem = Form.Item
|
|
|
class DetailBox extends React.Component {
|
|
|
|
|
|
okHandler = () => {
|
|
|
- const { dispatch, userGroup} = this.props;
|
|
|
+ const { dispatch, userGroup, form } = this.props;
|
|
|
const { newOne } = userGroup;
|
|
|
- console.log(newOne.operate);
|
|
|
- if(newOne.operate === 'create') {
|
|
|
- dispatch({ type: 'userGroup/remoteAdd' });
|
|
|
- }else if(newOne.operate === 'modify') {
|
|
|
- dispatch({ type: 'userGroup/remoteModify' });
|
|
|
- }
|
|
|
+
|
|
|
+ form.validateFields((err, values) => {
|
|
|
+ if(!err) {
|
|
|
+ if(newOne.operate === 'create') {
|
|
|
+ dispatch({ type: 'userGroup/remoteAdd' });
|
|
|
+ }else if(newOne.operate === 'modify') {
|
|
|
+ dispatch({ type: 'userGroup/remoteModify' });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
hideBox = () => {
|
|
|
@@ -22,9 +26,10 @@ class DetailBox extends React.Component {
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
- const { dispatch, userGroup } = this.props;
|
|
|
+ const { dispatch, userGroup, form } = this.props;
|
|
|
const { newOne } = userGroup;
|
|
|
|
|
|
+ const { getFieldDecorator } = form;
|
|
|
const formItemLayout = {
|
|
|
labelCol: { span: 4 },
|
|
|
wrapperCol: { span: 20 },
|
|
|
@@ -41,23 +46,36 @@ class DetailBox extends React.Component {
|
|
|
>
|
|
|
<Form size='small'>
|
|
|
<FormItem label='用户组名' {...formItemLayout} >
|
|
|
- <Input
|
|
|
- placeholder="请输入用户组名称"
|
|
|
- value={newOne.name}
|
|
|
- onChange={(e) => {
|
|
|
- dispatch({ type: 'userGroup/setNewModelField', name: 'name', value: e.target.value });
|
|
|
- }}
|
|
|
- >
|
|
|
- </Input>
|
|
|
+ {
|
|
|
+ getFieldDecorator('groupName', {
|
|
|
+ initialValue: newOne.name,
|
|
|
+ rules: [{ required: true, whitespace: true, message: '用户组名不能为空' }],
|
|
|
+ })(
|
|
|
+ <Input
|
|
|
+ placeholder="请输入用户组名称"
|
|
|
+ // value={newOne.name}
|
|
|
+ onChange={(e) => {
|
|
|
+ dispatch({ type: 'userGroup/setNewModelField', name: 'name', value: e.target.value });
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ </Input>
|
|
|
+ )
|
|
|
+ }
|
|
|
</FormItem>
|
|
|
<FormItem className='textarea-desc' label='描述' {...formItemLayout}>
|
|
|
- <Input.TextArea
|
|
|
- autosize={{ minRows: 2 }}
|
|
|
- value={newOne.description}
|
|
|
- onChange={(e) => {
|
|
|
- dispatch({ type: 'userGroup/setNewModelField', name: 'description', value: e.target.value });
|
|
|
- }}
|
|
|
- />
|
|
|
+ {
|
|
|
+ getFieldDecorator('description', {
|
|
|
+ initialValue: newOne.description,
|
|
|
+ })(
|
|
|
+ <Input.TextArea
|
|
|
+ autosize={{ minRows: 2 }}
|
|
|
+ // value={newOne.description}
|
|
|
+ onChange={(e) => {
|
|
|
+ dispatch({ type: 'userGroup/setNewModelField', name: 'description', value: e.target.value });
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }
|
|
|
</FormItem>
|
|
|
</Form>
|
|
|
</Modal>
|
|
|
@@ -65,4 +83,4 @@ class DetailBox extends React.Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export default connect(( { present: { userGroup } } ) => ({ userGroup }))(DetailBox)
|
|
|
+export default connect(( { present: { userGroup } } ) => ({ userGroup }))(Form.create()(DetailBox))
|