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
project
jinfa-admin
Commits
b3018176
Commit
b3018176
authored
Aug 02, 2021
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 嵌套表格默认不显示分页
parent
ccb67bd0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
12 deletions
+13
-12
index.tsx
src/components/NestTable/index.tsx
+6
-5
index.tsx
...System/orderDetail/components/orderDeleveRecord/index.tsx
+7
-7
No files found.
src/components/NestTable/index.tsx
View file @
b3018176
import
React
,
{
useCallback
}
from
'react'
import
{
Table
}
from
'antd'
import
{
TableProps
,
ColumnsType
}
from
'antd/es/table'
import
{
TableProps
,
ColumnsType
,
TablePaginationConfig
}
from
'antd/es/table'
import
{
CaretRightOutlined
,
CaretDownOutlined
}
from
'@ant-design/icons'
export
interface
NestTableProps
extends
TableProps
<
any
>
{
...
...
@@ -8,6 +8,7 @@ export interface NestTableProps extends TableProps<any> {
* 扁平化的递归嵌套类型, 后面一项永远为前一项的直系子集
*/
NestColumns
:
ColumnsType
<
any
>
[],
childPagination
?:
false
|
TablePaginationConfig
,
// 指定获得的子集数据类型
childrenDataKey
:
string
}
...
...
@@ -17,7 +18,7 @@ export interface NestTableProps extends TableProps<any> {
* @todo 实现无限嵌套, 目前暂时实现两层
*/
const
NestTable
:
React
.
FC
<
NestTableProps
>
=
(
props
)
=>
{
const
{
NestColumns
,
childrenDataKey
,
dataSource
,
...
resetProps
}
=
props
const
{
NestColumns
,
childrenDataKey
,
pagination
=
false
,
childPagination
=
false
,
dataSource
,
...
resetProps
}
=
props
if
(
NestColumns
.
length
>
2
)
{
throw
new
Error
(
'暂时不支持2项以上的嵌套table'
)
}
...
...
@@ -29,9 +30,10 @@ const NestTable:React.FC<NestTableProps> = (props) => {
columns=
{
childColumns
}
dataSource=
{
record
[
childrenDataKey
]
||
[]
}
rowKey=
'id'
pagination=
{
childPagination
}
/>
},
[
childColumns
,
childrenDataKey
])
return
(
<
Table
columns=
{
parentColumns
}
...
...
@@ -53,4 +55,4 @@ const NestTable:React.FC<NestTableProps> = (props) => {
NestTable
.
defaultProps
=
{}
export
default
NestTable
\ No newline at end of file
export
default
NestTable
src/pages/orderSystem/orderDetail/components/orderDeleveRecord/index.tsx
View file @
b3018176
...
...
@@ -198,12 +198,12 @@ const OrderDeleveRecord:React.FC<OrderDeleveRecordProps> = (props) => {
key
:
'createTime'
,
render
:
text
=>
formatTimeString
(
text
)
},
{
title
:
'内部状态'
,
dataIndex
:
'innerStatusName'
,
align
:
'center'
,
key
:
'innerStatusName'
,
},
//
{
//
title: '内部状态',
//
dataIndex: 'innerStatusName',
//
align: 'center',
//
key: 'innerStatusName',
//
},
]
return
(
...
...
@@ -227,7 +227,7 @@ const OrderDeleveRecord:React.FC<OrderDeleveRecordProps> = (props) => {
<
NestTable
NestColumns=
{
[
sideOrderCols
,
sideChildrenCols
]
}
rowKey=
'batchNo'
childrenDataKey=
'product
Id
'
childrenDataKey=
'product
s
'
dataSource=
{
deliveryDetails
}
/>
</
Tabs
.
TabPane
>
...
...
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