import React, { PureComponent } from 'react'; import { Form, Input, Card, Row, Col, Button, InputNumber, TreeSelect, message } from "antd"; import { connect } from 'dva'; import Panel from '../../../components/Panel'; import styles from '../../../layouts/Sword.less'; import { DICT_DETAIL, DICT_INIT, DICT_SUBMIT } from '../../../actions/dict'; const FormItem = Form.Item; const { TextArea } = Input; @connect(({ dict, loading }) => ({ dict, submitting: loading.effects['dict/submit'], })) @Form.create() class DictEdit extends PureComponent { componentWillMount() { const { dispatch, match: { params: { id }, }, } = this.props; dispatch(DICT_DETAIL(id)); dispatch(DICT_INIT()); } componentDidMount() { // 为字典名称增加焦点 this.dictValueRef.focus(); } handleSubmit = e => { e.preventDefault(); const { dispatch, match: { params: { id }, }, form, } = this.props; const parentId = form.getFieldValue('parentId'); if (id === parentId.toString()) { message.warn('上级字典不能选择自身!'); return; } form.validateFieldsAndScroll((err, values) => { if (!err) { const params = { id, ...values, }; dispatch(DICT_SUBMIT(params)); } }); }; 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.parentId, })( )} {getFieldDecorator('sort', { rules: [ { required: true, message: '请输入字典排序', }, ], initialValue: detail.sort, })()} {getFieldDecorator('dictValue', { rules: [ { required: true, message: '请输入字典名称', }, ], initialValue: detail.dictValue, })( { this.dictValueRef = input; }} placeholder="请输入字典名称" /> )} {getFieldDecorator('dictKey', { rules: [ { required: true, message: '请输入字典键值', }, ], initialValue: detail.dictKey, })()} {getFieldDecorator('remark')(