Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
shuniu-admin-react
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
superman
shuniu-admin-react
Commits
5a303517
Commit
5a303517
authored
Aug 10, 2016
by
superman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2016-08-10
parent
613ea9d4
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
378 additions
and
238 deletions
+378
-238
index.js
dist/index.js
+32
-32
proxy.config.js
proxy.config.js
+2
-2
ContactForm.jsx
src/components/ProductForm/ContactForm.jsx
+17
-14
DocumentsForm.jsx
src/components/ProductForm/DocumentsForm.jsx
+29
-11
ElementForm.jsx
src/components/ProductForm/ElementForm.jsx
+24
-16
KeyValue.jsx
src/components/ProductForm/KeyValue.jsx
+0
-40
ShouyiYongjingForm.jsx
src/components/ProductForm/ShouyiYongjingForm.jsx
+29
-11
List.jsx
src/containers/Announcement/List.jsx
+1
-1
EditItem.jsx
src/containers/Authority/EditItem.jsx
+2
-2
List.jsx
src/containers/Authority/List.jsx
+0
-10
EditItem.jsx
src/containers/Resource/EditItem.jsx
+2
-1
EditItem.jsx
src/containers/Users/EditItem.jsx
+190
-75
announcement.js
src/reducers/announcement.js
+2
-2
product.js
src/reducers/product.js
+2
-5
user.js
src/reducers/user.js
+8
-2
announcement.js
src/sagas/announcement.js
+15
-6
product.js
src/sagas/product.js
+4
-3
user.js
src/sagas/user.js
+18
-4
utils.js
src/utils.js
+1
-1
No files found.
dist/index.js
View file @
5a303517
This source diff could not be displayed because it is too large. You can
view the blob
instead.
proxy.config.js
View file @
5a303517
...
...
@@ -2,6 +2,6 @@
// - https://github.com/dora-js/dora-plugin-proxy#规则定义
module
.
exports
=
{
'/api/*'
:
'http://react.yanky.cn/'
,
//
'/api/*': 'http://192.168.1.126:8080/'
//
'/api/*': 'http://react.yanky.cn/',
'/api/*'
:
'http://192.168.1.126:8080/'
};
src/components/ProductForm/ContactForm.jsx
View file @
5a303517
...
...
@@ -35,26 +35,29 @@ export default class ContactForm extends Component {
constructor
(
props
,
context
)
{
super
(
props
,
context
);
this
.
state
=
{
staffs
:
props
.
product
.
staffs
.
map
(
staffs
=>
{
staffs
.
key
=
UUID
();
return
staffs
;
})
staffs
:
[]
};
}
componentDidMount
()
{
this
.
analysisStaffs
(
this
.
props
);
}
componentWillReceiveProps
(
nextProps
)
{
if
(
nextProps
&&
nextProps
.
product
.
staffs
&&
nextProps
.
product
.
staffs
)
{
if
(
nextProps
.
product
.
staffs
.
length
!=
this
.
props
.
product
.
staffs
.
length
)
{
this
.
setState
({
staffs
:
nextProps
.
product
.
staffs
.
map
(
staffs
=>
{
staffs
.
key
=
UUID
();
return
staffs
;
})
});
}
else
{
if
(
nextProps
.
isEdit
!==
this
.
props
.
isEdit
)
{
this
.
analysisStaffs
(
nextProps
);
}
}
}
analysisStaffs
(
props
)
{
if
(
props
.
product
&&
props
.
product
.
staffs
)
{
this
.
setState
({
staffs
:
props
.
product
.
staffs
.
map
(
staffs
=>
{
staffs
.
key
=
UUID
();
return
staffs
;
})
});
}
}
...
...
src/components/ProductForm/DocumentsForm.jsx
View file @
5a303517
...
...
@@ -52,10 +52,7 @@ export default class DocumentsForm extends Component {
product
:
PropTypes
.
object
,
};
componentWillMount
()
{
}
handleSubmit
(
e
)
{
e
.
preventDefault
();
...
...
@@ -83,7 +80,7 @@ export default class DocumentsForm extends Component {
const
{
user
,
loading
,
isEdit
}
=
this
.
props
;
return
(
<
Spin
spinning=
{
loading
}
>
<
Form
horizontal
onSubmit=
{
this
.
handleSubmit
.
bind
(
this
)
}
style=
{
{
maxWidth
:
'
8
00px'
,
margin
:
'auto'
}
}
>
<
Form
horizontal
onSubmit=
{
this
.
handleSubmit
.
bind
(
this
)
}
style=
{
{
maxWidth
:
'
10
00px'
,
margin
:
'auto'
}
}
>
<
Row
style=
{
{
padding
:
'0 20px'
}
}
>
<
Col
span=
"24"
>
<
Form
.
Item
>
...
...
@@ -112,10 +109,10 @@ export default class DocumentsForm extends Component {
<
li
key=
{
file
.
uid
}
style=
{
{
margin
:
"10px 0"
}
}
>
<
Copy
copyText=
{
file
.
url
}
>
<
Row
>
<
Col
span=
"
4
"
><
Icon
type=
"paper-clip"
<
Col
span=
"
6
"
><
Icon
type=
"paper-clip"
style=
{
{
marginRight
:
'.3em'
}
}
/>
{
file
.
name
}
</
Col
>
<
Col
span=
"
20
"
>
{
file
.
url
?
file
.
url
:
'正在上传...'
}
</
Col
>
<
Col
span=
"
18
"
>
{
file
.
url
?
file
.
url
:
'正在上传...'
}
</
Col
>
</
Row
>
</
Copy
>
</
li
>
...
...
@@ -124,18 +121,39 @@ export default class DocumentsForm extends Component {
</
ul
>
}
</
Form
.
Item
>
<
Form
.
Item
style=
{
{
marginTop
:
30
,
textAlign
:
'center'
}
}
>
<
Button
type=
"primary"
htmlType=
"submit"
loading=
{
loading
}
><
Icon
type=
"save"
/>
保存
</
Button
>
<
Form
.
Item
{
...
footerFormSubmitLayout
}
style=
{
{
marginTop
:
30
}
}
>
{
isEdit
?
<
Button
size=
"large"
type=
"primary"
htmlType=
"submit"
loading=
{
loading
}
>
<
Icon
type=
"save"
/>
保存
</
Button
>
:
<
Button
type=
"primary"
onClick=
{
e
=>
{
e
.
preventDefault
();
this
.
props
.
dispatch
({
type
:
'UPDATE_PRODUCT'
});
}
}
>
<
Icon
type=
"edit"
/>
上传
</
Button
>
}
{
!
this
.
props
.
isCreate
&&
<
Button
onClick=
{
e
=>
{
e
.
preventDefault
();
this
.
props
.
history
.
goBack
();}
}
<
Button
onClick=
{
e
=>
{
e
.
preventDefault
();
isEdit
?
this
.
props
.
dispatch
({
type
:
'CANCEL_UPDATE_PRODUCT'
})
:
this
.
props
.
history
.
goBack
();
}
}
style=
{
{
marginLeft
:
'1em'
}
}
>
<
Icon
type=
"rollback"
/>
{
isEdit
?
'取消'
:
'返回'
}
</
Button
>
}
</
Form
.
Item
>
</
Col
>
</
Row
>
</
Form
>
...
...
src/components/ProductForm/ElementForm.jsx
View file @
5a303517
...
...
@@ -47,7 +47,7 @@ export default class ElementForm extends Component {
constructor
(
props
,
context
)
{
super
(
props
,
context
);
this
.
state
=
{
elements
:
BaseElementTransform
(
props
.
product
.
elements
)
elements
:
[]
};
}
...
...
@@ -57,15 +57,23 @@ export default class ElementForm extends Component {
};
componentDidMount
()
{
this
.
analysisBaseElement
(
this
.
props
);
}
componentWillReceiveProps
(
nextProps
)
{
if
(
nextProps
&&
nextProps
.
product
&&
nextProps
.
product
.
elements
)
{
if
(
Object
.
keys
(
nextProps
.
product
.
elements
).
length
!=
Object
.
keys
(
this
.
props
.
product
.
elements
).
length
)
{
this
.
setState
({
elements
:
BaseElementTransform
(
nextProps
.
product
.
elements
)
});
}
if
(
nextProps
.
isEdit
!==
this
.
props
.
isEdit
)
{
this
.
analysisBaseElement
(
nextProps
);
}
}
analysisBaseElement
(
props
)
{
if
(
props
.
product
&&
props
.
product
.
elements
)
{
const
newElements
=
BaseElementTransform
(
props
.
product
.
elements
);
this
.
setState
({
elements
:
newElements
});
}
console
.
log
(
nextProps
);
}
/**
...
...
@@ -192,14 +200,14 @@ export default class ElementForm extends Component {
{
isEdit
?
<
span
>
<
Button
size=
"large"
onClick=
{
this
.
handleAddElement
.
bind
(
this
)
}
style=
{
{
marginRight
:
'1em'
}
}
>
<
Icon
type=
"plus"
/>
添加
</
Button
>
<
Button
size=
"large"
type=
"primary"
htmlType=
"submit"
loading=
{
loading
}
>
<
Icon
type=
"save"
/>
保存
</
Button
>
</
span
>
<
Button
size=
"large"
onClick=
{
this
.
handleAddElement
.
bind
(
this
)
}
style=
{
{
marginRight
:
'1em'
}
}
>
<
Icon
type=
"plus"
/>
添加
</
Button
>
<
Button
size=
"large"
type=
"primary"
htmlType=
"submit"
loading=
{
loading
}
>
<
Icon
type=
"save"
/>
保存
</
Button
>
</
span
>
:
<
Button
type=
"primary"
onClick=
{
e
=>
{
e
.
preventDefault
();
...
...
src/components/ProductForm/KeyValue.jsx
deleted
100644 → 0
View file @
613ea9d4
import
React
,
{
Component
,
PropTypes
}
from
'react'
;
import
{
Row
,
Col
,
Form
,
Input
,
Button
,
Checkbox
,
Select
,
message
,
Tabs
,
Cascader
,
Radio
,
Upload
,
Icon
,
Modal
,
DatePicker
,
Table
,
Spin
}
from
'antd'
;
export
default
class
KeyValue
extends
Component
{
render
(){
const
{
label
,
content
,
operation
}
=
this
.
props
;
return
(
<
Row
>
<
Col
span=
{
label
.
layout
}
>
<
Input
{
...
label
.
input
}
/>
</
Col
>
<
Col
span=
{
content
.
layout
}
>
<
Input
{
...
content
.
input
}
/>
</
Col
>
<
Col
span=
{
operation
.
layout
}
>
{
operation
.
input
}
</
Col
>
</
Row
>
);
}
}
src/components/ProductForm/ShouyiYongjingForm.jsx
View file @
5a303517
...
...
@@ -43,26 +43,44 @@ export default class ShouyiYongjingForm extends Component {
super
(
props
,
context
);
this
.
state
=
{
yongjing
:
YongjingTransform
(
props
.
product
.
commissionAlg
)
yongjing
:
[]
};
}
componentDidMount
()
{
this
.
analysisYongjing
(
this
.
props
);
}
componentWillReceiveProps
(
nextProps
)
{
if
(
nextProps
.
isEdit
!==
this
.
props
.
isEdit
)
{
this
.
analysisYongjing
(
nextProps
);
}
}
analysisYongjing
(
props
)
{
if
(
props
.
product
&&
props
.
product
.
commissionAlg
)
{
this
.
setState
({
yongjing
:
YongjingTransform
(
props
.
product
.
commissionAlg
)
});
}
}
static
propsType
=
{
product
:
PropTypes
.
object
,
user
:
PropTypes
.
object
,
dispatch
:
PropTypes
.
func
};
componentWillReceiveProps
(
nextProps
)
{
if
(
nextProps
&&
nextProps
.
product
&&
nextProps
.
product
.
commissionAlg
)
{
if
(
nextProps
.
product
.
commissionAlg
.
length
!=
this
.
props
.
product
.
commissionAlg
.
length
)
{
this
.
setState
({
yongjing
:
YongjingTransform
(
nextProps
.
product
.
commissionAlg
)
});
}
}
}
//
componentWillReceiveProps(nextProps) {
//
if (nextProps && nextProps.product && nextProps.product.commissionAlg) {
//
if (nextProps.product.commissionAlg.length != this.props.product.commissionAlg.length) {
//
this.setState({
//
yongjing: YongjingTransform(nextProps.product.commissionAlg)
//
});
//
}
//
//
}
//
}
/**
* 添加佣金算法
...
...
src/containers/Announcement/List.jsx
View file @
5a303517
...
...
@@ -110,7 +110,7 @@ export default class List extends Component {
onChange=
{
checked
=>
{
this
.
props
.
dispatch
({
type
:
'UPDATE_ANNOUNCEMENT_ITEM'
,
data
:{
item
:{
id
:
record
.
id
,
status
:
checked
?
1
:
0
}
...
...
src/containers/Authority/EditItem.jsx
View file @
5a303517
...
...
@@ -65,7 +65,6 @@ export default class EditItem extends Component {
componentWillReceiveProps
(
nextProps
)
{
if
(
nextProps
.
item
&&
nextProps
.
item
.
permissions
&&
nextProps
.
resources
)
{
this
.
analysisCheckedKeys
(
nextProps
);
console
.
log
(
'analysisCheckedKeys'
);
}
};
...
...
@@ -99,7 +98,8 @@ export default class EditItem extends Component {
if
(
isNaN
(
data
.
status
))
{
ENABLE_STATUS_LIST
.
forEach
(
item
=>
{
if
(
item
.
text
===
data
.
status
)
{
data
.
status
=
item
.
value
data
.
status
=
item
.
value
;
return
false
;
}
})
}
...
...
src/containers/Authority/List.jsx
View file @
5a303517
...
...
@@ -122,16 +122,6 @@ export default class List extends Component {
render
:
(
status
)
=>
(
<
span
>
{
enableStatusToString
(
status
)
}
</
span
>
)
},
{
title
:
'操作'
,
key
:
'operation'
,
width
:
120
,
className
:
'tac'
,
render
:
(
text
,
item
)
=>
(
<
span
onClick=
{
e
=>
{
e
.
stopPropagation
();
e
.
preventDefault
();}
}
>
</
span
>
)
}
];
...
...
src/containers/Resource/EditItem.jsx
View file @
5a303517
...
...
@@ -73,7 +73,8 @@ export default class EditItem extends Component {
if
(
isNaN
(
data
.
status
))
{
ENABLE_STATUS_LIST
.
forEach
(
item
=>
{
if
(
item
.
text
===
data
.
status
)
{
data
.
status
=
item
.
value
data
.
status
=
item
.
value
;
return
false
;
}
})
}
...
...
src/containers/Users/EditItem.jsx
View file @
5a303517
...
...
@@ -29,27 +29,49 @@ import {
footerFormSubmitLayout
,
userStatusToString
,
formatDateTime
,
NULL
NULL
,
USER_STATUS
}
from
'../../utils'
;
@
connect
(
state
=>
({
loading
:
state
.
user
.
loading
,
loading
:
state
.
user
.
loading
||
state
.
authority
.
loading
,
item
:
state
.
user
.
item
,
isEdit
:
state
.
user
.
isEdit
,
authorities
:
state
.
authority
.
items
,
}))
@
Form
.
create
()
export
default
class
EditItem
extends
Component
{
constructor
()
{
super
(...
arguments
);
this
.
state
=
{
isEdit
:
false
}
}
componentDidMount
()
{
this
.
fetchItem
(
this
.
props
.
params
.
id
);
this
.
fetchAuthorityList
();
};
// componentWillReceiveProps(nextProps) {
// if (nextProps.item && nextProps.authorities) {
// this.analysisCheckedKeys(nextProps);
// }
// };
//
// analysisCheckedKeys(props) {
// const {item, authorities, isEdit} = props;
// //对权限资源分组
// const authoritiesMap = {};
// const checkedKeys = [];
// authorities && authorities.forEach(authority=> {
// authoritiesMap[authority.name] = authority;
//
// });
//
// this.setState({
// authoritiesMap,
// checkedKeys
// });
// }
fetchItem
(
id
)
{
this
.
props
.
dispatch
({
type
:
'FETCH_USER_ITEM'
,
...
...
@@ -57,15 +79,25 @@ export default class EditItem extends Component {
});
};
handleSubmit
(
status
,
e
)
{
fetchAuthorityList
()
{
this
.
props
.
dispatch
({
type
:
'FETCH_AUTHORITY_LIST'
,
query
:
{
s
:
100
}
});
};
handleSubmit
(
e
)
{
e
.
preventDefault
();
let
data
=
{};
if
(
status
==
1
||
status
==
0
)
{
data
.
status
=
status
;
}
else
{
data
=
this
.
props
.
form
.
getFieldsValue
();
}
const
data
=
this
.
props
.
form
.
getFieldsValue
();
data
.
id
=
this
.
props
.
params
.
id
;
if
(
isNaN
(
data
.
status
))
{
Object
.
keys
(
USER_STATUS
).
forEach
(
key
=>
{
if
(
USER_STATUS
[
key
]
===
data
.
status
)
{
data
.
status
=
key
;
return
false
;
}
})
}
console
.
log
(
data
);
this
.
props
.
dispatch
({
type
:
'UPDATE_USER_ITEM'
,
...
...
@@ -74,15 +106,30 @@ export default class EditItem extends Component {
}
render
()
{
const
{
item
,
loading
,
form
:{
getFieldProps
},
location
:{
query
}}
=
this
.
props
;
const
{
isEdit
}
=
this
.
state
;
const
{
item
,
loading
,
form
:{
getFieldProps
},
location
:{
query
},
isEdit
,
authorities
}
=
this
.
props
;
const
operation
=
(
<
div
style=
{
{
textAlign
:
'right'
}
}
>
<
Button
.
Group
>
<
Button
type=
"ghost"
onClick=
{
e
=>
{
e
.
preventDefault
();
this
.
props
.
history
.
goBack
();}
}
>
<
Button
type=
"ghost"
onClick=
{
e
=>
{
e
.
preventDefault
();
this
.
props
.
dispatch
({
type
:
isEdit
?
'CANCEL_UPDATE_USER'
:
'UPDATE_USER'
});
}
}
>
<
Icon
type=
"edit"
/>
</
Button
>
<
Button
type=
"ghost"
onClick=
{
e
=>
{
e
.
preventDefault
();
isEdit
?
this
.
props
.
dispatch
({
type
:
'CANCEL_UPDATE_USER'
})
:
this
.
props
.
history
.
goBack
();
}
}
>
<
Icon
type=
"rollback"
/>
</
Button
>
</
Button
.
Group
>
...
...
@@ -91,74 +138,117 @@ export default class EditItem extends Component {
const
header
=
(
<
MainHeader
breadcrumb=
{
[
'用户管理'
,
'用户详情'
]
}
title=
{
(
query
&&
query
.
title
?
query
.
title
+
' - '
:
''
)
+
'用户详情'
}
title=
{
'用户详情'
+
(
isEdit
?
' - 编辑'
:
''
)
}
operation=
{
operation
}
/>
);
const
authoritiesMap
=
authorities
?
authorities
.
reduce
((
map
,
authority
)
=>
{
map
[
authority
.
name
]
=
authority
;
return
map
;
},
{})
:
{};
if
(
item
)
{
item
.
authorities
=
item
.
authorities
.
split
(
','
);
item
.
authoritiesDescList
=
[];
// item.authoritiesMap = item.authorities.reduce((map, name)=> {
// const authority = authoritiesMap[name];
// map[name] = authority;
// item.authoritiesDescList.push(authority.description);
// }, {});
}
return
(
<
Layout
header=
{
header
}
>
<
Spin
spinning=
{
loading
}
>
{
item
&&
<
Form
className=
"main-form"
horizontal
>
<
Form
.
Item
label=
"用户名"
{
...
smallFormItemLayout
}
>
{
item
.
username
}
</
Form
.
Item
>
<
Form
.
Item
label=
"状态"
{
...
smallFormItemLayout
}
>
{
userStatusToString
(
item
.
status
)
}
</
Form
.
Item
>
<
Form
.
Item
label=
"昵称"
{
...
smallFormItemLayout
}
>
{
isEdit
?
<
Input
{
...
getFieldProps
('
nick
',
{
initialValue
:
item
.
nick
})}
/>
:
item
.
nick
||
NULL
}
</
Form
.
Item
>
<
Form
.
Item
label=
"E-mail"
{
...
smallFormItemLayout
}
>
{
isEdit
?
<
Input
{
...
getFieldProps
('
email
',
{
initialValue
:
item
.
email
})}
/>
:
item
.
email
||
NULL
}
</
Form
.
Item
>
<
Form
.
Item
label=
"手机号"
{
...
smallFormItemLayout
}
>
{
isEdit
?
<
Input
{
...
getFieldProps
('
mobile
',
{
initialValue
:
item
.
mobile
})}
/>
:
item
.
mobile
||
NULL
}
</
Form
.
Item
>
<
Form
.
Item
label=
"注册时间"
{
...
smallFormItemLayout
}
>
{
item
.
dateCreated
&&
formatDateTime
(
item
.
dateCreated
)
}
</
Form
.
Item
>
<
Form
.
Item
{
...
footerFormSubmitLayout
}
style=
{
{
marginTop
:
30
}
}
>
{
isEdit
?
<
Button
type=
"primary"
onClick=
{
this
.
handleSubmit
.
bind
(
this
,
-
1
)
}
loading=
{
loading
}
>
<
Icon
type=
"save"
/>
修改
<
Row
>
<
Col
span=
"12"
>
<
Form
.
Item
label=
"用户名"
{
...
smallFormItemLayout
}
>
{
item
.
username
}
</
Form
.
Item
>
<
Form
.
Item
label=
"状态"
{
...
smallFormItemLayout
}
>
{
isEdit
?
<
Select
placeholder=
"请选择状态"
{
...
getFieldProps
('
status
',
{
initialValue
:
userStatusToString
(
item
.
status
)})}
>
<
Select
.
Option
value=
"0"
>
未激活
</
Select
.
Option
>
<
Select
.
Option
value=
"1"
>
已激活
</
Select
.
Option
>
</
Select
>
:
(
typeof
item
.
status
!==
'undefined'
?
userStatusToString
(
item
.
status
)
:
NULL
)
}
</
Form
.
Item
>
<
Form
.
Item
label=
"角色"
{
...
smallFormItemLayout
}
>
{
item
.
authoritiesDescList
.
join
()
}
</
Form
.
Item
>
<
Form
.
Item
label=
"昵称"
{
...
smallFormItemLayout
}
>
{
isEdit
?
<
Input
{
...
getFieldProps
('
nick
',
{
initialValue
:
item
.
nick
})}
/>
:
item
.
nick
||
NULL
}
</
Form
.
Item
>
<
Form
.
Item
label=
"E-mail"
{
...
smallFormItemLayout
}
>
{
isEdit
?
<
Input
{
...
getFieldProps
('
email
',
{
initialValue
:
item
.
email
})}
/>
:
item
.
email
||
NULL
}
</
Form
.
Item
>
<
Form
.
Item
label=
"手机号"
{
...
smallFormItemLayout
}
>
{
isEdit
?
<
Input
{
...
getFieldProps
('
mobile
',
{
initialValue
:
item
.
mobile
})}
/>
:
item
.
mobile
||
NULL
}
</
Form
.
Item
>
<
Form
.
Item
label=
"注册时间"
{
...
smallFormItemLayout
}
>
{
item
.
dateCreated
&&
formatDateTime
(
item
.
dateCreated
)
}
</
Form
.
Item
>
<
Form
.
Item
{
...
footerFormSubmitLayout
}
style=
{
{
marginTop
:
30
}
}
>
{
isEdit
?
<
Button
type=
"primary"
onClick=
{
this
.
handleSubmit
.
bind
(
this
)
}
loading=
{
loading
}
>
<
Icon
type=
"save"
/>
保存
</
Button
>
:
<
Button
type=
"primary"
onClick=
{
e
=>
{
e
.
preventDefault
();
this
.
props
.
dispatch
({
type
:
'UPDATE_USER'
});
}
}
>
<
Icon
type=
"edit"
/>
编辑
</
Button
>
}
<
Button
onClick=
{
e
=>
{
e
.
preventDefault
();
isEdit
?
this
.
props
.
dispatch
({
type
:
'CANCEL_UPDATE_USER'
})
:
this
.
props
.
history
.
goBack
();
}
}
style=
{
{
marginLeft
:
'1em'
}
}
>
<
Icon
type=
"rollback"
/>
{
isEdit
?
'取消'
:
'返回'
}
</
Button
>
:
item
.
status
?
<
Button
type=
"primary"
onClick=
{
this
.
handleSubmit
.
bind
(
this
,
0
)
}
loading=
{
loading
}
>
<
Icon
type=
"save"
/>
禁用
</
Button
>
:
<
Button
type=
"primary"
onClick=
{
this
.
handleSubmit
.
bind
(
this
,
1
)
}
loading=
{
loading
}
>
<
Icon
type=
"save"
/>
激活
</
Button
>
}
<
Button
onClick=
{
e
=>
{
e
.
preventDefault
();
this
.
props
.
history
.
goBack
();}
}
style=
{
{
marginLeft
:
'1em'
}
}
>
<
Icon
type=
"rollback"
/>
返回
</
Button
>
</
Form
.
Item
>
</
Form
.
Item
>
</
Col
>
<
Col
span=
"12"
>
</
Col
>
</
Row
>
</
Form
>
}
</
Spin
>
...
...
@@ -170,3 +260,28 @@ export default class EditItem extends Component {
// <Button type="ghost" onClick={e=>{e.preventDefault(); this.setState({isEdit: !this.state.isEdit})}}>
// <Icon type="edit"/>
// </Button>
// <Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}>
// {
// isEdit ?
// <Button type="primary" onClick={this.handleSubmit.bind(this, -1)}
// loading={loading}>
// <Icon type="save"/>修改
// </Button>
// :
// item.status ?
// <Button type="primary" onClick={this.handleSubmit.bind(this, 0)}
// loading={loading}>
// <Icon type="save"/>禁用
// </Button>
// :
// <Button type="primary" onClick={this.handleSubmit.bind(this, 1)}
// loading={loading}>
// <Icon type="save"/>激活
// </Button>
// }
// <Button onClick={e=>{e.preventDefault(); this.props.history.goBack();}}
// style={{marginLeft:'1em'}}>
// <Icon type="rollback"/>返回
// </Button>
// </Form.Item>
src/reducers/announcement.js
View file @
5a303517
...
...
@@ -47,10 +47,10 @@ const announcement = handleActions({
return
{...
state
,
loading
:
true
}
},
[
'UPDATE_ANNOUNCEMENT_ITEM_SUCCESS'
](
state
,
action
){
return
{...
state
,
loading
:
false
,
item
:
{...
state
.
item
,
...
action
.
item
}}
return
{...
state
,
loading
:
false
,
i
sEdit
:
false
,
i
tem
:
{...
state
.
item
,
...
action
.
item
}}
},
[
'UPDATE_ANNOUNCEMENT_ITEM_FAILED'
](
state
,
action
){
return
{...
state
,
err
:
action
.
err
,
loading
:
false
}
return
{...
state
,
err
:
action
.
err
,
loading
:
false
,
isEdit
:
false
}
},
},
initState
);
...
...
src/reducers/product.js
View file @
5a303517
...
...
@@ -62,13 +62,11 @@ const product = handleActions({
console
.
log
(
'UPDATE_PRODUCT_ITEM_SUCCESS staffs Error:'
,
action
.
item
.
staffs
);
}
}
const
ret
=
{...
state
,
loading
:
false
,
item
:{...
state
.
item
,
...
action
.
item
}};
console
.
log
(
ret
,
state
);
return
ret
;
return
{...
state
,
loading
:
false
,
item
:{...
state
.
item
,
...
action
.
item
},
isEdit
:
false
};
},
[
'UPDATE_PRODUCT_ITEM_FAILED'
](
state
,
action
){
return
{...
state
,
loading
:
false
,
err
:
action
.
err
};
return
{...
state
,
loading
:
false
,
err
:
action
.
err
,
isEdit
:
false
};
},
...
...
@@ -82,7 +80,6 @@ const product = handleActions({
return
{...
state
,
loading
:
false
,
err
:
action
.
err
};
}
},
{
//cates: [],
items
:
[],
loading
:
false
,
});
...
...
src/reducers/user.js
View file @
5a303517
...
...
@@ -53,14 +53,20 @@ const user = handleActions({
return
{...
state
,
loading
:
false
,
err
:
action
.
err
};
},
[
'UPDATE_USER_START'
](
state
){
return
{...
state
,
isEdit
:
true
}
},
[
'UPDATE_USER_END'
](
state
){
return
{...
state
,
isEdit
:
false
}
},
[
'UPDATE_USER_ITEM'
](
state
){
return
{...
state
,
loading
:
true
};
},
[
'UPDATE_USER_ITEM_SUCCESS'
](
state
,
action
){
return
{...
state
,
loading
:
false
,
item
:
{...
state
.
item
,
...
action
.
item
}};
return
{...
state
,
loading
:
false
,
item
:
{...
state
.
item
,
...
action
.
item
}
,
isEdit
:
false
};
},
[
'UPDATE_USER_ITEM_FAILED'
](
state
,
action
){
return
{...
state
,
loading
:
false
,
err
:
action
.
err
};
return
{...
state
,
loading
:
false
,
err
:
action
.
err
,
isEdit
:
false
};
},
},
{
...
...
src/sagas/announcement.js
View file @
5a303517
...
...
@@ -78,13 +78,13 @@ function* watchAdd() {
}
}
function
*
editItem
(
data
)
{
function
*
editItem
(
item
)
{
try
{
yield
call
(
updateItem
,
data
);
yield
call
(
updateItem
,
item
);
message
.
success
(
'修改成功!'
);
yield
put
({
type
:
'UPDATE_ANNOUNCEMENT_ITEM_SUCCESS'
,
item
:
data
item
});
}
catch
(
err
){
console
.
log
(
err
);
...
...
@@ -109,10 +109,18 @@ function* watchEdit() {
if
(
data
&&
data
.
item
)
{
yield
fork
(
editItem
,
data
.
item
);
}
else
{
yield
put
({
type
:
'UPDATE_ANNOUNCEMENT_END'
});
}
yield
put
({
type
:
'UPDATE_ANNOUNCEMENT_END'
});
}
}
function
*
watchSwidth
()
{
while
(
true
){
const
{
item
}
=
yield
take
(
'UPDATE_ANNOUNCEMENT_ITEM'
);
yield
fork
(
editItem
,
item
);
}
}
...
...
@@ -121,4 +129,5 @@ export default function*() {
yield
fork
(
watchItem
);
yield
fork
(
watchAdd
);
yield
fork
(
watchEdit
);
yield
fork
(
watchSwidth
);
}
src/sagas/product.js
View file @
5a303517
...
...
@@ -105,10 +105,11 @@ function* watchEditProductItem() {
if
(
data
&&
data
.
item
)
{
yield
fork
(
editItem
,
data
.
item
);
}
else
{
yield
put
({
type
:
'UPDATE_PRODUCT_END'
});
}
yield
put
({
type
:
'UPDATE_PRODUCT_END'
});
}
}
...
...
src/sagas/user.js
View file @
5a303517
import
{
takeLatest
}
from
'redux-saga'
;
import
{
take
,
call
,
put
,
fork
,
cancel
}
from
'redux-saga/effects'
;
import
{
take
,
call
,
put
,
fork
,
cancel
,
race
}
from
'redux-saga/effects'
;
import
{
fetch
,
clear
,
save
,
create
,
fetchList
,
fetchItem
,
updateItem
}
from
'../services/user'
;
import
{
message
}
from
'antd'
;
...
...
@@ -107,9 +107,23 @@ function* modifyItem(data) {
}
function
*
watchMidfiyItem
(){
while
(
true
){
const
{
data
}
=
yield
take
(
'UPDATE_USER_ITEM'
);
yield
fork
(
modifyItem
,
data
);
while
(
true
)
{
yield
take
(
'UPDATE_USER'
);
yield
put
({
type
:
'UPDATE_USER_START'
});
const
{
data
}
=
yield
race
({
data
:
take
(
'UPDATE_USER_ITEM'
),
canceled
:
take
(
'CANCEL_UPDATE_USER'
)
});
if
(
data
&&
data
.
item
)
{
yield
fork
(
modifyItem
,
data
.
item
);
}
else
{
yield
put
({
type
:
'UPDATE_USER_END'
});
}
}
}
...
...
src/utils.js
View file @
5a303517
...
...
@@ -69,7 +69,7 @@ export const productEnableCreateTrade = status => {
export
const
USER_STATUS
=
{
0
:
'未激活'
,
1
:
'
正常
'
1
:
'
已激活
'
};
export
const
userStatusToString
=
status
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment