接口ui修改

This commit is contained in:
waliang.wang 2017-07-25 14:35:46 +08:00
parent cde8e44d68
commit 9fdf3a44db
4 changed files with 26 additions and 19 deletions

View File

@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
import axios from 'axios'
import { connect } from 'react-redux'
import { autobind } from 'core-decorators'
import { Button, Tabs } from 'antd'
import { Button, Tabs, message } from 'antd'
import ReqMethod from './ReqMethod/ReqMethod.js'
import ReqHeader from './ReqHeader/ReqHeader.js'
import ReqParams from './ReqParams/ReqParams.js'
@ -19,6 +19,10 @@ import {
pushInterfaceName
} from '../../actions/addInterface.js'
const success = () => {
message.success('保存成功!')
}
@connect(
state => {
return {
@ -59,7 +63,8 @@ class AddInterface extends Component {
constructor (props) {
super(props)
this.state = {
isLoading: ''
isLoading: '',
isSave: false
}
}
@ -108,15 +113,6 @@ class AddInterface extends Component {
props.addReqHeader(req_headers)
}
editState2 () {
const props = this.props
props.pushInputValue(props.url)
// props.pushInterfaceName(title)
// props.getReqParams(req_params_other)
props.getResParams(props.resParams)
// props.addReqHeader(req_headers)
}
initInterfaceData (interfaceId) {
const params = { id: interfaceId }
@ -146,6 +142,12 @@ class AddInterface extends Component {
location.href = `${origin}${pathname}#/interface`
}
changeState (ifTrue) {
this.setState({
isSave: ifTrue
})
}
@autobind
saveForms () {
let postURL = undefined
@ -174,10 +176,10 @@ class AddInterface extends Component {
this.setLoading(true)
axios.post(postURL, params)
.then(data => {
console.log(data)
.then(() => {
this.setLoading()
this.editState2()
success()
this.changeState(true)
// this.routerPage()
})
.catch(e => {
@ -187,7 +189,7 @@ class AddInterface extends Component {
render () {
const TabPane = Tabs.TabPane
const isLoading = this.state.isLoading
const { isLoading, isSave } = this.state
return (
<section className="add-interface-box">
@ -199,7 +201,7 @@ class AddInterface extends Component {
<ReqHeader />
<ReqParams data={this.props} />
<ResParams />
<Result />
<Result isSave={isSave} />
</TabPane>
<TabPane tab="Mock" key="2">mock</TabPane>
<TabPane tab="测试" key="3">测试</TabPane>

View File

@ -38,6 +38,7 @@ class ResParams extends Component {
const reg = /(<p>)|(<\/p>)|&nbsp;|(<br>)|\s+|<div>|<\/div>/g
editor.customConfig.menus = []
editor.customConfig.onchange = html => {
console.log(html)
html = html.match(/{.*}/g)[0]
html = html.replace(reg, '')
console.log(html)

View File

@ -16,7 +16,8 @@ import PropTypes from 'prop-types'
class Result extends Component {
static propTypes = {
resParams: PropTypes.string,
reqParams: PropTypes.string
reqParams: PropTypes.string,
isSave: PropTypes.bool
}
constructor(props) {
@ -24,16 +25,15 @@ class Result extends Component {
}
render () {
console.log(1)
let TabPane = Tabs.TabPane
let resParams = ''
let json = ''
if(this.props.resParams){
console.log(this.props.resParams)
resParams = JSON.parse(this.props.resParams)
json = JSON.stringify(Mock.mock(resParams), null, 2)
}
return (
<div className="result">
<strong className="res-h3">返回示例 :</strong>

View File

@ -18,8 +18,10 @@
"@qnpm/ykit-config-qunar": "^0.8.2",
"axios": "^0.16.2",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"copy-webpack-plugin": "^4.0.1",
"core-decorators": "^0.17.0",
"fs-extra": "^3.0.1",
"jsoneditor": "^5.9.3",
"jsonwebtoken": "^7.4.1",
"koa": "^2.0.0",
"koa-bodyparser": "^3.2.0",
@ -33,11 +35,13 @@
"mock": "^0.1.1",
"mockjs": "^1.0.1-beta3",
"moment": "^2.18.1",
"monaco-editor": "^0.9.0",
"mongoose": "4.10.8",
"mongoose-auto-increment": "^5.0.1",
"node-sass-china": "^4.5.0",
"nodemailer": "^4.0.1",
"prop-types": "^15.5.10",
"react-monaco-editor": "^0.8.1",
"redux": "^3.7.1",
"redux-promise": "^0.5.3",
"redux-thunk": "^2.2.0",