2017-08-11 21:10:54 +08:00
|
|
|
import React, { Component } from 'react'
|
2017-08-17 20:24:07 +08:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import { withRouter } from 'react-router'
|
2017-08-21 15:57:04 +08:00
|
|
|
import { Table } from 'antd'
|
2017-08-18 17:31:48 +08:00
|
|
|
import { fetchInterfaceColList, fetchCaseList, setColData } from '../../../../reducer/modules/interfaceCol'
|
2017-08-11 21:10:54 +08:00
|
|
|
|
2017-08-17 20:24:07 +08:00
|
|
|
@connect(
|
|
|
|
state => {
|
|
|
|
return {
|
|
|
|
interfaceColList: state.interfaceCol.interfaceColList,
|
|
|
|
currColId: state.interfaceCol.currColId,
|
|
|
|
currCaseId: state.interfaceCol.currCaseId,
|
2017-08-18 18:13:33 +08:00
|
|
|
isShowCol: state.interfaceCol.isShowCol,
|
|
|
|
currCaseList: state.interfaceCol.currCaseList
|
2017-08-17 20:24:07 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fetchInterfaceColList,
|
2017-08-18 17:31:48 +08:00
|
|
|
fetchCaseList,
|
2017-08-17 20:24:07 +08:00
|
|
|
setColData
|
|
|
|
}
|
|
|
|
)
|
|
|
|
@withRouter
|
2017-08-11 21:10:54 +08:00
|
|
|
export default class InterfaceColContent extends Component {
|
2017-08-17 20:24:07 +08:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
match: PropTypes.object,
|
|
|
|
interfaceColList: PropTypes.array,
|
|
|
|
fetchInterfaceColList: PropTypes.func,
|
2017-08-18 17:31:48 +08:00
|
|
|
fetchCaseList: PropTypes.func,
|
2017-08-17 20:24:07 +08:00
|
|
|
setColData: PropTypes.func,
|
|
|
|
history: PropTypes.object,
|
2017-08-18 18:13:33 +08:00
|
|
|
currCaseList: PropTypes.array,
|
2017-08-17 20:24:07 +08:00
|
|
|
currColId: PropTypes.number,
|
|
|
|
currCaseId: PropTypes.number,
|
|
|
|
isShowCol: PropTypes.bool
|
|
|
|
}
|
|
|
|
|
2017-08-11 21:10:54 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
}
|
|
|
|
|
2017-08-17 20:24:07 +08:00
|
|
|
async componentWillMount() {
|
|
|
|
const result = await this.props.fetchInterfaceColList(this.props.match.params.id)
|
2017-08-18 17:31:48 +08:00
|
|
|
let { currColId } = this.props;
|
2017-08-17 20:24:07 +08:00
|
|
|
const params = this.props.match.params;
|
|
|
|
const { actionId } = params;
|
2017-08-22 09:41:20 +08:00
|
|
|
currColId = +actionId ||
|
|
|
|
result.payload.data.data.find(item => +item._id === +currColId) && +currColId ||
|
|
|
|
result.payload.data.data[0]._id;
|
2017-08-18 17:31:48 +08:00
|
|
|
this.props.history.push('/project/' + params.id + '/interface/col/' + currColId)
|
|
|
|
this.props.fetchCaseList(currColId)
|
|
|
|
this.props.setColData({currColId: +currColId, isShowCol: true})
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
|
const oldCaseId = this.props.match.params.actionId
|
|
|
|
const newCaseId = nextProps.match.params.actionId
|
|
|
|
if (oldCaseId !== newCaseId) {
|
|
|
|
this.props.fetchCaseList(newCaseId);
|
|
|
|
this.props.setColData({currColId: +newCaseId, isShowCol: true})
|
2017-08-17 20:24:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-11 21:10:54 +08:00
|
|
|
render() {
|
2017-08-21 15:57:04 +08:00
|
|
|
|
|
|
|
const { currCaseList } = this.props;
|
|
|
|
|
|
|
|
const columns = [{
|
2017-08-22 09:41:20 +08:00
|
|
|
title: '用例名称',
|
2017-08-21 15:57:04 +08:00
|
|
|
dataIndex: 'casename',
|
|
|
|
key: 'casename'
|
|
|
|
}, {
|
2017-08-22 09:41:20 +08:00
|
|
|
title: '用例路径',
|
2017-08-21 15:57:04 +08:00
|
|
|
dataIndex: 'path',
|
|
|
|
key: 'path'
|
2017-08-22 09:41:20 +08:00
|
|
|
}, {
|
|
|
|
title: '请求方式',
|
|
|
|
dataIndex: 'method',
|
|
|
|
key: 'method'
|
2017-08-21 15:57:04 +08:00
|
|
|
}];
|
|
|
|
|
2017-08-18 18:13:33 +08:00
|
|
|
return (
|
|
|
|
<div>
|
2017-08-21 15:57:04 +08:00
|
|
|
<div style={{padding:"15px"}}>
|
2017-08-22 09:41:20 +08:00
|
|
|
<h2 style={{marginBottom: '10px'}}>测试集合</h2>
|
|
|
|
<Table dataSource={currCaseList} columns={columns} pagination={false} rowKey="_id"/>
|
2017-08-21 15:57:04 +08:00
|
|
|
</div>
|
2017-08-18 18:13:33 +08:00
|
|
|
</div>
|
|
|
|
)
|
2017-08-11 21:10:54 +08:00
|
|
|
}
|
|
|
|
}
|