import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { Button, Form, Input, Icon, Tooltip, Select, message, Row, Col, Radio } from 'antd'; import { addProject } from '../../reducer/modules/project.js'; import { fetchGroupList } from '../../reducer/modules/group.js' import { autobind } from 'core-decorators'; const { TextArea } = Input; const FormItem = Form.Item; const Option = Select.Option; const RadioGroup = Radio.Group; import './Addproject.scss' const formItemLayout = { labelCol: { lg: { span: 3 }, xs: { span: 24 }, sm: { span: 6 } }, wrapperCol: { lg: { span: 21 }, xs: { span: 24 }, sm: { span: 14 } }, className: 'form-item' }; @connect( state => { return { groupList: state.group.groupList } }, { fetchGroupList, addProject } ) class ProjectList extends Component { constructor(props) { super(props); this.state = { groupList: [] } } static propTypes = { groupList: PropTypes.array, form: PropTypes.object, addProject: PropTypes.func, fetchGroupList: PropTypes.func } // 确认添加项目 @autobind handleOk(e) { const { form, addProject } = this.props; e.preventDefault(); form.validateFields((err, values) => { if (!err) { values.group_id = values.group.split(':')[0]; values.group_name = values.group.split(':')[1]; delete values.group; addProject(values).then((res) => { if (res.payload.data.errcode == 0) { form.resetFields(); message.success('创建成功! '); } }).catch(() => { }); } }); } async componentWillMount() { await this.props.fetchGroupList(); this.setState({groupList: this.props.groupList}); } render() { const { getFieldDecorator } = this.props.form; return (