Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-admin
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
linweijiong
jinfa-admin
Commits
462d055c
Commit
462d055c
authored
Dec 08, 2021
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: 完善代码
parent
88cef3d4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 deletions
+22
-12
index.tsx
src/components/FlowRecords/index.tsx
+22
-12
No files found.
src/components/FlowRecords/index.tsx
View file @
462d055c
...
...
@@ -5,7 +5,7 @@
* @LastEditTime: 2021-06-04 13:48:09
* @Description: 内、外部流传记录
*/
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
,
useRef
}
from
'react'
;
import
PolymericTable
from
'@/components/PolymericTable'
;
import
{
EditableColumns
}
from
'@/components/PolymericTable/interface'
;
import
MellowCard
,
{
MellowCardProps
}
from
'@/components/MellowCard'
;
...
...
@@ -35,7 +35,7 @@ export interface FetchListParams {
pageSize
:
number
,
}
interface
IProps
extends
MellowCardProps
{
export
interface
IProps
extends
MellowCardProps
{
/**
* 外部流转记录数据源,与 fetchOuterList 不能共存
* 如果两个同时存在 outerDataSource 优先
...
...
@@ -66,12 +66,12 @@ interface IProps extends MellowCardProps {
* 获取外部流转记录方法,与 outerDataSource 不能共存
* 如果两个同时存在 outerDataSource 优先
*/
fetchOuterList?:
<
T
extends
ListRes
>
(params: FetchListParams) =
>
Promise
<
T
>
,
fetchOuterList?:
(params: FetchListParams) =
>
Promise
<
ListRes
>
,
/**
* 获取内部流转记录方法,与 innerDataSource 不能共存
* 如果两个同时存在 innerDataSource 优先
*/
fetchInnerList?:
<
T
extends
ListRes
>
(params: FetchListParams) =
>
Promise
<
T
>
,
fetchInnerList?:
(params: FetchListParams) =
>
Promise
<
ListRes
>
,
}
const FlowRecords: React.FC
<
IProps
>
= (props: IProps) =
>
{
...
...
@@ -96,19 +96,21 @@ const FlowRecords: React.FC<IProps> = (props: IProps) => {
const
[
innerLoading
,
setInnerLoading
]
=
useState
(
false
);
const
[
radioValue
,
setRadioValue
]
=
useState
<
(
'inner'
|
'outer'
)
>
(
'inner'
);
const
mounted
=
useRef
(
false
);
const
getOuterList
=
(
params
:
FetchListParams
)
=>
{
if
(
outerDataSource
)
{
setOuterList
({
data
:
outerDataSource
,
totalCount
:
outerDataSource
.
length
});
return
;
}
if
(
fetchOuterList
)
{
if
(
fetchOuterList
)
{
setOuterLoading
(
true
);
fetchOuterList
(
params
).
then
(
res
=>
{
if
(
res
)
{
setOuterList
(
res
);
mounted
.
current
&&
setOuterList
(
res
);
}
}).
finally
(()
=>
{
setOuterLoading
(
false
);
mounted
.
current
&&
setOuterLoading
(
false
);
});
}
};
...
...
@@ -122,15 +124,23 @@ const FlowRecords: React.FC<IProps> = (props: IProps) => {
setInnerLoading
(
true
);
fetchInnerList
(
params
).
then
(
res
=>
{
if
(
res
)
{
setInnerList
(
res
);
mounted
.
current
&&
setInnerList
(
res
);
}
}).
finally
(()
=>
{
setInnerLoading
(
false
);
mounted
.
current
&&
setInnerLoading
(
false
);
});
}
};
useEffect
(()
=>
{
mounted
.
current
=
true
;
return
()
=>
{
mounted
.
current
=
false
;
};
},
[]);
useEffect
(()
=>
{
getOuterList
({
current
:
outerPage
,
pageSize
:
outerSize
,
...
...
@@ -199,7 +209,7 @@ const FlowRecords: React.FC<IProps> = (props: IProps) => {
}
:
null
),
].
filter
(
Boolean
);
].
filter
(
Boolean
)
as
[]
;
return
(
<
MellowCard
...
...
@@ -224,7 +234,7 @@ const FlowRecords: React.FC<IProps> = (props: IProps) => {
?
{
current
:
outerPage
,
pageSize
:
outerSize
,
total
:
outerList
.
totalCount
,
total
:
outerList
?
.
totalCount
,
}
:
null
)
}
...
...
@@ -242,7 +252,7 @@ const FlowRecords: React.FC<IProps> = (props: IProps) => {
?
{
current
:
innerPage
,
pageSize
:
innerSize
,
total
:
innerList
.
totalCount
,
total
:
innerList
?
.
totalCount
,
}
:
null
)
}
...
...
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