Commit 52eb141b authored by zhangwenshuai's avatar zhangwenshuai

update

parent a3356272
......@@ -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]}`}
</div>
)}
......
......@@ -24,6 +24,7 @@
width: @textFontGen;
color: @textPrimaryColor;
margin-right: 5px;
user-select: none;
}
.colTitle {
......
......@@ -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显示
......
......@@ -61,7 +61,7 @@ export default class AirTable extends Component<TableProps, TableState> {
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<TableProps, TableState> {
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<TableProps, TableState> {
this.memoizeData = memoizeOne(this.filterData);
}
componentWillReceiveProps(prevProps: Readonly<TableProps>, prevState: Readonly<TableState>, snapshot?: any): void {
if (JSON.stringify(prevState.groupConfig) !== JSON.stringify(this.state.groupConfig)) {
componentDidUpdate(prevProps: Readonly<TableProps>): void {
if (
JSON.stringify(this.props.dataSource) !== JSON.stringify(prevProps.dataSource)
) {
this.recomputeGridSize();
}
}
......@@ -539,7 +537,10 @@ export default class AirTable extends Component<TableProps, TableState> {
}}
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<TableProps, TableState> {
})}
columnCount={columnCount}
width={realWidth}
rowHeight={getRowHeight.bind(null, {
rowHeight={getRowHeight.bind(this, {
dataSource,
rowHeight,
})}
......@@ -743,7 +744,10 @@ export default class AirTable extends Component<TableProps, TableState> {
}}
columnCount={rightCount}
width={rightWidth + scrollbarWidth}
rowHeight={getRowHeight.bind(null, { dataSource, rowHeight })}
rowHeight={getRowHeight.bind(this, {
dataSource,
rowHeight,
})}
rowCount={rowCount}
height={tableBodyHeight - scrollbarWidth}
scrollTop={scrollTop}
......
......@@ -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];
......
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