Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wisdom-components
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
ReactWeb5
wisdom-components
Commits
156a4d08
Commit
156a4d08
authored
Mar 13, 2024
by
周宏民
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pref: table组件去掉空状态
parent
eef8d600
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
index.js
packages/base-components/BasicTable/src/index.js
+20
-12
No files found.
packages/base-components/BasicTable/src/index.js
View file @
156a4d08
import
React
,
{
useContext
,
useState
,
useEffect
}
from
'react
'
;
import
{
ConfigProvider
,
Table
}
from
'antd
'
;
import
classNames
from
'classnames'
;
import
PropTypes
from
'prop-types'
;
import
{
Table
,
ConfigProvider
}
from
'antd
'
;
import
React
,
{
useContext
,
useEffect
,
useRef
,
useState
}
from
'react
'
;
import
{
Resizable
}
from
'react-resizable'
;
import
'react-resizable/css/styles.css'
;
import
'./index.less'
;
...
...
@@ -26,12 +26,12 @@ const ResizeableTitle = (props) => {
};
const
BasicTable
=
(
props
)
=>
{
const
tableRef
=
useRef
(
null
);
const
[
cols
,
setCols
]
=
useState
(
props
.
columns
);
const
[
columns
,
setColumns
]
=
useState
(
props
.
columns
);
const
{
getPrefixCls
}
=
useContext
(
ConfigProvider
.
ConfigContext
);
const
prefixCls
=
getPrefixCls
(
'basic-table'
);
const
pagination
=
typeof
props
.
pagination
!==
'undefined'
?
props
.
pagination
:
{};
const
showTotal
=
(
total
)
=>
{
return
`共
${
Math
.
ceil
(
total
/
(
props
.
pagination
?
props
.
pagination
.
pageSize
||
10
:
10
),
...
...
@@ -74,20 +74,28 @@ const BasicTable = (props) => {
);
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[
cols
]);
const
renderEmpty
=
()
=>
{
let
height
=
tableRef
.
current
?.
clientHeight
;
// 表格高度减 表头 减padding
height
=
height
?
(
props
.
showHeader
===
false
?
height
-
15
-
32
:
height
-
60
-
32
)
:
200
;
return
<
div
style
=
{{
height
:
height
}}
/>
;
};
useEffect
(()
=>
{
setCols
(
props
.
columns
);
},
[
props
.
columns
]);
return
(
<
Table
className
=
{
classNames
(
prefixCls
)}
scroll
=
{{
y
:
'calc(100% - 40px)'
}}
components
=
{
components
}
{...
props
}
columns
=
{
columns
}
pagination
=
{
pagination
?
{
showTotal
,
...
pagination
}
:
pagination
}
/
>
<
ConfigProvider
renderEmpty
=
{
renderEmpty
}
>
<
Table
ref
=
{
tableRef
}
className
=
{
classNames
(
prefixCls
)}
scroll
=
{{
y
:
'calc(100% - 40px)'
}}
components
=
{
components
}
{...
props
}
columns
=
{
columns
}
pagination
=
{
pagination
?
{
showTotal
,
...
pagination
}
:
pagination
}
/
>
<
/ConfigProvider
>
);
};
...
...
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