2017-08-16 18:04:16 +08:00
|
|
|
import React, { Component } from 'react'
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import PropTypes from 'prop-types'
|
2017-08-11 17:25:57 +08:00
|
|
|
import { Tabs } from 'antd';
|
|
|
|
import Edit from './Edit.js'
|
|
|
|
import View from './View.js'
|
2017-08-17 11:26:20 +08:00
|
|
|
|
2017-08-16 18:04:16 +08:00
|
|
|
import { fetchInterfaceData } from '../../../../reducer/modules/interface.js';
|
|
|
|
import { withRouter } from 'react-router-dom';
|
2017-08-17 10:17:33 +08:00
|
|
|
import Run from './Run/Run.js'
|
2017-08-11 17:25:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
const TabPane = Tabs.TabPane;
|
2017-08-16 18:04:16 +08:00
|
|
|
@connect(
|
|
|
|
state => {
|
|
|
|
return {
|
|
|
|
curdata: state.inter.curdata,
|
|
|
|
list: state.inter.list
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2017-08-17 16:10:34 +08:00
|
|
|
fetchInterfaceData
|
2017-08-16 18:04:16 +08:00
|
|
|
}
|
|
|
|
)
|
|
|
|
class Content extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
match: PropTypes.object,
|
|
|
|
list: PropTypes.array,
|
|
|
|
curdata: PropTypes.object,
|
|
|
|
fetchInterfaceData: PropTypes.func
|
|
|
|
}
|
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
this.state = {
|
|
|
|
curtab: 'view'
|
|
|
|
}
|
|
|
|
this._actionId = 0;
|
|
|
|
}
|
2017-08-11 17:25:57 +08:00
|
|
|
|
2017-08-17 16:10:34 +08:00
|
|
|
componentWillMount() {
|
|
|
|
this.handleRequest(this.props)
|
|
|
|
}
|
|
|
|
|
2017-08-16 18:04:16 +08:00
|
|
|
componentWillReceiveProps(nextProps){
|
|
|
|
this.handleRequest(nextProps)
|
|
|
|
}
|
|
|
|
|
|
|
|
handleRequest(nextProps){
|
|
|
|
let matchParams = nextProps.match.params;
|
|
|
|
let _actionId;
|
2017-08-17 16:10:34 +08:00
|
|
|
_actionId = matchParams.actionId;
|
2017-08-16 18:04:16 +08:00
|
|
|
_actionId = parseInt(matchParams.actionId, 10);
|
|
|
|
if(!nextProps.curdata)return;
|
|
|
|
if(this._actionId !== _actionId){
|
|
|
|
this._actionId = _actionId;
|
|
|
|
this.props.fetchInterfaceData(_actionId)
|
|
|
|
}
|
|
|
|
this.setState({
|
|
|
|
curtab: 'view'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
onChange = (key)=>{
|
|
|
|
this.setState({
|
|
|
|
curtab: key
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const tabs = <Tabs onChange={this.onChange} activeKey={this.state.curtab} defaultActiveKey="view" >
|
|
|
|
<TabPane tab="预览" key="view">
|
|
|
|
{/* <View /> */}
|
2017-08-11 17:25:57 +08:00
|
|
|
</TabPane>
|
2017-08-16 18:04:16 +08:00
|
|
|
<TabPane tab="编辑" key="edit">
|
|
|
|
|
2017-08-11 17:25:57 +08:00
|
|
|
</TabPane>
|
2017-08-16 18:04:16 +08:00
|
|
|
<TabPane tab="运行" key="run">
|
|
|
|
{/* <Run /> */}
|
2017-08-11 17:25:57 +08:00
|
|
|
</TabPane>
|
2017-08-16 18:04:16 +08:00
|
|
|
</Tabs>;
|
|
|
|
let tabContent;
|
|
|
|
if (this.state.curtab === 'view') {
|
|
|
|
tabContent = <View />;
|
|
|
|
} else if (this.state.curtab === 'edit') {
|
|
|
|
tabContent = <Edit />
|
|
|
|
} else if (this.state.curtab === 'run') {
|
|
|
|
tabContent = <Run />
|
|
|
|
}
|
|
|
|
|
|
|
|
return <div className="interface-content">
|
|
|
|
{tabs}
|
|
|
|
{tabContent}
|
|
|
|
</div>
|
|
|
|
}
|
2017-08-11 17:25:57 +08:00
|
|
|
}
|
|
|
|
|
2017-08-17 11:26:20 +08:00
|
|
|
export default withRouter(Content)
|