Commit 1d6f0c2a by zhaochengxiang

调整样式

parent b55a142a
...@@ -1213,15 +1213,13 @@ const ImportActionTable = (props) => { ...@@ -1213,15 +1213,13 @@ const ImportActionTable = (props) => {
editingKey!=='' && <React.Fragment> editingKey!=='' && <React.Fragment>
{ {
suggests && suggests.length>0 && ( suggests && suggests.length>0 && (
<React.Fragment>
<SuggestTable suggests={suggests} onSelect={onSuggestChange} /> <SuggestTable suggests={suggests} onSelect={onSuggestChange} />
</React.Fragment>
) )
} }
</React.Fragment> </React.Fragment>
} }
{ {
suggestHaveMore && <div className='flex mt-3' style={{ justifyContent: 'center' }}> suggestHaveMore && <div className='flex pt-3' style={{ justifyContent: 'center' }}>
<Button onClick={loadMoreSuggests}>加载更多</Button> <Button onClick={loadMoreSuggests}>加载更多</Button>
</div> </div>
} }
......
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Table, Tooltip } from 'antd'; import { Table, Tooltip } from 'antd';
import { Resizable } from 'react-resizable'; import { Resizable } from 'react-resizable';
import ResizeObserver from 'rc-resize-observer';
import { isSzseEnv } from '../../../../util'; import { isSzseEnv } from '../../../../util';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
import './SuggestTable.less';
const ResizeableHeaderCell = props => { const ResizeableHeaderCell = props => {
const { onResize, width, onClick, ...restProps } = props; const { onResize, width, onClick, ...restProps } = props;
...@@ -96,6 +99,7 @@ const SuggestTable = (props) => { ...@@ -96,6 +99,7 @@ const SuggestTable = (props) => {
title: '使用次数', title: '使用次数',
dataIndex: 'referencesCount', dataIndex: 'referencesCount',
width: 80, width: 80,
ellipsis: true,
render: (_, record) => { render: (_, record) => {
return ( return (
<span>{record.recommendedStats?.referencesCount}</span> <span>{record.recommendedStats?.referencesCount}</span>
...@@ -166,10 +170,35 @@ const SuggestTable = (props) => { ...@@ -166,10 +170,35 @@ const SuggestTable = (props) => {
}; };
return ( return (
<div className='suggest-table'>
<ResizeObserver
onResize={({ width }) => {
let newColumns = [...cols];
newColumns.forEach((column, index) => {
if (!column.width) {
const rowWidth = (columns.reduce((preVal, col) => (col.width?col.width:0) + preVal, 0)) + 50;
if (width > rowWidth) {
column.width = width - rowWidth;
} else {
column.width = 200;
}
}
});
setColumns(newColumns);
}}
>
<Table <Table
rowSelection={rowSelection} rowSelection={rowSelection}
dataSource={suggests||[]} dataSource={suggests||[]}
pagination={false} pagination={false}
loading={false}
rowClassName={(record, index) => { rowClassName={(record, index) => {
return 'pointer'; return 'pointer';
}} }}
...@@ -179,13 +208,15 @@ const SuggestTable = (props) => { ...@@ -179,13 +208,15 @@ const SuggestTable = (props) => {
} }
}} }}
columns={ columns={
columns.map((col, index) => ({ columns.map((column, index) => {
...col, return {
onHeaderCell: column => ({ ...column,
onHeaderCell: (column: { width: any; }) => ({
width: column.width, width: column.width,
onResize: handleResize(index), onResize: handleResize(index),
}), }),
})) };
})
} }
onRow={(record, index) => { onRow={(record, index) => {
return { return {
...@@ -194,10 +225,9 @@ const SuggestTable = (props) => { ...@@ -194,10 +225,9 @@ const SuggestTable = (props) => {
} }
} }
}} }}
scroll={{
x: 'max-content'
}}
/> />
</ResizeObserver>
</div>
); );
} }
......
.suggest-table {
.yy-table {
margin: 0 !important;
}
}
\ No newline at end of file
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