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
bc005bb2
Commit
bc005bb2
authored
Aug 08, 2016
by
superman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
列表的接口全部改成list
parent
688aa87b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
587 additions
and
248 deletions
+587
-248
index.css
dist/index.css
+1
-1
index.js
dist/index.js
+36
-34
BaseInfoForm.jsx
src/components/ProductForm/BaseInfoForm.jsx
+3
-2
DocumentsForm.jsx
src/components/ProductForm/DocumentsForm.jsx
+8
-7
List.jsx
src/containers/Announcement/List.jsx
+8
-5
EditItem.jsx
src/containers/Authority/EditItem.jsx
+160
-74
EditItem.less
src/containers/Authority/EditItem.less
+22
-0
List.jsx
src/containers/Authority/List.jsx
+10
-5
BaseUpload.jsx
src/containers/BaseFunction/BaseUpload.jsx
+8
-7
AddItem.jsx
src/containers/CustomMessage/AddItem.jsx
+1
-1
List.jsx
src/containers/CustomMessage/List.jsx
+3
-1
List.jsx
src/containers/Product/List.jsx
+4
-1
List.jsx
src/containers/Remittance/List.jsx
+3
-1
EditItem.jsx
src/containers/Resource/EditItem.jsx
+22
-23
List.jsx
src/containers/Resource/List.jsx
+16
-27
utils.js
src/containers/Resource/utils.js
+0
-12
List.jsx
src/containers/Trade/List.jsx
+3
-1
List.jsx
src/containers/Users/List.jsx
+3
-1
List.jsx
src/containers/Withdraw/List.jsx
+3
-1
RESTful.js
src/sagas/RESTful.js
+216
-7
announcement.js
src/sagas/announcement.js
+2
-2
authority.js
src/sagas/authority.js
+2
-2
customMessage.js
src/sagas/customMessage.js
+2
-2
product.js
src/sagas/product.js
+2
-2
remittance.js
src/sagas/remittance.js
+2
-2
resource.js
src/sagas/resource.js
+2
-2
trade.js
src/sagas/trade.js
+2
-2
user.js
src/sagas/user.js
+2
-2
withdraw.js
src/sagas/withdraw.js
+2
-2
authority.js
src/services/admin/authority.js
+1
-1
resource.js
src/services/admin/resource.js
+1
-1
announcement.js
src/services/announcement.js
+1
-1
customMessage.js
src/services/customMessage.js
+1
-2
product.js
src/services/product.js
+1
-1
remittance.js
src/services/remittance.js
+1
-1
trade.js
src/services/trade.js
+1
-1
user.js
src/services/user.js
+1
-1
withdraw.js
src/services/withdraw.js
+1
-1
utils.js
src/utils.js
+30
-9
No files found.
dist/index.css
View file @
bc005bb2
This diff is collapsed.
Click to expand it.
dist/index.js
View file @
bc005bb2
This diff is collapsed.
Click to expand it.
src/components/ProductForm/BaseInfoForm.jsx
View file @
bc005bb2
...
...
@@ -26,7 +26,8 @@ import {
smallFormItemLayout
,
footerFormSubmitLayout
,
handleUpload
,
leftRightFormItemLayout
leftRightFormItemLayout
,
FILE_UPLOAD
}
from
'../../utils'
;
...
...
@@ -204,7 +205,7 @@ export default class BaseInfoForm extends Component {
<
Form
.
Item
label=
"产品主图"
{
...
leftRightFormItemLayout
}
>
{
isEdit
?
<
Upload
action=
"/api/fileUpload/upload"
listType=
"picture-card"
<
Upload
{
...
FILE_UPLOAD
}
listType=
"picture-card"
multiple=
{
true
}
headers=
{
{
authorization
:
user
&&
user
.
token
,
...
...
src/components/ProductForm/DocumentsForm.jsx
View file @
bc005bb2
...
...
@@ -27,7 +27,8 @@ import {
formItemLayout
,
smallFormItemLayout
,
footerFormSubmitLayout
,
handleUpload
handleUpload
,
FILE_UPLOAD
}
from
'../../utils'
;
import
Copy
from
'../../components/CopyToClipboard/CopyToClipboard'
;
...
...
@@ -88,15 +89,15 @@ export default class DocumentsForm extends Component {
<
Form
.
Item
>
{
isEdit
?
<
Upload
.
Dragger
action=
"/api/fileUpload/upload"
multiple=
{
true
}
headers=
{
{
<
Upload
.
Dragger
{
...
FILE_UPLOAD
}
multiple=
{
true
}
headers=
{
{
authorization
:
user
&&
user
.
token
,
}
}
onChange=
{
info
=>
this
.
setState
({
fileList
:
handleUpload
(
info
)})
}
onChange=
{
info
=>
this
.
setState
({
fileList
:
handleUpload
(
info
)})
}
//showUploadList=
{
false
}
onPreview=
{
(
e
)
=>
console
.
log
(
e
)
}
fileList=
{
this
.
state
.
fileList
}
onPreview=
{
(
e
)
=>
console
.
log
(
e
)
}
fileList=
{
this
.
state
.
fileList
}
>
<
p
className=
"ant-upload-drag-icon"
>
<
Icon
type=
"inbox"
/>
...
...
src/containers/Announcement/List.jsx
View file @
bc005bb2
...
...
@@ -33,7 +33,7 @@ export default class List extends Component {
};
handleRowClick
({
id
})
{
this
.
props
.
history
.
push
(
'/announcement/'
+
id
);
this
.
props
.
history
.
push
(
'/announcement/'
+
id
);
}
handleFilterVisible
()
{
...
...
@@ -46,9 +46,11 @@ export default class List extends Component {
const
pagination
=
{
total
:
total
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
1
0
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
3
0
,
current
:
parseInt
(
query
.
p
,
10
)
||
1
,
showSizeChanger
:
true
,
showTotal
:
total
=>
`共
${
total
}
条`
,
pageSizeOptions
:[
'10'
,
'30'
,
'50'
,
'100'
],
onShowSizeChange
:
(
current
,
pageSize
)
=>
{
console
.
log
(
'Current: '
,
current
,
'; PageSize: '
,
pageSize
);
query
.
p
=
current
;
...
...
@@ -148,18 +150,19 @@ export default class List extends Component {
const
footer
=
(
<
div
style=
{
{
margin
:
'10px 0'
}
}
>
<
Link
to=
{
'/announcement/create?itemId='
+
query
.
itemId
+
'&title='
+
query
.
title
}
>
<
Button
type=
"primary"
>
<
Button
type=
"primary"
>
<
Icon
type=
"plus"
/>
添加
</
Button
>
</
Link
>
<
Button
style=
{
{
margin
:
'0 1em'
}
}
type=
"ghost"
onClick=
{
e
=>
{
e
.
preventDefault
();
this
.
props
.
history
.
goBack
();}
}
>
<
Button
style=
{
{
margin
:
'0 1em'
}
}
type=
"ghost"
onClick=
{
e
=>
{
e
.
preventDefault
();
this
.
props
.
history
.
goBack
();}
}
>
<
Icon
type=
"rollback"
/>
返回
</
Button
>
</
div
>
);
return
(
<
Layout
header=
{
header
}
>
<
Layout
header=
{
header
}
>
<
Table
className=
"list-table"
columns=
{
columns
}
dataSource=
{
Array
.
isArray
(
items
)?
items
:[]
}
loading=
{
loading
}
...
...
src/containers/Authority/EditItem.jsx
View file @
bc005bb2
This diff is collapsed.
Click to expand it.
src/containers/Authority/EditItem.less
0 → 100644
View file @
bc005bb2
:global {
.resource-category {
}
.resource-item {
& > .ant-tree-child-tree {
&:before,
&:after {
content: '';
display: block;
clear: both;
}
}
}
.resource-action {
float: left;
}
.ant-tree-checkbox-indeterminate .ant-tree-checkbox-inner {
background-color: #1DA57A;
border-color: #1DA57A
}
}
src/containers/Authority/List.jsx
View file @
bc005bb2
...
...
@@ -13,7 +13,8 @@ import {
handleUpload
,
filterFormItemLayout
,
PRODUCT_STATUS
,
filterFormItemStyle
filterFormItemStyle
,
enableStatusToString
}
from
'../../utils'
;
import
{
Link
}
from
'react-router'
;
...
...
@@ -21,7 +22,6 @@ import Layout from '../../components/Layout/Layout';
import
MainHeader
from
'../../components/MainHeader/MainHeader'
;
@
connect
(
state
=>
({
items
:
state
.
authority
.
items
,
loading
:
state
.
authority
.
loading
,
...
...
@@ -93,12 +93,12 @@ export default class List extends Component {
const
columns
=
[
{
title
:
'
名称
'
,
title
:
'
角色ID
'
,
dataIndex
:
'name'
,
key
:
'name'
,
width
:
150
,
},
{
title
:
'
描述
'
,
title
:
'
名称
'
,
dataIndex
:
'description'
,
key
:
'description'
,
width
:
100
...
...
@@ -119,6 +119,9 @@ export default class List extends Component {
key
:
'status'
,
width
:
80
,
className
:
'tac'
,
render
:
(
status
)
=>
(
<
span
>
{
enableStatusToString
(
status
)
}
</
span
>
)
},
{
title
:
'操作'
,
key
:
'operation'
,
...
...
@@ -135,9 +138,11 @@ export default class List extends Component {
const
pagination
=
{
total
:
total
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
1
0
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
3
0
,
current
:
parseInt
(
query
.
p
,
10
)
||
1
,
showSizeChanger
:
true
,
showTotal
:
total
=>
`共
${
total
}
条`
,
pageSizeOptions
:
[
'10'
,
'30'
,
'50'
,
'100'
],
onShowSizeChange
:
(
current
,
pageSize
)
=>
{
console
.
log
(
'Current: '
,
current
,
'; PageSize: '
,
pageSize
);
query
.
p
=
current
;
...
...
src/containers/BaseFunction/BaseUpload.jsx
View file @
bc005bb2
...
...
@@ -27,7 +27,8 @@ import Layout from '../../components/Layout/Layout';
import
MainHeader
from
'../../components/MainHeader/MainHeader'
;
import
{
handleUpload
handleUpload
,
FILE_UPLOAD
}
from
'../../utils'
;
@
connect
(
state
=>
({
...
...
@@ -52,14 +53,14 @@ export default class BaseUpload extends Component {
<
Layout
header=
{
header
}
>
<
Row
style=
{
{
padding
:
'20px 20px 20px'
}
}
>
<
Col
span=
"24"
>
<
Upload
.
Dragger
action=
"/api/fileUpload/upload"
multiple=
{
true
}
headers=
{
{
<
Upload
.
Dragger
{
...
FILE_UPLOAD
}
multiple=
{
true
}
headers=
{
{
authorization
:
user
&&
user
.
token
,
}
}
onChange=
{
info
=>
this
.
setState
({
fileList
:
handleUpload
(
info
)})
}
showUploadList=
{
false
}
onPreview=
{
(
e
)
=>
console
.
log
(
e
)
}
onChange=
{
info
=>
this
.
setState
({
fileList
:
handleUpload
(
info
)})
}
showUploadList=
{
false
}
onPreview=
{
(
e
)
=>
console
.
log
(
e
)
}
>
<
p
className=
"ant-upload-drag-icon"
>
<
Icon
type=
"inbox"
/>
...
...
src/containers/CustomMessage/AddItem.jsx
View file @
bc005bb2
...
...
@@ -144,7 +144,7 @@ export default class AddItem extends Component {
<
Form
.
Item
label=
"消息正文"
help=
{
<
div
dangerouslySetInnerHTML=
{
{
__html
:
channelType
===
1
?
'微信跳转链接模板: <a href="此处替换跳转链接">此处替换显示内容</a>'
:
'最多50个字符'
}
}
/>
}
{
...
formItemLayout
}
>
<
Input
placeholder=
"消息正文"
type=
"textarea"
maxLength=
"50"
<
Input
placeholder=
"消息正文"
type=
"textarea"
maxLength=
{
channelType
===
1
?
10000
:
50
}
autosize=
{
{
minRows
:
3
,
maxRows
:
10
}
}
{
...
getFieldProps
('
customMessage
.
contents
')}
/>
</
Form
.
Item
>
...
...
src/containers/CustomMessage/List.jsx
View file @
bc005bb2
...
...
@@ -43,9 +43,11 @@ export default class List extends Component {
const
pagination
=
{
total
:
total
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
1
0
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
3
0
,
current
:
parseInt
(
query
.
p
,
10
)
||
1
,
showSizeChanger
:
true
,
showTotal
:
total
=>
`共
${
total
}
条`
,
pageSizeOptions
:[
'10'
,
'30'
,
'50'
,
'100'
],
onShowSizeChange
:
(
current
,
pageSize
)
=>
{
console
.
log
(
'Current: '
,
current
,
'; PageSize: '
,
pageSize
);
query
.
p
=
current
;
...
...
src/containers/Product/List.jsx
View file @
bc005bb2
...
...
@@ -40,6 +40,7 @@ const columns = [
title
:
'标题'
,
dataIndex
:
'shortTitle'
,
key
:
'shortTitle'
,
width
:
200
,
render
:
(
shortTitle
,
record
)
=>
(<
span
title=
{
shortTitle
}
>
{
(
shortTitle
+
''
).
substring
(
0
,
15
)
}
</
span
>)
},
{
title
:
'募集比率'
,
...
...
@@ -170,9 +171,11 @@ export default class List extends Component {
const
pagination
=
{
total
:
total
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
1
0
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
3
0
,
current
:
parseInt
(
query
.
p
,
10
)
||
1
,
showSizeChanger
:
true
,
showTotal
:
total
=>
`共
${
total
}
条`
,
pageSizeOptions
:[
'10'
,
'30'
,
'50'
,
'100'
],
onShowSizeChange
:
(
current
,
pageSize
)
=>
{
console
.
log
(
'Current: '
,
current
,
'; PageSize: '
,
pageSize
);
query
.
p
=
current
;
...
...
src/containers/Remittance/List.jsx
View file @
bc005bb2
...
...
@@ -101,9 +101,11 @@ export default class List extends Component {
const
pagination
=
{
total
:
total
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
1
0
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
3
0
,
current
:
parseInt
(
query
.
p
,
10
)
||
1
,
showSizeChanger
:
true
,
showTotal
:
total
=>
`共
${
total
}
条`
,
pageSizeOptions
:[
'10'
,
'30'
,
'50'
,
'100'
],
onShowSizeChange
:
(
current
,
pageSize
)
=>
{
console
.
log
(
'Current: '
,
current
,
'; PageSize: '
,
pageSize
);
query
.
p
=
current
;
...
...
src/containers/Resource/EditItem.jsx
View file @
bc005bb2
...
...
@@ -29,15 +29,12 @@ import {
footerFormSubmitLayout
,
userStatusToString
,
formatDateTime
,
NULL
NULL
,
resourceActions
,
enableStatusToString
,
ENABLE_STATUS_LIST
}
from
'../../utils'
;
import
{
STATUS_LIST
,
statusToString
}
from
'./utils'
;
@
connect
(
state
=>
({
loading
:
state
.
resource
.
loading
,
item
:
state
.
resource
.
item
,
...
...
@@ -74,7 +71,7 @@ export default class EditItem extends Component {
data
=
this
.
props
.
form
.
getFieldsValue
();
data
.
id
=
this
.
props
.
params
.
id
;
if
(
isNaN
(
data
.
status
))
{
STATUS_LIST
.
forEach
(
item
=>
{
ENABLE_
STATUS_LIST
.
forEach
(
item
=>
{
if
(
item
.
text
===
data
.
status
)
{
data
.
status
=
item
.
value
}
...
...
@@ -134,15 +131,20 @@ export default class EditItem extends Component {
item
&&
<
Form
className=
"main-form"
horizontal
>
<
Form
.
Item
label=
"
分组
"
{
...
smallFormItemLayout
}
>
<
Form
.
Item
label=
"
类别
"
{
...
smallFormItemLayout
}
>
{
isEdit
?
<
Input
{
...
getFieldProps
('
category
',
{
initialValue
:
item
.
category
})}
/>
<
Select
style=
{
{
width
:
200
}
}
{
...
getFieldProps
('
category
',
{
initialValue
:
item
.
category
})}
>
<
Select
.
Option
value=
"业务管理"
>
业务管理
</
Select
.
Option
>
<
Select
.
Option
value=
"基础功能"
>
基础功能
</
Select
.
Option
>
<
Select
.
Option
value=
"系统管理"
>
系统管理
</
Select
.
Option
>
</
Select
>
:
item
.
category
||
NULL
}
</
Form
.
Item
>
<
Form
.
Item
label=
"
描述
"
{
...
smallFormItemLayout
}
>
<
Form
.
Item
label=
"
名称
"
{
...
smallFormItemLayout
}
>
{
isEdit
?
<
Input
{
...
getFieldProps
('
description
',
{
initialValue
:
item
.
description
})}
/>
...
...
@@ -154,29 +156,26 @@ export default class EditItem extends Component {
{
isEdit
?
<
Select
placeholder=
"请选择状态"
{
...
getFieldProps
('
status
',
{
initialValue
:
s
tatusToString
(
item
.
status
)})}
>
placeholder=
"请选择状态"
{
...
getFieldProps
('
status
',
{
initialValue
:
enableS
tatusToString
(
item
.
status
)})}
>
<
Select
.
Option
value=
"1"
>
系统
</
Select
.
Option
>
<
Select
.
Option
value=
"5"
>
禁用
</
Select
.
Option
>
<
Select
.
Option
value=
"9"
>
启用
</
Select
.
Option
>
</
Select
>
:
(
typeof
item
.
status
!==
'undefined'
?
s
tatusToString
(
item
.
status
)
:
NULL
)
(
typeof
item
.
status
!==
'undefined'
?
enableS
tatusToString
(
item
.
status
)
:
NULL
)
}
</
Form
.
Item
>
<
Form
.
Item
label=
"method"
{
...
smallFormItemLayout
}
>
{
item
.
httpMethod
}
</
Form
.
Item
>
<
Form
.
Item
label=
"url"
{
...
smallFormItemLayout
}
>
{
item
.
url
}
</
Form
.
Item
>
<
Form
.
Item
label=
"controllerName"
{
...
smallFormItemLayout
}
>
{
item
.
controllerName
}
</
Form
.
Item
>
<
Form
.
Item
label=
"actionName"
{
...
smallFormItemLayout
}
>
{
item
.
actionName
}
<
Form
.
Item
label=
"Actions"
{
...
smallFormItemLayout
}
>
{
resourceActions
(
item
.
actionMask
).
map
(({
title
,
mask
})
=>
<
span
key=
{
mask
}
style=
{
{
marginRight
:
'1em'
}
}
>
{
title
}
</
span
>
)
}
</
Form
.
Item
>
<
Form
.
Item
label=
"
注册
时间"
{
...
smallFormItemLayout
}
>
<
Form
.
Item
label=
"
创建
时间"
{
...
smallFormItemLayout
}
>
{
item
.
dateCreated
&&
formatDateTime
(
item
.
dateCreated
)
}
</
Form
.
Item
>
<
Form
.
Item
{
...
footerFormSubmitLayout
}
style=
{
{
marginTop
:
30
}
}
>
...
...
src/containers/Resource/List.jsx
View file @
bc005bb2
...
...
@@ -13,17 +13,15 @@ import {
handleUpload
,
filterFormItemLayout
,
PRODUCT_STATUS
,
filterFormItemStyle
filterFormItemStyle
,
ENABLE_STATUS_LIST
,
enableStatusToString
}
from
'../../utils'
;
import
{
Link
}
from
'react-router'
;
import
Layout
from
'../../components/Layout/Layout'
;
import
MainHeader
from
'../../components/MainHeader/MainHeader'
;
import
{
STATUS_LIST
,
statusToString
}
from
'./utils'
;
@
connect
(
state
=>
({
...
...
@@ -102,37 +100,26 @@ export default class List extends Component {
key
:
'id'
,
width
:
60
},
{
title
:
'
category
'
,
title
:
'
类别
'
,
dataIndex
:
'category'
,
key
:
'category'
,
width
:
80
,
},
{
title
:
'
description
'
,
title
:
'
名称
'
,
dataIndex
:
'description'
,
key
:
'description'
,
width
:
100
},
{
title
:
'Method'
,
dataIndex
:
'httpMethod'
,
key
:
'httpMethod'
,
width
:
60
,
className
:
'tac'
},
{
title
:
'url'
,
dataIndex
:
'url'
,
key
:
'url'
,
width
:
200
},
{
title
:
'actionName'
,
title
:
'资源'
,
dataIndex
:
'controllerName'
,
key
:
'controllerName'
,
width
:
180
,
},
{
title
:
'权限值'
,
dataIndex
:
'actionName'
,
key
:
'actionName'
,
width
:
80
,
className
:
'tac'
},
{
title
:
'controllerName'
,
dataIndex
:
'controllerName'
,
key
:
'controllerName'
,
width
:
180
,
},
{
title
:
'创建时间'
,
dataIndex
:
'dateCreated'
,
...
...
@@ -145,13 +132,13 @@ export default class List extends Component {
</
span
>
)
},
{
title
:
'
status
'
,
title
:
'
状态
'
,
dataIndex
:
'status'
,
key
:
'status'
,
width
:
80
,
className
:
'tac'
,
render
:
(
status
)
=>
(
<
span
>
{
s
tatusToString
(
status
)
}
</
span
>
<
span
>
{
enableS
tatusToString
(
status
)
}
</
span
>
)
},
{
title
:
'操作'
,
...
...
@@ -169,9 +156,11 @@ export default class List extends Component {
const
pagination
=
{
total
:
total
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
1
0
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
3
0
,
current
:
parseInt
(
query
.
p
,
10
)
||
1
,
showSizeChanger
:
true
,
showTotal
:
total
=>
`共
${
total
}
条`
,
pageSizeOptions
:[
'10'
,
'30'
,
'50'
,
'100'
],
onShowSizeChange
:
(
current
,
pageSize
)
=>
{
console
.
log
(
'Current: '
,
current
,
'; PageSize: '
,
pageSize
);
query
.
p
=
current
;
...
...
src/containers/Resource/utils.js
View file @
bc005bb2
export
const
STATUS
=
{
1
:
'系统'
,
5
:
'禁用'
,
9
:
'启用'
};
export
function
statusToString
(
status
)
{
return
STATUS
[
status
]
||
'未定义('
+
status
+
')'
;
}
export
const
STATUS_LIST
=
Object
.
keys
(
STATUS
).
map
(
key
=>
{
return
{
value
:
key
,
text
:
STATUS
[
key
]}
});
src/containers/Trade/List.jsx
View file @
bc005bb2
...
...
@@ -148,9 +148,11 @@ export default class List extends Component {
const
pagination
=
{
total
:
total
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
1
0
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
3
0
,
current
:
parseInt
(
query
.
p
,
10
)
||
1
,
showSizeChanger
:
true
,
showTotal
:
total
=>
`共
${
total
}
条`
,
pageSizeOptions
:[
'10'
,
'30'
,
'50'
,
'100'
],
onShowSizeChange
:
(
current
,
pageSize
)
=>
{
console
.
log
(
'Current: '
,
current
,
'; PageSize: '
,
pageSize
);
query
.
p
=
current
;
...
...
src/containers/Users/List.jsx
View file @
bc005bb2
...
...
@@ -128,9 +128,11 @@ export default class List extends Component {
const
pagination
=
{
total
:
total
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
1
0
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
3
0
,
current
:
parseInt
(
query
.
p
,
10
)
||
1
,
showSizeChanger
:
true
,
showTotal
:
total
=>
`共
${
total
}
条`
,
pageSizeOptions
:[
'10'
,
'30'
,
'50'
,
'100'
],
onShowSizeChange
:
(
current
,
pageSize
)
=>
{
console
.
log
(
'Current: '
,
current
,
'; PageSize: '
,
pageSize
);
query
.
p
=
current
;
...
...
src/containers/Withdraw/List.jsx
View file @
bc005bb2
...
...
@@ -97,9 +97,11 @@ export default class List extends Component {
const
pagination
=
{
total
:
total
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
1
0
,
pageSize
:
parseInt
(
query
.
s
,
10
)
||
3
0
,
current
:
parseInt
(
query
.
p
,
10
)
||
1
,
showSizeChanger
:
true
,
showTotal
:
total
=>
`共
${
total
}
条`
,
pageSizeOptions
:[
'10'
,
'30'
,
'50'
,
'100'
],
onShowSizeChange
:
(
current
,
pageSize
)
=>
{
console
.
log
(
'Current: '
,
current
,
'; PageSize: '
,
pageSize
);
query
.
p
=
current
;
...
...
src/sagas/RESTful.js
View file @
bc005bb2
import
{
takeLatest
}
from
'redux-saga'
;
import
{
take
,
call
,
put
,
fork
,
cancel
,
select
}
from
'redux-saga/effects'
;
/*
import {takeLatest} from 'redux-saga';
import {take, call, put, fork, cancel, select
, race
} from 'redux-saga/effects';
import {message} from 'antd';
export default class RESTful {
constructor
()
{
constructor(
id
) {
this.id = id;
}
index() {
...
...
@@ -27,26 +27,48 @@ export default class RESTful {
}
}
watchIndex() {
const self = this;
return function*() {
while (true) {
const {query} = yield take('FETCH_' + self.id + '_LIST');
yield fork(self.index(), query);
}
};
}
show() {
const
{
api
,
id
}
=
this
;
const self = this;
const {api} = this;
return function*(id) {
try {
const result = yield call(api.show, id);
yield put({
type
:
'FETCH_'
+
id
+
'_ITEM_SUCCESS'
,
type: 'FETCH_' +
self.
id + '_ITEM_SUCCESS',
result
});
} catch (err) {
console.log(err);
message.error(err);
yield put({
type
:
'FETCH_'
+
id
+
'_ITEM_FAILED'
,
type: 'FETCH_' +
self.
id + '_ITEM_FAILED',
err
});
}
}
}
watchShow() {
const self = this;
return function*() {
while (true) {
const {id} = yield take('FETCH_' + self.id + '_ITEM');
yield fork(self.show(), id);
}
}
}
create() {
const {api, id} = this;
return function*(data) {
...
...
@@ -66,4 +88,191 @@ export default class RESTful {
}
}
}
watchCreate() {
const self = this;
return function*() {
while (true) {
const {data} = yield take('CREATE_' + self.id + '_ITEM');
yield fork(self.create(), data);
}
}
}
update() {
const {api, id} = this;
return function*(data) {
try {
yield call(api.update, data);
message.success('修改成功!');
yield put({
type: 'UPDATE_' + id + '_ITEM_SUCCESS',
item: data
});
} catch (err) {
console.log(err);
message.error(err);
yield put({
type: 'UPDATE_' + id + '_ITEM_FAILED',
err
});
}
}
}
watchUpdate() {
const self = this;
return function*() {
while (true) {
yield take('UPDATE_' + self.id);
yield put({
type: 'UPDATE_' + self.id + '_START'
});
const {data} = yield race({
data: take('UPDATE_' + self.id + '_ITEM'),
canceled: take('CANCEL_UPDATE_' + self.id)
});
if (data && data.item) {
yield fork(self.update(), data.item);
}
yield put({
type: 'UPDATE_' + self.id + '_END'
});
}
}
}
delete() {
const self = this;
const {api} = this;
return function*(id) {
try {
const result = yield call(api.show, id);
yield put({
type: 'DELETE_' + self.id + '_ITEM_SUCCESS',
result
});
} catch (err) {
console.log(err);
message.error(err);
yield put({
type: 'DELETE_' + self.id + '_ITEM_FAILED',
err
});
}
}
}
watchDelete() {
const self = this;
return function*() {
while (true) {
const {id} = yield take('DELETE_' + self.id + '_ITEM');
yield fork(self.delete(), id);
}
}
}
patch() {
const {api, id} = this;
return function*(data) {
try {
yield call(api.update, data);
message.success('操作成功!');
yield put({
type: 'PATCH_' + id + '_ITEM_SUCCESS',
item: data
});
} catch (err) {
console.log(err);
message.error(err);
yield put({
type: 'PATCH_' + id + '_ITEM_FAILED',
err
});
}
}
}
watchPatch() {
const self = this;
return function*() {
while (true) {
const {id} = yield take('PATCH_' + self.id + '_ITEM');
yield fork(self.patch(), id);
}
}
}
watch() {
const self = this;
const mask = this.mask;
const tasks = [
self.watchIndex,
self.watchCreate,
//savenull,
self.watchShow,
//editnull,
self.watchUpdate,
self.watchDelete,
self.watchPatch
];
return function*() {
tasks.forEach((task, index)=> {
const mi = 1 << index;
if (task && ((mask & mi ) === mi)) {
yield fork(task());
}
});
}
}
actions() {
const loadingFn = function (state) {
return {...state, loading: true};
};
const failedFn = function (state, action) {
return {...state, loading: false, err: action.err}
};
const editStartFn = function (state) {
return {...state, isEdit: true}
};
const editEndFn = function (state) {
return {...state, isEdit: false};
};
const itemsFn = function (state, action) {
return {...state, loading: false, items: action.items, total: action.total}
};
const itemFn = function (state, action) {
return {...state, loading: false, item: {...state.item, ...action.item}}
};
const id = this.id;
return {
['INDEX_' + id ]: loadingFn,
['INDEX_' + id + '_SUCCESS']: itemsFn,
['INDEX_' + id + '_FAILED']: failedFn,
['SHOW_' + id]: loadingFn,
['SHOW_' + id + '_SUCCESS']: itemFn,
['SHOW_' + id + '_FAILED']: failedFn,
['CREATE_' + id]: loadingFn,
['CREATE_' + id + '_SUCCESS']: itemFn,
['CREATE_' + id + '_FAILED']: failedFn,
['UPDATE_' + id]: loadingFn,
['UPDATE_' + id + '_SUCCESS']: itemFn,
['UPDATE_' + id + '_FAILED']: failedFn,
['ENTER_EDIT' + id]: editStartFn,
['EXIT_EDIT_' + id]: editEndFn,
['DELETE_' + id]: loadingFn,
['DELETE_' + id + '_SUCCESS']: itemFn,
['DELETE_' + id + '_FAILED']: failedFn,
['PATCH_' + id]: loadingFn,
['PATCH_' + id + '_SUCCESS']: itemFn,
['PATCH_' + id + '_FAILED']: failedFn,
}
}
}
*/
src/sagas/announcement.js
View file @
bc005bb2
...
...
@@ -5,11 +5,11 @@ import {message} from 'antd';
function
*
getList
(
query
)
{
try
{
const
{
total
,
announcements
}
=
yield
call
(
fetchList
,
query
);
const
{
total
,
list
}
=
yield
call
(
fetchList
,
query
);
yield
put
({
type
:
'FETCH_ANNOUNCEMENT_LIST_SUCCESS'
,
total
,
items
:
announcements
items
:
list
});
}
catch
(
err
)
{
console
.
log
(
err
);
...
...
src/sagas/authority.js
View file @
bc005bb2
...
...
@@ -5,11 +5,11 @@ import {message} from 'antd';
function
*
getList
(
query
)
{
try
{
const
{
total
,
authorities
}
=
yield
call
(
fetchList
,
query
);
const
{
total
,
list
}
=
yield
call
(
fetchList
,
query
);
yield
put
({
type
:
'FETCH_AUTHORITY_LIST_SUCCESS'
,
total
,
items
:
authorities
items
:
list
});
}
catch
(
err
)
{
console
.
log
(
err
);
...
...
src/sagas/customMessage.js
View file @
bc005bb2
...
...
@@ -5,11 +5,11 @@ import {message} from 'antd';
function
*
getList
(
query
)
{
try
{
const
{
total
,
customMessageViewDOs
}
=
yield
call
(
fetchList
,
query
);
const
{
total
,
list
}
=
yield
call
(
fetchList
,
query
);
yield
put
({
type
:
'FETCH_MESSAGE_LIST_SUCCESS'
,
total
,
items
:
customMessageViewDOs
items
:
list
});
}
catch
(
err
)
{
console
.
log
(
err
);
...
...
src/sagas/product.js
View file @
bc005bb2
...
...
@@ -5,11 +5,11 @@ import {message} from 'antd';
function
*
getList
(
query
)
{
try
{
const
{
total
,
items
}
=
yield
call
(
fetchList
,
query
);
const
{
total
,
list
}
=
yield
call
(
fetchList
,
query
);
yield
put
({
type
:
'FETCH_PRODUCT_LIST_SUCCESS'
,
total
,
items
items
:
list
});
}
catch
(
err
)
{
console
.
log
(
err
);
...
...
src/sagas/remittance.js
View file @
bc005bb2
...
...
@@ -7,11 +7,11 @@ import {message} from 'antd';
function
*
getList
(
query
)
{
try
{
const
{
total
,
audits
}
=
yield
call
(
fetchList
,
query
);
const
{
total
,
list
}
=
yield
call
(
fetchList
,
query
);
yield
put
({
type
:
'FETCH_REMITTANCE_LIST_SUCCESS'
,
total
,
items
:
audits
items
:
list
});
}
catch
(
err
)
{
console
.
log
(
err
);
...
...
src/sagas/resource.js
View file @
bc005bb2
...
...
@@ -5,11 +5,11 @@ import {message} from 'antd';
function
*
getList
(
query
)
{
try
{
const
{
total
,
resources
}
=
yield
call
(
fetchList
,
query
);
const
{
total
,
list
}
=
yield
call
(
fetchList
,
query
);
yield
put
({
type
:
'FETCH_RESOURCE_LIST_SUCCESS'
,
total
,
items
:
resources
items
:
list
});
}
catch
(
err
)
{
console
.
log
(
err
);
...
...
src/sagas/trade.js
View file @
bc005bb2
...
...
@@ -5,11 +5,11 @@ import {message} from 'antd';
function
*
getList
(
query
)
{
try
{
const
{
total
,
trades
}
=
yield
call
(
fetchList
,
query
);
const
{
total
,
list
}
=
yield
call
(
fetchList
,
query
);
yield
put
({
type
:
'FETCH_TRADE_LIST_SUCCESS'
,
total
,
items
:
trades
items
:
list
});
}
catch
(
err
)
{
console
.
log
(
err
);
...
...
src/sagas/user.js
View file @
bc005bb2
...
...
@@ -45,10 +45,10 @@ function* watchAddItem() {
function
*
getList
(
query
)
{
try
{
const
{
users
,
total
}
=
yield
call
(
fetchList
,
query
);
const
{
list
,
total
}
=
yield
call
(
fetchList
,
query
);
yield
put
({
type
:
'FETCH_USER_LIST_SUCCESS'
,
items
:
users
,
items
:
list
,
total
});
}
catch
(
err
)
{
...
...
src/sagas/withdraw.js
View file @
bc005bb2
...
...
@@ -5,11 +5,11 @@ import {message} from 'antd';
function
*
getList
(
query
)
{
try
{
const
{
total
,
audits
}
=
yield
call
(
fetchList
,
query
);
const
{
total
,
list
}
=
yield
call
(
fetchList
,
query
);
yield
put
({
type
:
'FETCH_WITHDRAW_LIST_SUCCESS'
,
total
,
items
:
audits
items
:
list
});
}
catch
(
err
)
{
console
.
log
(
err
);
...
...
src/services/admin/authority.js
View file @
bc005bb2
...
...
@@ -2,7 +2,7 @@ import xFetch from '../xFetch';
import
{
serialize
}
from
'../../utils'
;
export
async
function
fetchList
(
query
)
{
return
xFetch
(
'/api/admin/authorities'
+
'?'
+
serialize
(
query
));
return
xFetch
(
'/api/admin/authorities'
+
'?'
+
serialize
({
s
:
30
,
...
query
}
));
}
export
async
function
fetchItem
(
id
)
{
...
...
src/services/admin/resource.js
View file @
bc005bb2
...
...
@@ -2,7 +2,7 @@ import xFetch from '../xFetch';
import
{
serialize
}
from
'../../utils'
;
export
async
function
fetchList
(
query
)
{
return
xFetch
(
'/api/admin/resources'
+
'?'
+
serialize
(
query
));
return
xFetch
(
'/api/admin/resources'
+
'?'
+
serialize
({
s
:
30
,
...
query
}
));
}
export
async
function
fetchItem
(
id
)
{
...
...
src/services/announcement.js
View file @
bc005bb2
...
...
@@ -4,7 +4,7 @@ import {serialize} from '../utils';
export
async
function
fetchList
(
query
)
{
const
data
=
{...
query
};
delete
data
.
title
;
return
xFetch
(
'/api/announcements'
+
'?'
+
serialize
(
data
));
return
xFetch
(
'/api/announcements'
+
'?'
+
serialize
(
{
s
:
30
,
...
data
}
));
}
export
async
function
fetchItem
(
id
)
{
...
...
src/services/customMessage.js
View file @
bc005bb2
...
...
@@ -2,8 +2,7 @@ import xFetch from './xFetch';
import
{
serialize
}
from
'../utils'
;
export
async
function
fetchList
(
query
)
{
const
data
=
{...
query
};
return
xFetch
(
'/api/customMessages'
+
'?'
+
serialize
(
data
));
return
xFetch
(
'/api/customMessages'
+
'?'
+
serialize
({
s
:
30
,
...
query
}));
}
export
async
function
fetchItem
(
id
)
{
...
...
src/services/product.js
View file @
bc005bb2
...
...
@@ -2,7 +2,7 @@ import xFetch from './xFetch';
import
{
serialize
}
from
'../utils'
;
export
async
function
fetchList
(
query
)
{
return
xFetch
(
'/api/products'
+
'?'
+
serialize
(
query
));
return
xFetch
(
'/api/products'
+
'?'
+
serialize
(
{
s
:
30
,
...
query
}
));
}
export
async
function
fetchCates
()
{
...
...
src/services/remittance.js
View file @
bc005bb2
...
...
@@ -2,7 +2,7 @@ import xFetch from './xFetch';
import
{
serialize
}
from
'../utils'
;
export
async
function
fetchList
(
query
)
{
return
xFetch
(
'/api/remittance/audits'
+
'?'
+
serialize
(
query
));
return
xFetch
(
'/api/remittance/audits'
+
'?'
+
serialize
(
{
s
:
30
,
...
query
}
));
}
export
async
function
fetchItem
(
id
)
{
return
xFetch
(
'/api/remittance/audits/'
+
id
);
...
...
src/services/trade.js
View file @
bc005bb2
...
...
@@ -2,7 +2,7 @@ import xFetch from './xFetch';
import
{
serialize
}
from
'../utils'
;
export
async
function
fetchList
(
query
)
{
return
xFetch
(
'/api/trades'
+
'?'
+
serialize
(
query
));
return
xFetch
(
'/api/trades'
+
'?'
+
serialize
(
{
s
:
30
,
...
query
}
));
}
export
async
function
fetchItem
(
id
)
{
return
xFetch
(
'/api/trades/'
+
id
);
...
...
src/services/user.js
View file @
bc005bb2
...
...
@@ -16,7 +16,7 @@ export async function create(data) {
}
export
async
function
fetchList
(
query
)
{
return
xFetch
(
'/api/admin/users'
+
'?'
+
serialize
(
query
));
return
xFetch
(
'/api/admin/users'
+
'?'
+
serialize
(
{
s
:
30
,
...
query
}
));
}
export
async
function
fetchItem
(
id
)
{
...
...
src/services/withdraw.js
View file @
bc005bb2
...
...
@@ -2,7 +2,7 @@ import xFetch from './xFetch';
import
{
serialize
}
from
'../utils'
;
export
async
function
fetchList
(
query
)
{
return
xFetch
(
'/api/withdraw/audits'
+
'?'
+
serialize
(
query
));
return
xFetch
(
'/api/withdraw/audits'
+
'?'
+
serialize
(
{
s
:
30
,
...
query
}
));
}
export
async
function
fetchItem
(
id
)
{
...
...
src/utils.js
View file @
bc005bb2
...
...
@@ -4,6 +4,8 @@
export
const
NULL
=
'_____?_____'
;
export
const
FILE_UPLOAD
=
{
action
:
'/api/fileUpload'
};
export
function
serialize
(
obj
,
prefix
)
{
if
(
obj
)
{
var
str
=
[];
...
...
@@ -259,13 +261,32 @@ export function cr2br(text) {
}
export
const
ACTIONPERMISSION
=
{
index
:
1
<<
0
,
create
:
1
<<
1
,
save
:
1
<<
2
,
show
:
1
<<
3
,
edit
:
1
<<
4
,
update
:
1
<<
5
,
'delete'
:
1
<<
6
,
patch
:
1
<<
7
export
function
resourceActions
(
mask
)
{
return
resourceActions
.
enum
.
reduce
((
arr
,
action
,
index
)
=>
{
const
value
=
1
<<
index
;
if
((
mask
&
value
)
===
value
)
{
arr
.
push
({
title
:
action
,
mask
:
value
});
}
return
arr
;
},
[]);
}
resourceActions
.
enum
=
[
'列表index'
,
'创建create'
,
'save'
,
'详情show'
,
'edit'
,
'编辑update'
,
'删除delete'
,
'审核patch'
];
export
const
ENABLE_STATUS
=
{
1
:
'系统'
,
5
:
'禁用'
,
9
:
'启用'
};
export
function
enableStatusToString
(
status
)
{
return
ENABLE_STATUS
[
status
]
||
'未定义('
+
status
+
')'
;
}
export
const
ENABLE_STATUS_LIST
=
Object
.
keys
(
ENABLE_STATUS
).
map
(
key
=>
{
return
{
value
:
key
,
text
:
ENABLE_STATUS
[
key
]}
});
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