Commit 7b342c03 by zhaochengxiang

路径

parent 07b57f41
...@@ -179,6 +179,21 @@ const ModelTable = (props) => { ...@@ -179,6 +179,21 @@ const ModelTable = (props) => {
} }
}, },
{ {
title: '路径',
dataIndex: 'path',
width: 120,
ellipsis: true,
sorter: true,
sortDirections: ['ascend', 'descend'],
render: (text, _, __) => {
return (
<Tooltip title={text||''}>
<Text ellipsis={true}>{text||''}</Text>
</Tooltip>
)
}
},
{
title: '状态', title: '状态',
dataIndex: 'state', dataIndex: 'state',
width: 100, width: 100,
...@@ -257,24 +272,8 @@ const ModelTable = (props) => { ...@@ -257,24 +272,8 @@ const ModelTable = (props) => {
}, },
]; ];
const pathColumn = {
title: '路径',
dataIndex: 'path',
width: 120,
ellipsis: true,
sorter: true,
sortDirections: ['ascend', 'descend'],
render: (text, _, __) => {
return (
<Tooltip title={text||''}>
<Text ellipsis={true}>{text||''}</Text>
</Tooltip>
)
}
};
const [ columns, setColumns ] = useState([]); const [ columns, setColumns ] = useState([]);
const [ includePathColumns, setIncludePathColumns ] = useState([]); // const [ includePathColumns, setIncludePathColumns ] = useState([]);
const [ pagination, setPagination ] = useState( { pageNum: 1, pageSize: 20 } ); const [ pagination, setPagination ] = useState( { pageNum: 1, pageSize: 20 } );
const [ currentItem, setCurrentItem ] = useState(null); const [ currentItem, setCurrentItem ] = useState(null);
const { pageNum, pageSize } = pagination; const { pageNum, pageSize } = pagination;
...@@ -388,17 +387,17 @@ const ModelTable = (props) => { ...@@ -388,17 +387,17 @@ const ModelTable = (props) => {
useEffect(() => { useEffect(() => {
if (tableWidth>0 && columns.length===0) { if (tableWidth>0 && columns.length===0) {
let newColumns = [], newIncludePathColumns = []; let newColumns = [];
let excludePathCols = [...cols]; let newCols = [...cols];
if ((modelId||'') !== '') { if ((modelId||'') !== '') {
excludePathCols = cols.filter(item => item.dataIndex!=='key'); newCols = cols.filter(item => item.dataIndex!=='key');
} }
excludePathCols.forEach((column, index) => { newCols.forEach((column, index) => {
const newColumn = {...column}; const newColumn = {...column};
if (!newColumn.width) { if (!newColumn.width) {
const rowWidth = (excludePathCols.reduce((preVal, col) => (col.width?col.width:0) + preVal, 0)) + 97; //展开50 勾选32 滚动条15 const rowWidth = (newCols.reduce((preVal, col) => (col.width?col.width:0) + preVal, 0)) + 97; //展开50 勾选32 滚动条15
if (tableWidth - rowWidth > 200) { if (tableWidth - rowWidth > 200) {
newColumn.width = tableWidth - rowWidth; newColumn.width = tableWidth - rowWidth;
...@@ -410,26 +409,26 @@ const ModelTable = (props) => { ...@@ -410,26 +409,26 @@ const ModelTable = (props) => {
newColumns.push(newColumn); newColumns.push(newColumn);
}); });
const includePathCols = [...cols]; // const includePathCols = [...cols];
includePathCols.splice(3, 0, pathColumn); // includePathCols.splice(3, 0, pathColumn);
includePathCols.forEach((column, index) => { // includePathCols.forEach((column, index) => {
const newColumn = {...column}; // const newColumn = {...column};
if (!newColumn.width) { // if (!newColumn.width) {
const rowWidth = (includePathCols.reduce((preVal, col) => (col.width?col.width:0) + preVal, 0)) + 97; // const rowWidth = (includePathCols.reduce((preVal, col) => (col.width?col.width:0) + preVal, 0)) + 97;
if (tableWidth - rowWidth > 200) { // if (tableWidth - rowWidth > 200) {
newColumn.width = tableWidth-rowWidth; // newColumn.width = tableWidth-rowWidth;
} else { // } else {
newColumn.width = 200; // newColumn.width = 200;
} // }
} // }
newIncludePathColumns.push(newColumn); // newIncludePathColumns.push(newColumn);
}); // });
setColumns([ ...newColumns, <Column key='auto' />]); setColumns([ ...newColumns, <Column key='auto' />]);
setIncludePathColumns([ ...newIncludePathColumns, <Column key='auto' />]); // setIncludePathColumns([ ...newIncludePathColumns, <Column key='auto' />]);
} }
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [ tableWidth ]) }, [ tableWidth ])
...@@ -583,20 +582,16 @@ const ModelTable = (props) => { ...@@ -583,20 +582,16 @@ const ModelTable = (props) => {
const handleResize = index => (e, { size }) => { const handleResize = index => (e, { size }) => {
let nextColumns = [...columns]; let nextColumns = [...columns];
if ((modelId||'')==='' && (view==='state'||(keyword||'')!=='')) { // if ((modelId||'')==='' && (view==='state'||(keyword||'')!=='')) {
nextColumns = [...includePathColumns]; // nextColumns = [...includePathColumns];
} // }
nextColumns[index] = { nextColumns[index] = {
...nextColumns[index], ...nextColumns[index],
width: size.width, width: size.width,
}; };
if ((modelId||'')==='' && (view==='state'||(keyword||'')!=='')) { setColumns(nextColumns);
setIncludePathColumns(nextColumns);
} else {
setColumns(nextColumns);
}
}; };
const onTableChange = (pagination, filters, sorter, extra) => { const onTableChange = (pagination, filters, sorter, extra) => {
...@@ -680,9 +675,9 @@ const ModelTable = (props) => { ...@@ -680,9 +675,9 @@ const ModelTable = (props) => {
const mergedColumns = () => { const mergedColumns = () => {
let newColumns = [...columns]; let newColumns = [...columns];
if ((modelId||'')==='' && (view==='state'||(keyword||'')!=='')) { // if ((modelId||'')==='' && (view==='state'||(keyword||'')!=='')) {
newColumns = [...includePathColumns]; // newColumns = [...includePathColumns];
} // }
return ( return (
newColumns.map((col, index) => ({ newColumns.map((col, index) => ({
......
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