Commit b3018176 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 嵌套表格默认不显示分页

parent ccb67bd0
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
......@@ -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='productId'
childrenDataKey='products'
dataSource={deliveryDetails}
/>
</Tabs.TabPane>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment