import React from 'react'; import PropTypes from 'prop-types'; import { Form, Cascader, Switch, Radio, Input, Modal, Icon } from 'antd'; import { Codes, domains } from '../../utils/config'; const RadioGroup = Radio.Group; const FormItem = Form.Item const formItemLayout = { labelCol: { span: 6, }, wrapperCol: { span: 15, }, } const ModalForm = ({ item = {}, onOk, form: { getFieldDecorator, getFieldsValue, validateFields, }, ...modalProps, }) => { const handleOk = () => { validateFields((errors) => { if (errors) return; const data = { ...getFieldsValue(), }; item.id ? data.id = item.id : null; onOk(data); }) } const modalOpts = { ...modalProps, onOk: handleOk, } return (
{getFieldDecorator('domain', { rules: [{ required: true, type: 'number', message: '请选择平台!' }], initialValue: item.domain || Codes.CODE_LJ, })( {Object.keys(domains).map(key => {domains[Number(key)]})} )} {getFieldDecorator('name', { rules: [{ required: true, type: 'string', message: '用户名为必填项!' }], initialValue: item.name, })()} {getFieldDecorator('nickname', { initialValue: item.nickname, })()} {getFieldDecorator('gender', { initialValue: item.gender || 0, })( )} {getFieldDecorator('birthday', { initialValue: item.birthday, })()} {getFieldDecorator('mobile', { initialValue: item.mobile, })()} {getFieldDecorator('mail', { initialValue: item.mail, })()} {getFieldDecorator('qq', { initialValue: item.qq, })()} {getFieldDecorator('weChat', { initialValue: item.weChat, })()} {getFieldDecorator('status', { valuePropsName: 'checked', })()}
) } ModalForm.propTypes = { item: PropTypes.object, form: PropTypes.object, type: PropTypes.string, onOk: PropTypes.func, } export default Form.create()(ModalForm);