import React, { PureComponent as Component } from 'react'; import { connect } from 'react-redux'; import { Modal, Collapse, Row, Col, Input, message, Button, Icon } from 'antd'; import PropTypes from 'prop-types'; import axios from 'axios'; import { withRouter } from 'react-router'; import { fetchInterfaceColList } from '../../../../../reducer/modules/interfaceCol'; const { TextArea } = Input; const Panel = Collapse.Panel; @connect( state => ({ interfaceColList: state.interfaceCol.interfaceColList }), { fetchInterfaceColList } ) @withRouter export default class AddColModal extends Component { static propTypes = { visible: PropTypes.bool, interfaceColList: PropTypes.array, fetchInterfaceColList: PropTypes.func, match: PropTypes.object, onOk: PropTypes.func, onCancel: PropTypes.func, caseName: PropTypes.string }; state = { visible: false, addColName: '', addColDesc: '', id: 0, caseName: '' }; constructor(props) { super(props); } UNSAFE_componentWillMount() { this.props.fetchInterfaceColList(this.props.match.params.id); this.setState({ caseName: this.props.caseName }); } UNSAFE_componentWillReceiveProps(nextProps) { this.setState({ id: nextProps.interfaceColList[0]._id }); this.setState({ caseName: nextProps.caseName }); } addCol = async () => { const { addColName: name, addColDesc: desc } = this.state; const project_id = this.props.match.params.id; const res = await axios.post('/api/col/add_col', { name, desc, project_id }); if (!res.data.errcode) { message.success('添加集合成功'); await this.props.fetchInterfaceColList(project_id); this.setState({ id: res.data.data._id }); } else { message.error(res.data.errmsg); } }; select = id => { this.setState({ id }); }; render() { const { interfaceColList = [] } = this.props; const { id } = this.state; return ( this.props.onOk(id, this.state.caseName)} onCancel={this.props.onCancel} >
接口用例名:
this.setState({ caseName: e.target.value })} />

请选择添加到的集合:

集合名:
this.setState({ addColName: e.target.value })} />
简介: