Commit a7ee8cc3 by zhaochengxiang

加工内容历史版本优化

parent 70411e92
...@@ -69,12 +69,13 @@ function FC<RowType extends object = any>({ width, maxHeight, pageSize, pageNum, ...@@ -69,12 +69,13 @@ function FC<RowType extends object = any>({ width, maxHeight, pageSize, pageNum,
setDefaultWidth(columns, contentWidth) setDefaultWidth(columns, contentWidth)
paddingCol.current.width = 0 paddingCol.current.width = 0
const cols = columns const newCols = columns
.map((col, index) => { .map((col, index) => {
const render = getRender(col); const render = getRender(col);
const colWidth = col.width ?? 100; const colWidth = col.width ?? 100;
return { return {
...col, /* colRef: createRef(), */ width: colWidth, render, ellipsis: true, ellipsis: true,
...col, /* colRef: createRef(), */ width: colWidth, render,
onHeaderCell: (column: any) => ({ onHeaderCell: (column: any) => ({
width: column.width, width: column.width,
// colRef: column.colRef, // colRef: column.colRef,
...@@ -82,7 +83,8 @@ function FC<RowType extends object = any>({ width, maxHeight, pageSize, pageNum, ...@@ -82,7 +83,8 @@ function FC<RowType extends object = any>({ width, maxHeight, pageSize, pageNum,
}), }),
}; };
}) })
setCols(cols)
setCols(newCols)
} }
}, [columns, tableWidth, width, extraColWidth]) }, [columns, tableWidth, width, extraColWidth])
......
import { useEffect, useState } from 'react'; import { useEffect, useState, useRef } from 'react';
import { Typography, Tooltip, Table } from 'antd'; import { Typography, Tooltip } from 'antd';
import Table from '../../../../util/Component/Table';
const { Text, Paragraph, Title } = Typography; const { Text, Paragraph, Title } = Typography;
...@@ -9,43 +10,74 @@ const VersionCompareProcess = (props) => { ...@@ -9,43 +10,74 @@ const VersionCompareProcess = (props) => {
const [ columns, setColumns ] = useState([]); const [ columns, setColumns ] = useState([]);
const [ tableData, setTableData ] = useState([]); const [ tableData, setTableData ] = useState([]);
const compareTableDataRef = useRef();
const hiddenDivRef = useRef();
useEffect(() => { useEffect(() => {
const newColumns = []; const newColumns = [];
(data?.heads?.processingHead||[]).forEach((item, index) => { (data?.heads?.processingHead||[]).forEach((item, index) => {
newColumns.push({ const newColumn = {
title: item||'', title: item||'',
dataIndex: `column${index}`, dataIndex: `column${index}`,
render: (attrValue, record, index) => { render: (attrValue, record, _index) => {
let stateClassName = '', height = 0, compareHeight = 0;
let stateClassName = '';
if (attrValue?.state==='ADD' || attrValue?.state==='UPDATE') { if (attrValue?.state==='ADD' || attrValue?.state==='UPDATE') {
stateClassName = 'add'; stateClassName = 'add';
} else if (attrValue?.state === 'DELETE') { } else if (attrValue?.state === 'DELETE') {
stateClassName = 'delete'; stateClassName = 'delete';
} }
const compareValue = compareTableDataRef.current?.[_index]?.[`column${index}`]?.value;
console.log('compareValue', compareValue)
const _span = document.createElement('span');
_span.innerText = attrValue?.value??'';
hiddenDivRef.current?.appendChild(_span);
height = hiddenDivRef.current?.getBoundingClientRect().height
hiddenDivRef.current?.removeChild(_span);
_span.innerText = compareValue??'';
hiddenDivRef.current?.appendChild(_span);
compareHeight = hiddenDivRef.current?.getBoundingClientRect().height
hiddenDivRef.current?.removeChild(_span);
return ( return (
<Paragraph> <div style={{ position: 'relative' }}>
<Tooltip title={attrValue?.value||''}> {
<Text className={stateClassName} ellipsis={true}>{attrValue?.value||''}</Text> (height>compareHeight) ? <div className={stateClassName}>{attrValue?.value||''}</div> : <>
</Tooltip> <div className={stateClassName} style={{
</Paragraph> position: 'absolute',
top: '50%',
left: 0,
transform: 'translateY(-50%)',
}}>
{attrValue?.value||''}
</div>
<div style={{ visibility: 'hidden' }}>{compareValue}</div>
</>
}
</div>
); );
}, },
width: 60, ellipsis: false,
ellipsis: true, };
});
newColumns.push(newColumn);
}) })
setColumns(newColumns); setColumns(newColumns);
const newTableData = []; const newTableData = [], newCompareTableData = [];
let processingValue = []; let processingValue = [], compareProcessingValue = [];
if (direction==='left') { if (direction==='left') {
processingValue = data?.left?.processingValue||[]; processingValue = data?.left?.processingValue||[];
compareProcessingValue = data?.right?.processingValue||[];
} else if (direction==='right') { } else if (direction==='right') {
processingValue = data?.right?.processingValue||[]; processingValue = data?.right?.processingValue||[];
compareProcessingValue = data?.left?.processingValue||[];
} }
(processingValue||[]).forEach((attrItem) => { (processingValue||[]).forEach((attrItem) => {
...@@ -54,8 +86,17 @@ const VersionCompareProcess = (props) => { ...@@ -54,8 +86,17 @@ const VersionCompareProcess = (props) => {
newAttrItem[`column${index}`] = item; newAttrItem[`column${index}`] = item;
}) })
newTableData.push(newAttrItem); newTableData.push(newAttrItem);
});
(compareProcessingValue||[]).forEach((attrItem) => {
let newAttrItem = {};
(attrItem||[]).forEach((item, index) => {
newAttrItem[`column${index}`] = item;
}) })
newCompareTableData.push(newAttrItem);
});
compareTableDataRef.current = newCompareTableData;
setTableData(newTableData); setTableData(newTableData);
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
...@@ -73,6 +114,9 @@ const VersionCompareProcess = (props) => { ...@@ -73,6 +114,9 @@ const VersionCompareProcess = (props) => {
dataSource={tableData} dataSource={tableData}
pagination={false} pagination={false}
/> />
<div style={{ width: 0, height: 0 }} >
<div style={{ width: 100 }} ref={hiddenDivRef}></div>
</div>
</div> </div>
); );
} }
......
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