Commit 2c948fe6 by zhaochengxiang

模型列表宽度调整问题

parent 933a9743
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"@types/react": "^17.0.39", "@types/react": "^17.0.39",
"@types/react-dom": "^17.0.12", "@types/react-dom": "^17.0.12",
"ahooks": "^3.1.7", "ahooks": "^3.1.7",
"antd": "^4.18.2", "antd": "4.18.2",
"axios": "^0.19.0", "axios": "^0.19.0",
"copy-to-clipboard": "^3.3.1", "copy-to-clipboard": "^3.3.1",
"core-js": "^3.4.2", "core-js": "^3.4.2",
......
...@@ -5,7 +5,6 @@ import SmoothScroll from 'smooth-scroll'; ...@@ -5,7 +5,6 @@ import SmoothScroll from 'smooth-scroll';
import classnames from 'classnames'; import classnames from 'classnames';
import { Resizable } from 'react-resizable'; import { Resizable } from 'react-resizable';
import { useContextMenu, Menu as RcMenu, Item as RcItem } from "react-contexify"; import { useContextMenu, Menu as RcMenu, Item as RcItem } from "react-contexify";
import ResizeObserver from 'rc-resize-observer';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
import { showMessage, getQueryParam, paginate, isSzseEnv, formatDate, getDataModelerRole } from '../../../../util'; import { showMessage, getQueryParam, paginate, isSzseEnv, formatDate, getDataModelerRole } from '../../../../util';
...@@ -133,7 +132,6 @@ const ModelTable = (props) => { ...@@ -133,7 +132,6 @@ const ModelTable = (props) => {
id: MENU_ID, id: MENU_ID,
}); });
const [ tableWidth, setTableWidth ] = useState(0);
const [ selectedRowKeys, setSelectedRowKeys ] = useState([]); const [ selectedRowKeys, setSelectedRowKeys ] = useState([]);
const [ subSelectedRowKeys, setSubSelectedRowKeys ] = useState([]); const [ subSelectedRowKeys, setSubSelectedRowKeys ] = useState([]);
// const [ mouseEnterKey, setMouseEnterKey ] = useState(null); // const [ mouseEnterKey, setMouseEnterKey ] = useState(null);
...@@ -386,54 +384,14 @@ const ModelTable = (props) => { ...@@ -386,54 +384,14 @@ const ModelTable = (props) => {
}, [data, pagination, sortRule]) }, [data, pagination, sortRule])
useEffect(() => { useEffect(() => {
if (tableWidth) {
let newColumns = [], newIncludePathColumns = [];
let excludePathCols = [...cols];
if ((modelId||'') !== '') {
excludePathCols = cols.filter(item => item.dataIndex!=='key');
}
excludePathCols.forEach((column, index) => {
const newColumn = {...column};
if (!newColumn.width) {
const rowWidth = (excludePathCols.reduce((preVal, col) => (col.width?col.width:0) + preVal, 0)) + 97; //展开50 勾选32 滚动条15
if (tableWidth > rowWidth) {
newColumn.width = (tableWidth-rowWidth)>200?(tableWidth-rowWidth):200;
} else {
newColumn.width = 200;
}
}
newColumns.push(newColumn);
});
const includePathCols = [...cols]; const includePathCols = [...cols];
includePathCols.splice(3, 0, pathColumn); includePathCols.splice(3, 0, pathColumn);
includePathCols.forEach((column, index) => { setColumns(cols);
const newColumn = {...column}; setIncludePathColumns(includePathCols);
if (!newColumn.width) {
const rowWidth = (includePathCols.reduce((preVal, col) => (col.width?col.width:0) + preVal, 0)) + 97;
if (tableWidth > rowWidth) {
newColumn.width = (tableWidth-rowWidth)>200?(tableWidth-rowWidth):200;
} else {
newColumn.width = 200;
}
}
newIncludePathColumns.push(newColumn);
});
setColumns(newColumns);
setIncludePathColumns(newIncludePathColumns);
}
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [ tableWidth ]) }, [])
const modelEventChange = (e) => { const modelEventChange = (e) => {
if (e.key === 'modelChange') { if (e.key === 'modelChange') {
...@@ -724,11 +682,6 @@ const ModelTable = (props) => { ...@@ -724,11 +682,6 @@ const ModelTable = (props) => {
return ( return (
<div className={classes}> <div className={classes}>
<ResizeObserver
onResize={({ width }) => {
setTableWidth(width);
}}
>
<Table <Table
rowSelection={rowSelection} rowSelection={rowSelection}
components={{ components={{
...@@ -755,7 +708,6 @@ const ModelTable = (props) => { ...@@ -755,7 +708,6 @@ const ModelTable = (props) => {
onChange={onTableChange} onChange={onTableChange}
expandable={expandable} expandable={expandable}
/> />
</ResizeObserver>
{ {
!modelId && (data||[]).length>0 && <Pagination !modelId && (data||[]).length>0 && <Pagination
className="text-center mt-3" className="text-center mt-3"
......
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