import React, { Component } from 'react' import { connect } from 'react-redux'; import { withRouter } from 'react-router' import PropTypes from 'prop-types' import { fetchInterfaceColList, fetchInterfaceCaseList } from '../../../../reducer/modules/interfaceCol' import { autobind } from 'core-decorators'; import axios from 'axios'; import { Menu, Input, Icon, Tag, Modal, Row, Col, message, Tooltip } from 'antd'; const SubMenu = Menu.SubMenu; const { TextArea } = Input; @connect( state => { return { interfaceColList: state.interfaceCol.interfaceColList } }, { fetchInterfaceColList, fetchInterfaceCaseList } ) @withRouter export default class InterfaceColMenu extends Component { static propTypes = { match: PropTypes.object, interfaceColList: PropTypes.array, fetchInterfaceColList: PropTypes.func, fetchInterfaceCaseList: PropTypes.func } state = { addColModalVisible: false, addColName: '', addColDesc: '' } constructor(props) { super(props) } componentWillMount() { this.props.fetchInterfaceColList(this.props.match.params.id) } @autobind async addCol() { 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) { this.setState({ addColModalVisible: false }); message.success('添加集合成功'); await this.props.fetchInterfaceColList(project_id); } } @autobind async selectCol(key, e, col) { if (!col.interfaceCaseList) { await this.props.fetchInterfaceCaseList(col._id) } } render() { return (
this.setState({addColModalVisible: true})} >
{ this.props.interfaceColList.map((col, index) => ( {col.name}} onTitleClick={(key, e) => this.selectCol(key, e, col)} > { col.interfaceCaseList && col.interfaceCaseList.map((interfaceCase, index) => ( {interfaceCase.name} )) } )) } { this.setState({ addColModalVisible: false }) }} className="add-col-modal" >
集合名:
this.setState({addColName: e.target.value})}>
简介:
) } }