diff --git a/components/apolloTable/component/Cell.tsx b/components/apolloTable/component/Cell.tsx index 96b1948928dfba41e97d718ef5e5588d42a74091..3f6ef7bd63e8076788c036eb5c3e896e8c5819a3 100644 --- a/components/apolloTable/component/Cell.tsx +++ b/components/apolloTable/component/Cell.tsx @@ -456,7 +456,7 @@ const Cell = (props: CellProps) => { > {columnIndex === 0 && position !== 'right' && - record.groupConfig[3] && + record.groupConfig[2] && `${record.groupConfig[2].colChsName}:${record.groupTextArr[2]}`} )} diff --git a/components/apolloTable/component/Column.less b/components/apolloTable/component/Column.less index 8f26e3acf3657d508c28eb74092f33f3e0c13f8f..276e9500de6c94b3f4124d8be842fe40793bc962 100644 --- a/components/apolloTable/component/Column.less +++ b/components/apolloTable/component/Column.less @@ -24,6 +24,7 @@ width: @textFontGen; color: @textPrimaryColor; margin-right: 5px; + user-select: none; } .colTitle { diff --git a/components/apolloTable/component/DragSorted.tsx b/components/apolloTable/component/DragSorted.tsx index 7c83406bb6629ffa171add53f120eb01c821471c..aa156a72052e4fa6dac6e2fd5c8738f7b3b36d13 100644 --- a/components/apolloTable/component/DragSorted.tsx +++ b/components/apolloTable/component/DragSorted.tsx @@ -135,8 +135,8 @@ const DragSorted = (props: any) => { const dropMove = dropCol.current && dropCol.current.move; // 清理操作 clean(); - // 没有列信息 - if (!dragColumn || !dropColumn) { + // 没有列信息或没有移动位置 + if (!dragColumn || !dropColumn || dragColumn === dropColumn) { return; } // 拖动回调 @@ -217,6 +217,10 @@ const DragSorted = (props: any) => { // 表格初始位置x点 const originLeft = container.getBoundingClientRect().x || 0; // 拖动列矩形 + if (!e.target.offsetParent) { + // 兼容处理 + return; + } const targetRect = e.target.offsetParent.getBoundingClientRect(); const curX = e.clientX; // 影子div显示 diff --git a/components/apolloTable/component/Table.tsx b/components/apolloTable/component/Table.tsx index 12c8c9c2ef94ab9fad20aeead5bdadcda14137cf..dfee1876931392fa9293c40e0ba2c019e33fb394 100644 --- a/components/apolloTable/component/Table.tsx +++ b/components/apolloTable/component/Table.tsx @@ -61,7 +61,7 @@ export default class AirTable extends Component { memoizeTotalHeight: Function; static getDerivedStateFromProps(nextProps: TableProps, prevState: TableState) { - const { columns, dataSource, groupConfig } = prevState; + const { columns, dataSource } = prevState; const nextState: TableState = { ...prevState, }; @@ -71,19 +71,15 @@ export default class AirTable extends Component { if (JSON.stringify(columns) !== JSON.stringify(nextProps.columns)) { nextState.columns = nextProps.columns; } - if (JSON.stringify(groupConfig) !== JSON.stringify(nextProps.groupConfig)) { - nextState.groupConfig = nextProps.groupConfig; - } return nextState; } constructor(props: TableProps) { super(props); - const { columns, dataSource, groupConfig, width, height } = props; + const { columns, dataSource, width, height } = props; this.state = { columns, dataSource, - groupConfig, tableWidth: width || 0, tableHeight: height || 0, }; @@ -98,8 +94,10 @@ export default class AirTable extends Component { this.memoizeData = memoizeOne(this.filterData); } - componentWillReceiveProps(prevProps: Readonly, prevState: Readonly, snapshot?: any): void { - if (JSON.stringify(prevState.groupConfig) !== JSON.stringify(this.state.groupConfig)) { + componentDidUpdate(prevProps: Readonly): void { + if ( + JSON.stringify(this.props.dataSource) !== JSON.stringify(prevProps.dataSource) + ) { this.recomputeGridSize(); } } @@ -539,7 +537,10 @@ export default class AirTable extends Component { }} columnCount={leftCount} width={leftWidth + scrollbarWidth} - rowHeight={getRowHeight.bind(null, { dataSource, rowHeight })} + rowHeight={getRowHeight.bind(this, { + dataSource, + rowHeight, + })} rowCount={rowCount} height={tableBodyHeight - scrollbarWidth} scrollTop={scrollTop} @@ -622,7 +623,7 @@ export default class AirTable extends Component { })} columnCount={columnCount} width={realWidth} - rowHeight={getRowHeight.bind(null, { + rowHeight={getRowHeight.bind(this, { dataSource, rowHeight, })} @@ -743,7 +744,10 @@ export default class AirTable extends Component { }} columnCount={rightCount} width={rightWidth + scrollbarWidth} - rowHeight={getRowHeight.bind(null, { dataSource, rowHeight })} + rowHeight={getRowHeight.bind(this, { + dataSource, + rowHeight, + })} rowCount={rowCount} height={tableBodyHeight - scrollbarWidth} scrollTop={scrollTop} diff --git a/components/apolloTable/component/index.tsx b/components/apolloTable/component/index.tsx index fbd266b1c2c9aa3e6b0b8db87b4c007842fcddbe..1df35f714b6aac8f8f6e341c72a073b0abdd6dac 100644 --- a/components/apolloTable/component/index.tsx +++ b/components/apolloTable/component/index.tsx @@ -73,6 +73,8 @@ const formatData = (config: string[], dataSource: any[]) => { groupTextArr[2] = group3Cell.text; } }); + // 先清空之前的 + delete row.classList; if (groupKeyArr[0]) { const group1Key = groupKeyArr[0]; const group1Text = groupTextArr[0];