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
shenshaokai
jinfa-platform
Commits
04919f7e
Commit
04919f7e
authored
Jul 16, 2021
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: 抽离并暴露类型声明
parent
9101327b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
88 deletions
+100
-88
EditableCellTable.tsx
src/components/PolymericTable/EditableCellTable.tsx
+3
-3
NormalTable.tsx
src/components/PolymericTable/NormalTable.tsx
+8
-82
index.tsx
src/components/PolymericTable/index.tsx
+9
-0
interface.d.ts
src/components/PolymericTable/interface.d.ts
+80
-3
No files found.
src/components/PolymericTable/EditableCellTable.tsx
View file @
04919f7e
...
...
@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-08-20 16:15:59
* @LastEditors: XieZhiXiong
* @LastEditTime: 202
0-12-15 16:45:41
* @LastEditTime: 202
1-07-16 14:27:55
* @Description: 基于 NormalTable 简单的可编辑列 Table
*/
import
React
,
{
useContext
,
useState
,
useEffect
,
useRef
}
from
'react'
;
...
...
@@ -13,7 +13,7 @@ import {
Form
,
message
,
}
from
'antd'
;
import
{
StandardTableProps
,
EditableCellProps
,
EditableColumn
s
}
from
'./interface'
;
import
{
NormalTableProps
,
EditableCellProp
s
}
from
'./interface'
;
import
NormalTable
from
'./NormalTable'
;
const
EditableContext
=
React
.
createContext
<
any
>
({});
...
...
@@ -122,7 +122,7 @@ const EditableCell: React.FC<EditableCellProps> = ({
return
<
td
{
...
restProps
}
>
{
childNode
}
</
td
>;
};
const
EditableCellTable
:
React
.
FC
<
StandardTableProps
>
=
props
=>
{
const
EditableCellTable
:
React
.
FC
<
NormalTableProps
<
{}
>
>
=
props
=>
{
const
components
=
{
body
:
{
row
:
EditableRow
,
...
...
src/components/PolymericTable/NormalTable.tsx
View file @
04919f7e
...
...
@@ -7,94 +7,20 @@
*/
import
React
,
{
useState
,
useEffect
,
useRef
,
useImperativeHandle
}
from
'react'
;
import
{
Table
,
Pagination
}
from
'antd'
;
import
{
TableProps
}
from
'antd/lib/table'
;
import
{
PaginationProps
}
from
'antd/lib/pagination'
;
import
classNames
from
'classnames'
;
import
SearchForm
,
{
SearchFormIProps
}
from
'./SearchForm'
;
import
{
NormalTableRefHandleType
,
NormalTableProps
,
SearchValuesType
,
FetchResponse
,
FetchParamsType
,
}
from
'./interface'
;
import
SearchForm
from
'./SearchForm'
;
import
styles
from
'./index.less'
;
const
PAGE_SIZE
=
10
;
export
type
PaginationPositionType
=
'topLeft'
|
'topRight'
|
'bottomLeft'
|
'bottomRight'
export
type
SearchValuesType
=
{
[
key
:
string
]:
any
}
export
type
FetchParamsType
=
SearchValuesType
&
{
/**
* 当前页
*/
current
?:
number
,
/**
* 当前页数
*/
pageSize
?:
number
,
};
export
type
FetchResponse
<
T
>
=
{
/**
* 数据
*/
data
:
T
[],
/**
* 总条数
*/
totalCount
:
number
,
};
export
type
NormalTableRefHandleType
=
{
/**
* 重新加载数据
*/
reload
:
(
params
?:
FetchParamsType
)
=>
void
,
}
export
interface
NormalTableProps
<
T
>
extends
Omit
<
TableProps
<
T
>
,
'pagination'
>
{
/**
* 获取数据方法,如果外部有传入 dataSource 则无效
*/
fetchDataSource
?:
(
params
:
FetchParamsType
)
=>
Promise
<
FetchResponse
<
T
>>
,
/**
* 查询formily表单props
*/
searchFormProps
?:
SearchFormIProps
,
/**
* 自定义渲染查询Form
*/
customRenderSearchForm
?:
()
=>
React
.
ReactNode
,
/**
* 查询formily提交触发事件
*/
onSearchSubmit
?:
(
values
:
SearchValuesType
)
=>
void
,
/**
* 分页器props,默认 current 1,默认 pageSize 10
*/
pagination
?:
PaginationProps
|
null
,
/**
* 分页器位置,默认 bottomRight
*/
paginationPosition
?:
PaginationPositionType
,
/**
* 默认 current,只在首次请求生效
*/
defaultCurrent
?:
number
,
/**
* 默认 pageSize
*/
defaultPageSize
?:
number
,
/**
* 分页器改变触发事件
*/
onPaginationChange
?:
(
page
:
number
,
size
:
number
)
=>
void
,
/**
* 是否占满父容器,默认为false,注意当开启该属性会跟 scroll 属性冲突
*/
full
?:
boolean
,
/**
* 渲染底部内容
*/
renderFootContent
?:
()
=>
React
.
ReactNode
,
}
const
NormalTable
:
React
.
ForwardRefRenderFunction
<
NormalTableRefHandleType
,
NormalTableProps
<
{}
>>
=
(<
T
extends
{},
>
(props: NormalTableProps
<
T
>
, ref) =
>
{
const
{
fetchDataSource
,
...
...
src/components/PolymericTable/index.tsx
View file @
04919f7e
/*
* @Author: XieZhiXiong
* @Date: 2021-01-06 11:36:34
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-07-16 14:27:20
* @Description:
*/
import
NormalTable
from
'./NormalTable'
;
import
EditableCellTable
from
'./EditableCellTable'
;
export
*
from
'./interface'
;
export
{
NormalTable
as
default
,
EditableCellTable
,
...
...
src/components/PolymericTable/interface.d.ts
View file @
04919f7e
...
...
@@ -6,10 +6,87 @@
* @Description:
*/
import
{
TableProps
,
TablePaginationConfig
,
ColumnType
}
from
'antd/lib/table'
;
import
{
PaginationProps
}
from
'antd/lib/pagination'
;
import
{
SearchFormIProps
}
from
'./SearchForm'
;
export
interface
StandardTableProps
extends
TableProps
<
any
>
{
pagination
?:
TablePaginationConfig
;
onPaginationChange
?:
(
page
:
number
,
size
:
number
)
=>
void
;
export
type
PaginationPositionType
=
'topLeft'
|
'topRight'
|
'bottomLeft'
|
'bottomRight'
export
type
SearchValuesType
=
{
[
key
:
string
]:
any
}
export
type
FetchParamsType
=
SearchValuesType
&
{
/**
* 当前页
*/
current
?:
number
,
/**
* 当前页数
*/
pageSize
?:
number
,
};
export
type
FetchResponse
<
T
>
=
{
/**
* 数据
*/
data
:
T
[],
/**
* 总条数
*/
totalCount
:
number
,
};
export
type
NormalTableRefHandleType
=
{
/**
* 重新加载数据
*/
reload
:
(
params
?:
FetchParamsType
)
=>
void
,
}
export
interface
NormalTableProps
<
T
>
extends
Omit
<
TableProps
<
T
>
,
'pagination'
>
{
/**
* 获取数据方法,如果外部有传入 dataSource 则无效
*/
fetchDataSource
?:
(
params
:
FetchParamsType
)
=>
Promise
<
FetchResponse
<
T
>>
,
/**
* 查询formily表单props
*/
searchFormProps
?:
SearchFormIProps
,
/**
* 自定义渲染查询Form
*/
customRenderSearchForm
?:
()
=>
React
.
ReactNode
,
/**
* 查询formily提交触发事件
*/
onSearchSubmit
?:
(
values
:
SearchValuesType
)
=>
void
,
/**
* 分页器props,默认 current 1,默认 pageSize 10
*/
pagination
?:
PaginationProps
|
null
,
/**
* 分页器位置,默认 bottomRight
*/
paginationPosition
?:
PaginationPositionType
,
/**
* 默认 current,只在首次请求生效
*/
defaultCurrent
?:
number
,
/**
* 默认 pageSize
*/
defaultPageSize
?:
number
,
/**
* 分页器改变触发事件
*/
onPaginationChange
?:
(
page
:
number
,
size
:
number
)
=>
void
,
/**
* 是否占满父容器,默认为false,注意当开启该属性会跟 scroll 属性冲突
*/
full
?:
boolean
,
/**
* 渲染底部内容
*/
renderFootContent
?:
()
=>
React
.
ReactNode
,
}
export
interface
EditableCellProps
{
...
...
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