yapi/client/containers/AddInterface/AddInterface.js

92 lines
2.0 KiB
JavaScript
Raw Normal View History

2017-07-18 12:53:53 +08:00
import './AddInterface.scss'
import React, { Component } from 'react'
2017-07-20 14:48:29 +08:00
import PropTypes from 'prop-types'
import axios from 'axios'
import { connect } from 'react-redux'
import { autobind } from 'core-decorators'
2017-07-18 12:53:53 +08:00
import { Button } from 'antd'
import ReqMethod from './ReqMethod/ReqMethod.js'
import ReqHeader from './ReqHeader/ReqHeader.js'
import ReqParams from './ReqParams/ReqParams.js'
import ResParams from './ResParams/ResParams.js'
import Result from './Result/Result.js'
2017-07-20 14:48:29 +08:00
import { saveForms } from '../../actions/addInterface.js'
2017-07-18 12:53:53 +08:00
2017-07-20 14:48:29 +08:00
@connect(
state => {
return {
reqParams: state.addInterface.reqParams
}
},
{
saveForms
}
)
2017-07-18 12:53:53 +08:00
2017-07-20 14:48:29 +08:00
class AddInterface extends Component {
static propTypes = {
reqParams: PropTypes.string,
saveForms: PropTypes.func
}
2017-07-18 12:53:53 +08:00
constructor (props) {
super(props)
}
2017-07-20 14:48:29 +08:00
@autobind
2017-07-18 12:53:53 +08:00
saveForms () {
2017-07-20 14:48:29 +08:00
// const config = {
// url: '/interface/add',
// method: 'POST',
// headers: {'Content-Type': 'application/json'},
// params: {
// method: 'POST',
// project_id: 8,
// req_headers: [],
// req_params_type: 'json',
// req_params: this.props.reqParams
// }
// }
const params = {
url: '/interface/add',
method: 'POST',
params: {
method: 'POST',
project_id: 8,
req_headers: [],
req_params_type: 'json',
req_params: this.props.reqParams
}
}
axios.post('/interface/add', params)
.then(data => {
console.log(data)
})
.catch(e => {
console.log(e)
})
console.log(this.props.reqParams)
2017-07-18 12:53:53 +08:00
}
render () {
return (
<section className="add-interface-box">
<div className="content">
2017-07-20 14:48:29 +08:00
<Button type="primary" className="save" onClick={this.saveForms}>保存</Button>
2017-07-18 12:53:53 +08:00
<ReqMethod />
<ReqHeader />
<ReqParams />
<ResParams />
<Result />
</div>
</section>
)
}
}
export default AddInterface