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="/"> <Menu.Item key="/">
<Link to="/">首页</Link> <Link to="/">首页</Link>
</Menu.Item> </Menu.Item>
<Menu.Item key="/ProjectGroups"> <Menu.Item key="group/ProjectGroups">
<Link to="/ProjectGroups">分组</Link> <Link to="group/ProjectGroups">分组</Link>
</Menu.Item> </Menu.Item>
<Menu.Item key="/Interface"> <Menu.Item key="/Interface">
<Link to="/Interface">接口</Link> <Link to="/Interface">接口</Link>

View File

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

View File

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

View File

@ -42,10 +42,10 @@ class Interface extends Component {
} }
componentWillMount () { componentWillMount () {
// 558 665 704 743 const interfaceId = this.getInterfaceId()
const params = { const params = {
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 () { render () {
const { interfaceData, projectMember, modalVisible } = this.props const { interfaceData, projectMember, modalVisible } = this.props
return ( return (

View File

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

View File

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

View File

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