优化Table
parent
96d903a2ad
commit
528f8e7c14
|
|
@ -11,7 +11,9 @@ export type TableProProps<DataSource, U, ValueType> = Omit<TableProps, 'columns'
|
|||
/** 是否禁用内容区滚动,默认 false */
|
||||
disabledResizer?: boolean;
|
||||
/** 是否显示索引列,默认 true */
|
||||
showIndex?: boolean;
|
||||
showIndexColumn?: boolean;
|
||||
/** 索引列是否固定,默认 left */
|
||||
indexColumnFixed?: "left" | "right" | boolean;
|
||||
/** 是否使用居中布局,默认 true */
|
||||
useAlignCenter?: boolean;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,15 +5,16 @@ import "./index.less";
|
|||
function TablePro(props) {
|
||||
const {
|
||||
columns = [],
|
||||
showIndex = true,
|
||||
showIndexColumn = true,
|
||||
useAlignCenter = true,
|
||||
indexColumnFixed = "left",
|
||||
rowKey = "id",
|
||||
...restProps
|
||||
} = props;
|
||||
|
||||
const storeIndex = props.storeIndex || `${window.process.env.app.antd["ant-prefix"]}_${Math.random().toString(36).substring(2)}`;
|
||||
function calcColumns() {
|
||||
showIndex && columns.unshift(getIndexColumn(props.pagination));
|
||||
showIndexColumn && columns.unshift({...getIndexColumn(props.pagination), fixed: indexColumnFixed});
|
||||
return columns.map(item => ({ align: useAlignCenter ? "center" : "left", ...item }));
|
||||
}
|
||||
return <Table rowKey={rowKey} storeIndex={storeIndex} columns={calcColumns()} {...restProps} />;
|
||||
|
|
|
|||
Loading…
Reference in New Issue