Commit 602ab98f authored by zhangwenshuai's avatar zhangwenshuai

update apolloTable

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