修复表格样式

This commit is contained in:
hanhh 2021-10-16 10:53:14 +08:00
parent 6fa8a678bf
commit 87027f8a8c
4 changed files with 15 additions and 10 deletions

View File

@ -1,3 +1,3 @@
.ant-table-pagination.ant-pagination { .ant-table-pagination.ant-pagination {
margin-bottom: 0; margin-bottom: 0 !important;
} }

View File

@ -677,7 +677,8 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
setTimeout(() => { setTimeout(() => {
if (selectedRowIds.length === 0 || selectedIds.length === 0) { if (selectedRowIds.length === 0 || selectedIds.length === 0) {
setTableScrollHeight(getTableScroll()); const offset = isPhone ? 40 : 0;
setTableScrollHeight(getTableScroll() - offset);
} }
}); });
}; };
@ -761,7 +762,8 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
useEffect(() => { useEffect(() => {
setPageSize(parseInt(localStorage.getItem('pageSize') || '20')); setPageSize(parseInt(localStorage.getItem('pageSize') || '20'));
setTableScrollHeight(getTableScroll()); const offset = isPhone ? 40 : 0;
setTableScrollHeight(getTableScroll() - offset);
}, []); }, []);
return ( return (
@ -840,6 +842,7 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
onChange: onPageChange, onChange: onPageChange,
pageSize: pageSize, pageSize: pageSize,
showSizeChanger: true, showSizeChanger: true,
simple: isPhone,
defaultPageSize: 20, defaultPageSize: 20,
showTotal: (total: number, range: number[]) => showTotal: (total: number, range: number[]) =>
`${range[0]}-${range[1]} 条/总共 ${total}`, `${range[0]}-${range[1]} 条/总共 ${total}`,

View File

@ -366,7 +366,8 @@ const Env = ({ headerStyle, isPhone, theme }: any) => {
setTimeout(() => { setTimeout(() => {
if (selectedRowIds.length === 0 || selectedIds.length === 0) { if (selectedRowIds.length === 0 || selectedIds.length === 0) {
setTableScrollHeight(getTableScroll({ extraHeight: 40 })); const offset = isPhone ? 40 : 0;
setTableScrollHeight(getTableScroll({ extraHeight: 127 }) - offset);
} }
}); });
}; };
@ -435,7 +436,8 @@ const Env = ({ headerStyle, isPhone, theme }: any) => {
}, [searchText]); }, [searchText]);
useEffect(() => { useEffect(() => {
setTableScrollHeight(getTableScroll({ extraHeight: 40 })); const offset = isPhone ? 40 : 0;
setTableScrollHeight(getTableScroll({ extraHeight: 127 }) - offset);
}, []); }, []);
return ( return (

View File

@ -182,7 +182,7 @@ export function getTableScroll({
}: { extraHeight?: number; id?: string } = {}) { }: { extraHeight?: number; id?: string } = {}) {
if (typeof extraHeight == 'undefined') { if (typeof extraHeight == 'undefined') {
// 默认底部分页64 + 边距10 // 默认底部分页64 + 边距10
extraHeight = 80; extraHeight = 167;
} }
let tHeader = null; let tHeader = null;
if (id) { if (id) {
@ -192,16 +192,16 @@ export function getTableScroll({
.getElementsByClassName('ant-table-thead')[0] .getElementsByClassName('ant-table-thead')[0]
: null; : null;
} else { } else {
tHeader = document.getElementsByClassName('ant-table-thead')[0]; tHeader = document.querySelector('.ant-pro-grid-content');
} }
//表格内容距离顶部的距离 //表格内容距离顶部的距离
let tHeaderBottom = 0; let mainTop = 0;
if (tHeader) { if (tHeader) {
tHeaderBottom = tHeader.getBoundingClientRect().bottom; mainTop = tHeader.getBoundingClientRect().top;
} }
//窗体高度-表格内容顶部的高度-表格内容底部的高度 //窗体高度-表格内容顶部的高度-表格内容底部的高度
let height = document.body.clientHeight - tHeaderBottom - extraHeight; let height = document.body.clientHeight - mainTop - extraHeight;
return height; return height;
} }