feat - 修改路由参数

This commit is contained in:
waliang.wang 2017-07-25 17:41:58 +08:00
parent 73795893c5
commit ee31f5cb4c
7 changed files with 31 additions and 16 deletions

View File

@ -142,8 +142,8 @@ class HeaderCom extends Component {
<Menu.Item key="/">
<Link to="/">首页</Link>
</Menu.Item>
<Menu.Item key="/ProjectGroups">
<Link to="/ProjectGroups">分组</Link>
<Menu.Item key="group/ProjectGroups">
<Link to="group/ProjectGroups">分组</Link>
</Menu.Item>
<Menu.Item key="/Interface">
<Link to="/Interface">接口</Link>

View File

@ -73,6 +73,7 @@ class AddInterface extends Component {
let interfaceId = undefined
if (ifTrue) {
interfaceId = this.getInterfaceId()
console.log('interfaceId', interfaceId)
this.initInterfaceData(interfaceId)
} else {
const props = this.props
@ -91,8 +92,10 @@ class AddInterface extends Component {
}
getInterfaceId () {
const value = location.hash.match(/\d+/g)
return value ? value[0] : ''
const reg = /AddInterface\/edit\/(\d+)/g
const url = location.href
url.match(reg)
return RegExp.$1
}
verificationURL () {
@ -159,7 +162,7 @@ class AddInterface extends Component {
path: url,
method: 'POST',
req_headers: seqGroup,
project_id: 558,
project_id: interfaceId,
req_params_type: 'json',
req_params_other: reqParams,
res_body_type: 'json',
@ -180,7 +183,6 @@ class AddInterface extends Component {
this.setLoading()
success()
this.changeState(true)
// this.routerPage()
})
.catch(e => {
console.log(e)

View File

@ -38,10 +38,8 @@ 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.match(/{.*}/g)[0]
html = html.replace(reg, '')
console.log(html)
this.props.getResParams(html)
}
setTimeout(() => {

View File

@ -42,10 +42,10 @@ class Interface extends Component {
}
componentWillMount () {
// 558 665 704 743
const interfaceId = this.getInterfaceId()
const params = {
params: {
project_id: 558
project_id: interfaceId
}
}
@ -63,6 +63,13 @@ class Interface extends Component {
})
}
getInterfaceId () {
const reg = /Interface\/(\d+)/g
const url = location.href
url.match(reg)
return RegExp.$1
}
render () {
const { interfaceData, projectMember, modalVisible } = this.props
return (

View File

@ -32,7 +32,7 @@
.interface-table {
-webkit-box-flex: 1;
margin: 0 0 0 20px;
margin: 0 20px;
.ant-table-wrapper table {
font-size: .14rem;

View File

@ -11,16 +11,24 @@ class InterfaceList extends Component {
super(props)
}
getInterfaceId () {
const reg = /Interface\/(\d+)/g
const url = location.href
url.match(reg)
return RegExp.$1
}
render () {
const { projectMember } = this.props
const getInterfaceId = this.getInterfaceId()
console.log(`/AddInterface/${getInterfaceId}`)
return (
<ul className="interface-list">
<li><Link to="/AddInterface">添加接口</Link></li>
<li><Link to={`/AddInterface/${getInterfaceId}`}>添加接口</Link></li>
<li onClick={projectMember}>管理项目成员</li>
</ul>
)
}
}
export default InterfaceList
export default InterfaceList

View File

@ -41,7 +41,7 @@ const getColumns = (data, props) => {
dataIndex: 'name',
key: 'name',
render: (text, record) => {
return <Link to={`Interface/${record._id}`}>{text}</Link>
return <Link to={`../Interface/${record._id}`}>{text}</Link>
}
}, {
title: '创建人',