2017-07-18 12:53:53 +08:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import React, { Component } from 'react'
|
|
|
|
import { Select, Input } from 'antd'
|
2017-07-20 16:34:46 +08:00
|
|
|
import { autobind } from 'core-decorators'
|
2017-07-18 12:53:53 +08:00
|
|
|
import {
|
2017-07-20 16:34:46 +08:00
|
|
|
pushInputValue,
|
|
|
|
pushInterfaceName
|
2017-07-19 15:12:10 +08:00
|
|
|
} from '../../../actions/addInterface.js'
|
2017-07-18 12:53:53 +08:00
|
|
|
|
|
|
|
@connect(
|
2017-07-19 15:12:10 +08:00
|
|
|
state => {
|
2017-07-18 12:53:53 +08:00
|
|
|
return {
|
2017-07-20 16:34:46 +08:00
|
|
|
reqInputVal: state.addInterface.inputValue,
|
|
|
|
interfaceName: state.addInterface.interfaceName
|
2017-07-18 12:53:53 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2017-07-20 16:34:46 +08:00
|
|
|
pushInputValue,
|
|
|
|
pushInterfaceName
|
2017-07-18 12:53:53 +08:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
class ReqMethod extends Component {
|
|
|
|
static propTypes = {
|
2017-07-19 15:12:10 +08:00
|
|
|
pushInputValue: PropTypes.func,
|
2017-07-20 16:34:46 +08:00
|
|
|
pushInterfaceName: PropTypes.func,
|
|
|
|
inputValue: PropTypes.string,
|
|
|
|
interfaceName: PropTypes.string
|
2017-07-18 12:53:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
}
|
|
|
|
|
|
|
|
handleChange (value) {
|
|
|
|
console.log(`selected ${value}`)
|
|
|
|
}
|
|
|
|
|
2017-07-20 16:34:46 +08:00
|
|
|
@autobind
|
2017-07-18 12:53:53 +08:00
|
|
|
getInputVal (e) {
|
|
|
|
const inputVal = e.target.value
|
2017-07-20 16:34:46 +08:00
|
|
|
console.log(this.props.pushInputValue)
|
2017-07-19 15:12:10 +08:00
|
|
|
this.props.pushInputValue(inputVal)
|
2017-07-18 12:53:53 +08:00
|
|
|
}
|
|
|
|
|
2017-07-20 16:34:46 +08:00
|
|
|
@autobind
|
|
|
|
getInterfaceValue () {
|
|
|
|
// const name = e.target.value
|
|
|
|
console.log(this.props.pushInterfaceName)
|
|
|
|
// this.props.pushInterfaceName(name)
|
|
|
|
}
|
|
|
|
|
2017-07-18 12:53:53 +08:00
|
|
|
render () {
|
|
|
|
const { Option } = Select
|
2017-07-20 16:34:46 +08:00
|
|
|
console.log(this.props.interfaceName)
|
2017-07-18 12:53:53 +08:00
|
|
|
return (
|
|
|
|
<table>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<th>协议 :</th>
|
|
|
|
<td>
|
2017-07-19 15:12:10 +08:00
|
|
|
<span className="h3">请求协议 {this.props.inputValue}</span>
|
2017-07-18 12:53:53 +08:00
|
|
|
<Select defaultValue="HTTP" style={{ width: 220}} onChange={this.handleChange} size="large">
|
|
|
|
<Option value="HTTP">HTTP</Option>
|
|
|
|
<Option value="HTTPS">HTTPS</Option>
|
|
|
|
</Select>
|
|
|
|
<span className="h3">请求方式</span>
|
|
|
|
<Select defaultValue="POST" style={{ width: 220 }} onChange={this.handleChange} size="large">
|
|
|
|
<Option value="POST">POST</Option>
|
|
|
|
<Option value="GET">GET</Option>
|
|
|
|
<Option value="PUT">PUT</Option>
|
|
|
|
<Option value="DELETE">DELETE</Option>
|
|
|
|
</Select>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>URL :</th>
|
2017-07-20 16:34:46 +08:00
|
|
|
<td><Input placeholder="填写 URL" className="url" size="large" onBlur={this.getInputVal} /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>名称 :</th>
|
|
|
|
<td><Input placeholder="接口名称" className="url" size="large" onBlur={this.getInterfaceValue} /></td>
|
2017-07-18 12:53:53 +08:00
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-19 15:12:10 +08:00
|
|
|
export default ReqMethod
|