2017-07-18 12:53:53 +08:00
|
|
|
import React, { Component } from 'react'
|
|
|
|
import { Button } from 'antd'
|
2017-07-19 15:12:10 +08:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import { connect } from 'react-redux'
|
2017-07-18 12:53:53 +08:00
|
|
|
import ParamsList from './ParamsList.js'
|
2017-07-19 15:12:10 +08:00
|
|
|
import { autobind } from 'core-decorators'
|
|
|
|
import {
|
|
|
|
addReqParams
|
|
|
|
} from '../../../actions/addInterface.js'
|
|
|
|
|
|
|
|
@connect(
|
|
|
|
state => {
|
|
|
|
return {
|
|
|
|
seqParams: state.addInterface.seqParams
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
addReqParams
|
|
|
|
}
|
|
|
|
)
|
2017-07-18 12:53:53 +08:00
|
|
|
|
|
|
|
class ReqParams extends Component {
|
2017-07-19 15:12:10 +08:00
|
|
|
static propTypes = {
|
|
|
|
addReqParams: PropTypes.func,
|
|
|
|
seqParams: PropTypes.array
|
|
|
|
}
|
|
|
|
|
2017-07-18 12:53:53 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
}
|
|
|
|
|
2017-07-19 15:12:10 +08:00
|
|
|
@autobind
|
|
|
|
addSeqParams () {
|
|
|
|
let newSeqParams= []
|
|
|
|
let seqParams = this.props.seqParams
|
|
|
|
let id = seqParams[seqParams.length-1].id
|
|
|
|
let list = {
|
|
|
|
id: ++id,
|
|
|
|
paramsName: '',
|
|
|
|
describe: ''
|
|
|
|
}
|
|
|
|
seqParams.push(list)
|
|
|
|
newSeqParams.push(...seqParams)
|
|
|
|
// this.props.addReqParams(newSeqParams)
|
|
|
|
}
|
|
|
|
|
2017-07-18 12:53:53 +08:00
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<section>
|
|
|
|
<div className="req-params">
|
|
|
|
<strong className="req-h3">请求参数 :</strong>
|
|
|
|
<ul>
|
|
|
|
<ParamsList />
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
2017-07-19 15:12:10 +08:00
|
|
|
<Button type="primary" className="req-save" onClick={this.addSeqParams}>添加</Button>
|
2017-07-18 12:53:53 +08:00
|
|
|
</section>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ReqParams
|