yapi/client/containers/AddInterface/ReqMethod/ReqMethod.js

107 lines
2.5 KiB
JavaScript
Raw Normal View History

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,
2017-07-20 16:57:21 +08:00
pushInterfaceName,
pushInterfaceMethod
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:57:21 +08:00
method: state.addInterface.method,
2017-07-20 19:26:04 +08:00
url: state.addInterface.url,
2017-07-20 16:34:46 +08:00
interfaceName: state.addInterface.interfaceName
2017-07-18 12:53:53 +08:00
}
},
{
2017-07-20 16:34:46 +08:00
pushInputValue,
2017-07-20 16:57:21 +08:00
pushInterfaceName,
pushInterfaceMethod
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,
2017-07-20 16:57:21 +08:00
pushInterfaceMethod: PropTypes.func,
2017-07-20 19:26:04 +08:00
url: PropTypes.string,
2017-07-20 16:57:21 +08:00
method: PropTypes.string,
2017-07-20 16:34:46 +08:00
interfaceName: PropTypes.string
2017-07-18 12:53:53 +08:00
}
constructor(props) {
super(props)
}
2017-07-20 16:57:21 +08:00
@autobind
2017-07-18 12:53:53 +08:00
handleChange (value) {
2017-07-20 16:57:21 +08:00
this.props.pushInterfaceMethod(value)
2017-07-18 12:53:53 +08:00
}
2017-07-20 16:34:46 +08:00
@autobind
2017-07-18 12:53:53 +08:00
getInputVal (e) {
2017-07-20 19:26:04 +08:00
const url = e.target.value
this.props.pushInputValue(url)
2017-07-18 12:53:53 +08:00
}
2017-07-20 16:34:46 +08:00
@autobind
2017-07-20 16:57:21 +08:00
getInterfaceValue (e) {
const name = e.target.value
this.props.pushInterfaceName(name)
2017-07-20 16:34:46 +08:00
}
2017-07-18 12:53:53 +08:00
render () {
const { Option } = Select
2017-07-26 16:25:34 +08:00
const { url, interfaceName, method } = this.props
2017-07-26 19:07:29 +08:00
2017-07-18 12:53:53 +08:00
return (
<table>
<tbody>
<tr>
<td>
2017-07-27 20:06:49 +08:00
<span className="h3">请求方式 : </span>
<Select value={method} style={{ width: 180 }} onChange={this.handleChange} size="large">
2017-07-18 12:53:53 +08:00
<Option value="POST">POST</Option>
<Option value="GET">GET</Option>
<Option value="PUT">PUT</Option>
<Option value="DELETE">DELETE</Option>
</Select>
</td>
</tr>
<tr>
2017-07-24 10:59:17 +08:00
<td>
2017-07-27 20:06:49 +08:00
<span className="h3">URL : </span>
2017-07-24 10:59:17 +08:00
<Input
placeholder="填写 URL"
className="url"
size="large"
onInput={this.getInputVal}
value={url}
/>
</td>
2017-07-20 16:34:46 +08:00
</tr>
<tr>
2017-07-24 10:59:17 +08:00
<td>
2017-07-27 20:06:49 +08:00
<span className="h3">名称 : </span>
2017-07-24 10:59:17 +08:00
<Input
placeholder="接口名称"
className="url"
size="large"
value={interfaceName}
onInput={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