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