import React, { Component } from 'react' import { connect } from 'react-redux'; import { withRouter } from 'react-router' import PropTypes from 'prop-types' import { fetchInterfaceColList, fetchInterfaceCaseList, setColData } from '../../../../reducer/modules/interfaceCol' import { autobind } from 'core-decorators'; import axios from 'axios'; import { Input, Icon, Tag, Modal, Row, Col, message, Tooltip, Tree } from 'antd'; const TextArea = Input.TextArea; const TreeNode = Tree.TreeNode; import './InterfaceColMenu.scss' @connect( state => { return { interfaceColList: state.interfaceCol.interfaceColList, currColId: state.interfaceCol.currColId, currCaseId: state.interfaceCol.currCaseId, isShowCol: state.interfaceCol.isShowCol } }, { fetchInterfaceColList, fetchInterfaceCaseList, setColData } ) @withRouter export default class InterfaceColMenu extends Component { static propTypes = { match: PropTypes.object, interfaceColList: PropTypes.array, fetchInterfaceColList: PropTypes.func, fetchInterfaceCaseList: PropTypes.func, setColData: PropTypes.func, history: PropTypes.object, currColId: PropTypes.number, currCaseId: PropTypes.number, isShowCol: PropTypes.bool } state = { addColModalVisible: false, addColName: '', addColDesc: '' } constructor(props) { super(props) } // async componentWillMount() { // const result = await this.props.fetchInterfaceColList(this.props.match.params.id) // let params = this.props.match.params; // if(!params.actionId){ // this.props.history.push('/project/'+params.id + '/interface/col/' + result.payload.data.data[0]._id) // } // } // async componentWillReceiveProps(nextProps) { // const result = await nextProps.fetchInterfaceColList(nextProps.match.params.id) // let params = nextProps.match.params; // if(!params.actionId){ // nextProps.history.replace('/project/'+params.id + '/interface/col/' + result.payload.data.data[0]._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); } else { message.error(res.data.errmsg); } } @autobind async onSelect(key) { const type = key.split('_')[0]; const id = key.split('_')[1]; if (type === 'col') { this.props.setColData({ isShowCol: true, currColId: id }) } else { this.props.setColData({ isShowCol: false, currCaseId: id }) } } render() { const { currColId, currCaseId, isShowCol } = this.props; return (
this.setState({addColModalVisible: true})} >
{ this.props.interfaceColList.map((col) => ( {col.name}} > { col.caseList && col.caseList.map((interfaceCase) => ( )) } )) } { this.setState({ addColModalVisible: false }) }} className="add-col-modal" >
集合名:
this.setState({addColName: e.target.value})}>
简介:
) } }