Commit 602ab98f authored by zhangwenshuai's avatar zhangwenshuai

update apolloTable

parent 8c526b9d
...@@ -48,7 +48,9 @@ export default class TableColumn extends PureComponent<ColumnProps> { ...@@ -48,7 +48,9 @@ export default class TableColumn extends PureComponent<ColumnProps> {
if (typeof onChange === 'function') { if (typeof onChange === 'function') {
const data = _.cloneDeep(selectedRows); const data = _.cloneDeep(selectedRows);
dataSource.map((item: any) => { dataSource.map((item: any) => {
const index = data.findIndex((temp: any) => { return temp.id === item.id; }); const index = data.findIndex((temp: any) => {
return temp.id === item.id;
});
if (checked) { if (checked) {
index > -1 && data.splice(index, 1); index > -1 && data.splice(index, 1);
} else { } else {
...@@ -72,6 +74,7 @@ export default class TableColumn extends PureComponent<ColumnProps> { ...@@ -72,6 +74,7 @@ export default class TableColumn extends PureComponent<ColumnProps> {
columnIndex, columnIndex,
questionText, questionText,
rowSelection, rowSelection,
icon,
} = this.props; } = this.props;
const { value = [] } = sortConfig || {}; const { value = [] } = sortConfig || {};
const sort = value.find((item: any) => { const sort = value.find((item: any) => {
...@@ -82,13 +85,12 @@ export default class TableColumn extends PureComponent<ColumnProps> { ...@@ -82,13 +85,12 @@ export default class TableColumn extends PureComponent<ColumnProps> {
<div className={s.colContainer}> <div className={s.colContainer}>
{rowSelection && columnIndex === 0 && <div className={s.checkbox}>{this.getCheckbox()}</div>} {rowSelection && columnIndex === 0 && <div className={s.checkbox}>{this.getCheckbox()}</div>}
<div className={s.colBrief} style={{ marginLeft: showIndex && columnIndex === 0 ? '40px' : 0 }}> <div className={s.colBrief} style={{ marginLeft: showIndex && columnIndex === 0 ? '40px' : 0 }}>
{icon && <div className={s.colIcon}>{icon()}</div>}
<span className={s.colTitle}> <span className={s.colTitle}>
{columnChsName} {columnChsName}
{questionText && ( {questionText && (
<Tooltip title={questionText}> <Tooltip title={questionText}>
<div className={s.tipContainer}> <div className={s.tipContainer}>?</div>
?
</div>
</Tooltip> </Tooltip>
)} )}
</span> </span>
......
...@@ -55,7 +55,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -55,7 +55,7 @@ export default class AirTable extends Component<TableProps, TableState> {
constructor(props: TableProps) { constructor(props: TableProps) {
super(props); super(props);
const { columns, dataSource, width = 0, height = 0, rowHeight } = props; const { columns, dataSource, width = 0, height = 0, rowHeight, headerHeight, columnWidth } = props;
this.state = { this.state = {
columns, columns,
dataSource, dataSource,
...@@ -65,9 +65,9 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -65,9 +65,9 @@ export default class AirTable extends Component<TableProps, TableState> {
this.config = { this.config = {
overscanColumnCount: 5, overscanColumnCount: 5,
overscanRowCount: 5, overscanRowCount: 5,
columnWidth: 150, columnWidth: columnWidth || 150,
rowHeight: rowHeight || 80, rowHeight: rowHeight || 80,
headerHeight: 60, headerHeight: headerHeight || 60,
}; };
this.memoizeLeftColumns = memoizeOne(this.getLeftColumns); this.memoizeLeftColumns = memoizeOne(this.getLeftColumns);
this.memoizeRightColumns = memoizeOne(this.getRightColumns); this.memoizeRightColumns = memoizeOne(this.getRightColumns);
...@@ -214,6 +214,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -214,6 +214,7 @@ export default class AirTable extends Component<TableProps, TableState> {
columnAttrObj = {}, columnAttrObj = {},
sortFlag, sortFlag,
questionText, questionText,
icon,
} = showColumns[columnIndex]; } = showColumns[columnIndex];
return ( return (
<div className={styles.headerCell} key={key} style={style}> <div className={styles.headerCell} key={key} style={style}>
...@@ -229,6 +230,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -229,6 +230,7 @@ export default class AirTable extends Component<TableProps, TableState> {
questionText={questionText} questionText={questionText}
rowSelection={position === 'right' ? false : rowSelection} rowSelection={position === 'right' ? false : rowSelection}
dataSource={dataSource} dataSource={dataSource}
icon={icon}
/> />
</div> </div>
); );
...@@ -352,7 +354,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -352,7 +354,7 @@ export default class AirTable extends Component<TableProps, TableState> {
const rightWidth = this.memoizeLeftWidth(rightColumns, showColumns); const rightWidth = this.memoizeLeftWidth(rightColumns, showColumns);
let totalHeight: number = rowCount * rowHeight; let totalHeight: number = rowCount * rowHeight;
const { totalWidth } = this.memoizeTotalWidth(showColumns); const { totalWidth } = this.memoizeTotalWidth(showColumns);
if (totalWidth > tableWidth) { if (rowCount > 0 && totalWidth > tableWidth) {
totalHeight = rowCount * rowHeight + scrollbarWidth; totalHeight = rowCount * rowHeight + scrollbarWidth;
} }
return ( return (
...@@ -581,9 +583,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -581,9 +583,7 @@ export default class AirTable extends Component<TableProps, TableState> {
</div> </div>
)} )}
<div className={styles.fillHandleWrapper} /> <div className={styles.fillHandleWrapper} />
<div className={styles.loading}> <div className={styles.loading}>{/*<Spin spinning={loading} />*/}</div>
{/*<Spin spinning={loading} />*/}
</div>
</div> </div>
); );
}} }}
......
...@@ -58,6 +58,8 @@ class AirTable extends React.Component<CommonProps, CommonState> { ...@@ -58,6 +58,8 @@ class AirTable extends React.Component<CommonProps, CommonState> {
rowSelection, rowSelection,
tableOperateConfig, tableOperateConfig,
noDataPlaceholder, noDataPlaceholder,
columnWidth,
headerHeight,
} = this.props; } = this.props;
const sortConfig = operateConfig const sortConfig = operateConfig
&& operateConfig.menusGroup && operateConfig.menusGroup
...@@ -86,6 +88,8 @@ class AirTable extends React.Component<CommonProps, CommonState> { ...@@ -86,6 +88,8 @@ class AirTable extends React.Component<CommonProps, CommonState> {
emptyPlaceholder={emptyPlaceholder} emptyPlaceholder={emptyPlaceholder}
cellEditable={cellEditable} cellEditable={cellEditable}
rowHeight={rowHeight} rowHeight={rowHeight}
headerHeight={headerHeight}
columnWidth={columnWidth}
loading={loading} loading={loading}
rowSelection={rowSelection} rowSelection={rowSelection}
noDataPlaceholder={noDataPlaceholder} noDataPlaceholder={noDataPlaceholder}
......
...@@ -65,6 +65,8 @@ export interface TableProps extends LoadConfigProps { ...@@ -65,6 +65,8 @@ export interface TableProps extends LoadConfigProps {
emptyPlaceholder?: string; emptyPlaceholder?: string;
cellEditable?: boolean; cellEditable?: boolean;
rowHeight?: number; rowHeight?: number;
headerHeight?: number;
columnWidth?: number;
loading?: boolean; loading?: boolean;
rowSelection?: any; rowSelection?: any;
noDataPlaceholder?: any; noDataPlaceholder?: any;
......
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