Commit 52eb141b authored by zhangwenshuai's avatar zhangwenshuai

update

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