import React, { PureComponent } from 'react'; import { Form, Input, Card, Row, Col, Button, InputNumber, TreeSelect } from 'antd'; import { connect } from 'dva'; import Panel from '../../../components/Panel'; import styles from '../../../layouts/Sword.less'; import func from '../../../utils/Func'; import { DICT_INIT, DICT_SUBMIT, DICT_DETAIL, DICT_CLEAR_DETAIL } from '../../../actions/dict'; const FormItem = Form.Item; const { TextArea } = Input; @connect(({ dict, loading }) => ({ dict, submitting: loading.effects['dict/submit'], })) @Form.create() class DictAdd extends PureComponent { componentWillMount() { const { dispatch, match: { params: { id }, }, } = this.props; if (func.notEmpty(id)) { dispatch(DICT_DETAIL(id)); } else { dispatch(DICT_CLEAR_DETAIL()); } dispatch(DICT_INIT()); } componentDidMount() { // 为字典名称增加焦点 this.dictValueRef.focus(); } handleSubmit = e => { e.preventDefault(); const { dispatch, form } = this.props; form.validateFieldsAndScroll((err, values) => { if (!err) { dispatch(DICT_SUBMIT(values)); } }); }; onParentIdChange = (value, title) => { console.log(value); console.log(title); }; render() { const { form: { getFieldDecorator }, dict: { detail, init: { tree }, }, submitting, } = this.props; const formItemLayout = { labelCol: { span: 8, }, wrapperCol: { span: 16, }, }; const formAllItemLayout = { labelCol: { span: 4, }, wrapperCol: { span: 20, }, }; const action = ( ); return (
{getFieldDecorator('code', { rules: [ { required: true, message: '请选择字典编号', }, ], initialValue: detail.code, })()} {getFieldDecorator('parentId', { initialValue: detail.id, })( )} {getFieldDecorator('sort', { rules: [ { required: true, message: '请输入字典排序', }, ], initialValue: detail.nextSort, })()} {getFieldDecorator('dictValue', { rules: [ { required: true, message: '请输入字典名称', }, ], })( { this.dictValueRef = input; }} placeholder="请输入字典名称" /> )} {getFieldDecorator('dictKey', { rules: [ { required: true, message: '请输入字典键值', }, ], initialValue: detail.nextKey, })()} {getFieldDecorator('remark')(