IO-1412 Fixed column resize

This commit is contained in:
swtmply
2023-04-12 00:57:13 +08:00
parent 55ddaca328
commit d585cacdfc
2 changed files with 16 additions and 3 deletions

View File

@@ -81,7 +81,7 @@ export function ProductionListTable({
state, state,
activeStatuses: bodyshop.md_ro_statuses.active_statuses, activeStatuses: bodyshop.md_ro_statuses.active_statuses,
}).find((e) => e.key === k.key), }).find((e) => e.key === k.key),
width: k.width, width: k.width ?? 100,
}; };
})) || })) ||
[] []
@@ -267,6 +267,8 @@ export function ProductionListTable({
sortOrder: sortOrder:
state.sortedInfo.columnKey === c.key && state.sortedInfo.order, state.sortedInfo.columnKey === c.key && state.sortedInfo.order,
title: headerItem(c), title: headerItem(c),
ellipsis: true,
width: c.width ?? 100,
onHeaderCell: (column) => ({ onHeaderCell: (column) => ({
width: column.width, width: column.width,
onResize: handleResize(index), onResize: handleResize(index),
@@ -276,11 +278,12 @@ export function ProductionListTable({
rowKey="id" rowKey="id"
loading={loading} loading={loading}
dataSource={dataSource} dataSource={dataSource}
// scroll={{ x: true }} scroll={{ x: 1000 }}
onChange={handleTableChange} onChange={handleTableChange}
/> />
</ReactDragListView.DragColumn> </ReactDragListView.DragColumn>
</div> </div>
); );
} }
export default connect(mapStateToProps, null)(ProductionListTable); export default connect(mapStateToProps, null)(ProductionListTable);

View File

@@ -3,8 +3,18 @@ import { Resizable } from "react-resizable";
export default function ResizableComponent(props) { export default function ResizableComponent(props) {
const { onResize, width, ...restProps } = props; const { onResize, width, ...restProps } = props;
if (!width) {
return <th {...restProps} />;
}
return ( return (
<Resizable width={width || 200} height={0} onResize={onResize}> <Resizable
width={width || 200}
height={0}
onResize={onResize}
draggableOpts={{ enableUserSelectHack: false }}
>
<th {...restProps} /> <th {...restProps} />
</Resizable> </Resizable>
); );