Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
前端-黄佳鑫
jinfa-platform
Commits
df1e8375
Commit
df1e8375
authored
Aug 20, 2020
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对接会员规则相关
parent
135b04fb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
22 deletions
+54
-22
index.tsx
src/components/StandardTable/index.tsx
+9
-8
index.tsx
src/pages/member/memberUpgradeRule/index.tsx
+45
-14
No files found.
src/components/StandardTable/index.tsx
View file @
df1e8375
...
...
@@ -15,20 +15,20 @@ export default class StandardTable extends React.PureComponent<StandardTableProp
state
=
{
page
:
1
,
size
:
0
,
size
:
1
0
,
};
handlePaginationChange
=
(
page
:
number
,
size
:
number
)
=>
{
const
{
pagination
=
{},
onPaginationChange
}
=
this
.
props
;
const
{
current
,
pageSize
}
=
pagination
;
// 单独控制当前页 或 当前页数
//
if (!('current' in pagination)) {
// this.setState({
current });
//
}
//
if (!('pageSize' in pagination)) {
// this.setState({
pageSize });
//
}
//
内部自己维护 page、size,
单独控制当前页 或 当前页数
if
(
!
(
'current'
in
pagination
))
{
this
.
setState
({
page
:
current
});
}
if
(
!
(
'pageSize'
in
pagination
))
{
this
.
setState
({
size
:
pageSize
});
}
if
(
onPaginationChange
)
{
onPaginationChange
(
page
,
size
);
...
...
@@ -44,6 +44,7 @@ export default class StandardTable extends React.PureComponent<StandardTableProp
pagination
=
{},
loading
,
className
,
onPaginationChange
,
...
restProps
}
=
this
.
props
;
...
...
src/pages/member/memberUpgradeRule/index.tsx
View file @
df1e8375
...
...
@@ -4,6 +4,7 @@ import {
Input
,
Button
,
Form
,
message
,
}
from
'antd'
;
import
{
ColumnType
}
from
'antd/lib/table/interface'
;
import
{
PublicApi
}
from
'@/services/api'
;
...
...
@@ -73,8 +74,6 @@ const EditableCell: React.FC<EditableCellProps> = ({
try
{
const
values
=
await
form
.
validateFields
();
console
.
log
(
'values'
,
values
)
// toggleEdit();
handleSave
({
...
record
,
...
...
@@ -120,18 +119,17 @@ interface Columns extends ColumnType<any> {
rules
?:
Array
<
any
>
;
}
const
fetchData
=
async
(
params
:
any
)
=>
{
const
res
=
await
PublicApi
.
getMemberManageLevelRulePage
(
params
);
return
res
.
data
;
};
const
MemberUpgradeRule
:
React
.
FC
<
[]
>
=
()
=>
{
const
[
page
,
setPage
]
=
useState
(
1
);
const
[
size
,
setSize
]
=
useState
(
10
);
const
[
total
,
setTotal
]
=
useState
(
0
);
const
[
dataSource
,
setDataSource
]
=
useState
([]);
const
[
listLoading
,
setListLoading
]
=
useState
(
true
);
const
[
submitLoading
,
setSubmitLoading
]
=
useState
(
false
);
const
getRuleList
=
async
(
params
)
=>
{
setListLoading
(
true
);
const
res
=
await
PublicApi
.
getMemberManageLevelRulePage
(
params
);
if
(
res
.
code
===
1000
)
{
...
...
@@ -144,10 +142,10 @@ const MemberUpgradeRule: React.FC<[]> = () => {
useEffect
(()
=>
{
getRuleList
({
current
:
1
,
pageSize
:
1
,
current
:
page
,
pageSize
:
size
,
});
},
[]);
},
[
page
,
size
]);
const
columns
:
Columns
[]
=
[
{
...
...
@@ -175,14 +173,45 @@ const MemberUpgradeRule: React.FC<[]> = () => {
];
const
handlePaginationChange
=
(
page
:
number
,
size
:
number
)
=>
{
console
.
log
(
page
,
size
)
setPage
(
page
);
setSize
(
size
);
};
// 重新保存 dataSource
const
handleSave
=
row
=>
{
console
.
log
(
'new row'
,
row
)
const
newData
=
[...
dataSource
];
const
index
=
newData
.
findIndex
(
item
=>
item
.
id
===
row
.
id
);
const
item
=
newData
[
index
];
newData
.
splice
(
index
,
1
,
{
...
item
,
...
row
,
point
:
+
row
.
point
,
});
setDataSource
(
newData
);
};
const
handleSubmit
=
()
=>
{};
const
handleSubmit
=
async
()
=>
{
if
(
!
dataSource
.
length
)
{
return
;
}
const
payload
=
dataSource
.
map
(
item
=>
({
id
:
item
.
id
,
point
:
item
.
point
,
}));
setSubmitLoading
(
true
);
const
res
=
await
PublicApi
.
postMemberManageLevelRuleSetpoint
(
payload
);
if
(
res
.
code
===
1000
)
{
message
.
success
(
'保存成功'
);
getRuleList
({
current
:
page
,
pageSize
:
size
,
});
}
setSubmitLoading
(
false
);
};
const
components
=
{
body
:
{
...
...
@@ -212,7 +241,7 @@ const MemberUpgradeRule: React.FC<[]> = () => {
],
};
const
newColumns
:
any
=
columns
.
map
(
col
=>
{
const
newColumns
:
any
=
columns
.
map
(
col
=>
{
if
(
!
col
.
editable
)
{
return
col
;
}
...
...
@@ -243,6 +272,7 @@ const MemberUpgradeRule: React.FC<[]> = () => {
<
Button
type=
"primary"
icon=
{
<
ContainerOutlined
/>
}
loading=
{
submitLoading
}
onClick=
{
handleSubmit
}
>
保存
...
...
@@ -263,6 +293,7 @@ const MemberUpgradeRule: React.FC<[]> = () => {
rowClassName=
{
()
=>
'editable-row'
}
loading=
{
listLoading
}
pagination=
{
{
pageSize
:
size
,
total
,
}
}
onPaginationChange=
{
handlePaginationChange
}
...
...
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