yapi/client/containers/AddInterface/ReqParams/ParamsList.js

64 lines
1.7 KiB
JavaScript
Raw Normal View History

2017-07-18 12:53:53 +08:00
import React, { Component } from 'react'
import { Select, Input } from 'antd'
2017-07-19 19:29:18 +08:00
import PropTypes from 'prop-types'
import { autobind } from 'core-decorators'
import { connect } from 'react-redux'
import { deleteReqParams } from '../../../actions/addInterface.js'
2017-07-26 12:31:42 +08:00
import json2html from 'json2html'
2017-07-19 19:29:18 +08:00
@connect(
state => {
return {
reqParams: state.addInterface.reqParams
}
},
{
deleteReqParams
}
)
2017-07-18 12:53:53 +08:00
class ParamsList extends Component {
2017-07-19 19:29:18 +08:00
static propTypes = {
reqParams: PropTypes.array,
dataNum: PropTypes.number,
deleteReqParams: PropTypes.func
}
2017-07-18 12:53:53 +08:00
constructor(props) {
super(props)
}
2017-07-19 19:29:18 +08:00
@autobind
deleteReqParams (e) {
let newSeqParams = []
let reqParams = this.props.reqParams
let dataNum = e.target.getAttribute('data-num')
reqParams.map(value => {
if (+dataNum !== value.id) {
newSeqParams.push(value)
}
})
this.props.deleteReqParams(newSeqParams)
}
2017-07-18 12:53:53 +08:00
render () {
const Option = Select.Option
2017-07-19 19:29:18 +08:00
const dataNum = this.props.dataNum
2017-07-18 12:53:53 +08:00
return (
<li>
<Select defaultValue="选填" style={{ width: 'auto' }} onChange={this.handleChange} size="large" className="required">
<Option value="必填">必填</Option>
<Option value="选填">选填</Option>
</Select>
<em className="title">参数名称</em>
<Input placeholder="参数名称" className="name" size="large" />
<em className="title">参数说明</em>
<Input placeholder="参数说明" className="name" size="large" />
2017-07-19 19:29:18 +08:00
<span className="close" onClick={this.deleteReqParams} data-num={dataNum}>×</span>
2017-07-26 12:31:42 +08:00
</li>
2017-07-18 12:53:53 +08:00
)
}
}
export default ParamsList