text: import { Component } from 'react';
  import { Modal, Form, Input } from 'antd';
  
  const FormItem = Form.Item;
  
  class UserEditModal extends Component {
  
    constructor(props) {
      super(props);
      this.state = {
        visible: false,
      };
    }
  
    showModalHandler = (e) => {
      if (e) e.stopPropagation();
      this.setState({
        visible: true,
      });
    };
  
    hideModelHandler = () => {
      this.setState({
        visible: false,
      });
    };
  
    okHandler = () => {
      const { onOk } = this.props;
      this.props.form.validateFields((err, values) => {
        if (!err) {
          onOk(values);
          this.hideModelHandler();
        }
      });
    };
  
    render() {
      const { children } = this.props;
      const { getFieldDecorator } = this.props.form;
      const { name, email, website } = this.props.record;
      const formItemLayout = {
        labelCol: { span: 6 },
        wrapperCol: { span: 14 },
      };
  
      /* Added by stone 20191102 begin */
      let readonly = true;
      let titleName  = "";
      if(this.props.operType === "create"){
        titleName = "Create User";
        readonly = false;
      }else if(this.props.operType === "edit"){
        titleName = "Edit User";
        readonly = false;
      }else{
        titleName = "User Detail";
        readonly = true;
      }
      /* Added by stone 20191102 end */
  
      return (
        <span>
          <span onClick={this.showModalHandler}>
            { children }
          </span>
          <Modal
            title={titleName}
            visible={this.state.visible}
            onOk={this.okHandler}
            onCancel={this.hideModelHandler}
          >
            <Form horizontal onSubmit={this.okHandler}>
              <FormItem
                {...formItemLayout}
                label="Name"
              >
                {
                  getFieldDecorator('name', {
                    initialValue: name,
                    rules: [
                      {
                        required: true,
                        message: "Name为必输项！",
                      },
                    ],
                    })(<Input readOnly={readonly}/>)
                  }
              </FormItem>
              <FormItem
                {...formItemLayout}
                label="Email"
              >
                {
                  getFieldDecorator('email', {
                    initialValue: email,
                  })(<Input readOnly={readonly} />)
                }
              </FormItem>
              <FormItem
                {...formItemLayout}
                label="Website"
              >
                {
                  getFieldDecorator('website', {
                    initialValue: website,
                  })(<Input readOnly={readonly}/>)
                  //(<Input disabled={readonly}/>)
                }
              </FormItem>
            </Form>
          </Modal>
        </span>
      );
    }
  }
  
  export default Form.create()(UserEditModal);
  