2017-07-18 12:53:53 +08:00
|
|
|
|
import React, { Component } from 'react'
|
|
|
|
|
import { Select, Input } from 'antd'
|
2017-07-19 15:12:10 +08:00
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
import { autobind } from 'core-decorators'
|
|
|
|
|
import {
|
|
|
|
|
reqTagValue,
|
|
|
|
|
reqHeaderValue,
|
|
|
|
|
deleteReqHeader
|
|
|
|
|
} from '../../../actions/addInterface.js'
|
|
|
|
|
|
|
|
|
|
@connect(
|
|
|
|
|
state => {
|
|
|
|
|
return {
|
|
|
|
|
seqGroup: state.addInterface.seqGroup,
|
|
|
|
|
tagValue: state.addInterface.tagValue,
|
|
|
|
|
headerValue: state.addInterface.headerValue,
|
|
|
|
|
reqTagValue: state.addInterface.reqTagValue,
|
|
|
|
|
reqHeaderValue: state.addInterface.reqHeaderValue
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
reqTagValue,
|
|
|
|
|
reqHeaderValue,
|
|
|
|
|
deleteReqHeader
|
|
|
|
|
}
|
|
|
|
|
)
|
2017-07-18 12:53:53 +08:00
|
|
|
|
|
|
|
|
|
class ReqList extends Component {
|
2017-07-19 15:12:10 +08:00
|
|
|
|
static propTypes = {
|
|
|
|
|
headerValue: PropTypes.string,
|
|
|
|
|
seqGroup: PropTypes.array,
|
|
|
|
|
tagValue: PropTypes.string,
|
|
|
|
|
reqTagValue: PropTypes.func,
|
|
|
|
|
reqHeaderValue: PropTypes.func,
|
|
|
|
|
deleteReqHeader: PropTypes.func,
|
|
|
|
|
dataNum: PropTypes.number
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-18 12:53:53 +08:00
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props)
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-19 19:29:18 +08:00
|
|
|
|
@autobind
|
2017-07-19 15:12:10 +08:00
|
|
|
|
handleChange (value) {
|
|
|
|
|
this.props.reqTagValue(value)
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-19 19:29:18 +08:00
|
|
|
|
@autobind
|
2017-07-19 15:12:10 +08:00
|
|
|
|
handleBlur (e) {
|
|
|
|
|
const value = e.target.value
|
|
|
|
|
this.props.reqHeaderValue(value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@autobind
|
|
|
|
|
deleteReqHeader (e) {
|
|
|
|
|
let newSeqGroup = []
|
|
|
|
|
let seqGroup = this.props.seqGroup
|
|
|
|
|
let dataNum = e.target.getAttribute('data-num')
|
|
|
|
|
seqGroup.map(value => {
|
|
|
|
|
if (+dataNum !== value.id) {
|
|
|
|
|
newSeqGroup.push(value)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this.props.deleteReqHeader(newSeqGroup)
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-18 12:53:53 +08:00
|
|
|
|
render () {
|
|
|
|
|
const Option = Select.Option
|
2017-07-19 15:12:10 +08:00
|
|
|
|
const dataNum = this.props.dataNum
|
2017-07-18 12:53:53 +08:00
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<li>
|
2017-07-19 15:12:10 +08:00
|
|
|
|
<em className="title">头部标签 {this.props.tagValue} {this.props.headerValue}</em>
|
2017-07-19 19:29:18 +08:00
|
|
|
|
<Select defaultValue="HTTP" style={{ width: 220 }} onChange={this.handleChange} size="large">
|
2017-07-18 12:53:53 +08:00
|
|
|
|
<Option value="HTTP">Accept</Option>
|
|
|
|
|
<Option value="Accept-Charset">Accept-Charset</Option>
|
|
|
|
|
<Option value="Accept-Encoding">Accept-Encoding</Option>
|
|
|
|
|
<Option value="Accept-Language">Accept-Language</Option>
|
|
|
|
|
<Option value="Accept-Ranges">Accept-Ranges</Option>
|
|
|
|
|
</Select>
|
|
|
|
|
<em className="title">头部内容</em>
|
2017-07-19 19:29:18 +08:00
|
|
|
|
<Input placeholder="Basic usage" className="req-content" size="large" onBlur={this.handleBlur} />
|
2017-07-19 15:12:10 +08:00
|
|
|
|
<span className="close" onClick={this.deleteReqHeader} data-num={dataNum}>×</span>
|
2017-07-18 12:53:53 +08:00
|
|
|
|
</li>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ReqList
|