diff --git a/components/apolloTable/component/Table.tsx b/components/apolloTable/component/Table.tsx index dc71ada66db7b598a83e36f4ed7111bf2557e711..fe8138570fb3b1cea2a18efd4942b4a3973b4686 100644 --- a/components/apolloTable/component/Table.tsx +++ b/components/apolloTable/component/Table.tsx @@ -162,7 +162,10 @@ export default class AirTable extends Component { }; // 获取每列的宽度 - getColumnWidth = (columns: ColumnProps[], { index }: { index: number }) => { + getColumnWidth = ( + { columns, showColumns }: { columns: ColumnProps[]; showColumns: ColumnProps[] }, + { index }: { index: number }, + ) => { const { tableWidth = 0 } = this.state; const { totalWidth, configWidth, defaultWidthLen } = this.memoizeTotalWidth(columns); const { columnWidth } = this.config; @@ -170,7 +173,7 @@ export default class AirTable extends Component { if (totalWidth < tableWidth) { colWidth = _.floor((tableWidth - configWidth) / defaultWidthLen); } - const columnObj = columns[index]; + const columnObj = showColumns[index]; if (columnObj && columnObj.width) { return columnObj.width; } @@ -229,7 +232,7 @@ export default class AirTable extends Component { sortFlag={sortFlag} sortConfig={sortConfig} columnIndex={columnIndex} - showIndex={showIndex} + showIndex={position === 'right' ? false : showIndex} questionText={questionText} rowSelection={position === 'right' ? false : rowSelection} dataSource={dataSource} @@ -331,7 +334,7 @@ export default class AirTable extends Component { cellStyle={cellStyle} columns={columns} paginationConfig={paginationConfig} - showIndex={showIndex} + showIndex={position === 'right' ? false : showIndex} emptyPlaceholder={emptyPlaceholder} cellEditable={cellEditable} rowSelection={position === 'right' ? false : rowSelection} @@ -404,7 +407,10 @@ export default class AirTable extends Component { this.grid1 = dom; }} className={styles.headerGrid} - columnWidth={this.getColumnWidth.bind(this, showColumns)} + columnWidth={this.getColumnWidth.bind(this, { + columns: showColumns, + showColumns: leftColumns, + })} columnCount={leftCount} width={leftWidth} rowHeight={headerHeight} @@ -435,7 +441,10 @@ export default class AirTable extends Component { showColumns: leftColumns, showData: leftData, })} - columnWidth={this.getColumnWidth.bind(this, showColumns)} + columnWidth={this.getColumnWidth.bind(this, { + columns: showColumns, + showColumns: leftColumns, + })} columnCount={leftCount} width={leftWidth} rowHeight={rowHeight} @@ -467,10 +476,10 @@ export default class AirTable extends Component { }} className={styles.headerGrid} overscanColumnCount={overscanColumnCount} - columnWidth={this.getColumnWidth.bind( - this, + columnWidth={this.getColumnWidth.bind(this, { + columns: showColumns, showColumns, - )} + })} columnCount={columnCount} width={width} rowHeight={headerHeight} @@ -504,10 +513,10 @@ export default class AirTable extends Component { className={styles.centerGrid} overscanColumnCount={overscanColumnCount} overscanRowCount={overscanRowCount} - columnWidth={this.getColumnWidth.bind( - this, + columnWidth={this.getColumnWidth.bind(this, { + columns: showColumns, showColumns, - )} + })} columnCount={columnCount} width={realWidth} rowHeight={rowHeight} @@ -561,7 +570,10 @@ export default class AirTable extends Component { this.grid5 = dom; }} className={styles.headerGrid} - columnWidth={this.getColumnWidth.bind(this, showColumns)} + columnWidth={this.getColumnWidth.bind(this, { + columns: showColumns, + showColumns: rightColumns, + })} columnCount={rightCount} width={rightWidth} rowHeight={headerHeight} @@ -595,7 +607,10 @@ export default class AirTable extends Component { showData: rightData, position: 'right', })} - columnWidth={this.getColumnWidth.bind(this, showColumns)} + columnWidth={this.getColumnWidth.bind(this, { + columns: showColumns, + showColumns: rightColumns, + })} columnCount={rightCount} width={rightWidth} rowHeight={rowHeight}