Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
hfpp2012
/
react-spd
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1800ba88
authored
May 22, 2017
by
hfpp2012 yinsigan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
router hash history push
1 parent
93d82e96
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
9 deletions
src/components/Element.js
src/components/ModalRepoForm.js
src/components/RegionalDesign.js
src/components/Element.js
View file @
1800ba8
import
React
from
'react'
import
Move
from
'../libs/move'
import
EventEmitter
from
'../libs/eventEmitter'
import
{
hashHistory
}
from
'react-router'
export
default
class
Element
extends
React
.
Component
{
static
get
getDefaultProps
()
{
...
...
@@ -241,7 +240,7 @@ export default class Element extends React.Component {
const
childrenObjectType
=
this
.
props
.
childrenObjectType
const
url
=
`/regional_design/
${
this
.
props
.
id
}
?object=
${
childrenObjectType
}
`
if
(
childrenObjectType
!=
'drug_brandreth_grid'
)
{
hashHistory
.
push
(
url
)
this
.
props
.
hashHistory
.
push
(
url
)
}
}
...
...
src/components/ModalRepoForm.js
View file @
1800ba8
...
...
@@ -10,9 +10,11 @@ export default class ModalRepoForm extends React.Component {
this
.
state
=
{
showModal
:
false
,
name
:
''
};
this
.
init_state
=
this
.
state
;
this
.
close
=
this
.
close
.
bind
(
this
);
this
.
open
=
this
.
open
.
bind
(
this
);
this
.
handleChange
=
this
.
handleChange
.
bind
(
this
);
this
.
save
=
this
.
save
.
bind
(
this
);
}
close
()
{
...
...
@@ -36,7 +38,7 @@ export default class ModalRepoForm extends React.Component {
e
.
preventDefault
()
$
.
post
(
'/regional_design/repos.json'
,
{
repo
:
this
.
state
},
function
(
data
)
{
this
.
props
.
handleNewRepo
(
data
)
this
.
setState
(
this
.
getInitialState
()
)
this
.
setState
(
this
.
init_state
)
EventEmitter
.
dispatch
(
'alert'
,
'操作成功'
)
}.
bind
(
this
),
'JSON'
)
}
...
...
src/components/RegionalDesign.js
View file @
1800ba8
...
...
@@ -11,6 +11,7 @@ export default class RegionalDesign extends React.Component {
this
.
state
=
{
data
:
null
,
loading
:
true
,
error
:
null
,
object_name
:
''
,
object_type
:
''
,
children_object_type
:
''
};
this
.
init_state
=
this
.
state
;
this
.
addElement
=
this
.
addElement
.
bind
(
this
);
this
.
updateElement
=
this
.
updateElement
.
bind
(
this
);
this
.
addElement
=
this
.
addElement
.
bind
(
this
);
...
...
@@ -34,11 +35,12 @@ export default class RegionalDesign extends React.Component {
children_param_name
:
'drug_brandreth_grid'
}
}
return
config
[
props
.
location
.
query
.
object
][
key
]
const
search_str
=
props
.
location
.
search
return
config
[
search_str
.
substring
(
search_str
.
indexOf
(
"="
)
+
1
)][
key
]
}
componentDidMount
()
{
const
url
=
this
.
getConfig
(
this
.
props
,
'object_url'
)
+
'/'
+
this
.
props
.
params
.
id
+
'.json'
const
url
=
this
.
getConfig
(
this
.
props
,
'object_url'
)
+
'/'
+
this
.
props
.
match
.
params
.
id
+
'.json'
this
.
getJSON
(
url
)
EventEmitter
.
subscribe
(
'moveDropZone'
,
function
(
element
){
...
...
@@ -59,7 +61,7 @@ export default class RegionalDesign extends React.Component {
name
:
element
.
name
,
pos_x
:
element
.
initialPos
.
x
,
pos_y
:
element
.
initialPos
.
y
,
parent_id
:
this
.
props
.
params
.
id
parent_id
:
this
.
props
.
match
.
params
.
id
}
const
url
=
this
.
getConfig
(
this
.
props
,
'children_object_url'
)
+
'.json'
...
...
@@ -95,8 +97,8 @@ export default class RegionalDesign extends React.Component {
}
componentWillReceiveProps
(
nextProps
)
{
this
.
setState
(
this
.
getInitialS
tate
)
const
url
=
this
.
getConfig
(
nextProps
,
'object_url'
)
+
'/'
+
nextProps
.
params
.
id
+
'.json'
this
.
setState
(
this
.
init_s
tate
)
const
url
=
this
.
getConfig
(
nextProps
,
'object_url'
)
+
'/'
+
nextProps
.
match
.
params
.
id
+
'.json'
this
.
getJSON
(
url
)
}
...
...
@@ -118,7 +120,7 @@ export default class RegionalDesign extends React.Component {
else
{
const
data
=
this
.
state
.
data
.
map
(
function
(
element
)
{
return
(
<
Element
childrenObjectType
=
{
this
.
state
.
children_object_type
}
isDropZoneChild
=
{
true
}
key
=
{
element
.
id
}
id
=
{
element
.
id
}
name
=
{
element
.
name
}
initialPos
=
{
element
.
initialPos
}
/
>
<
Element
hashHistory
=
{
this
.
props
.
history
}
childrenObjectType
=
{
this
.
state
.
children_object_type
}
isDropZoneChild
=
{
true
}
key
=
{
element
.
id
}
id
=
{
element
.
id
}
name
=
{
element
.
name
}
initialPos
=
{
element
.
initialPos
}
/
>
)
}.
bind
(
this
))
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment