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;
...@@ -38,7 +41,7 @@ const ResizeableHeaderCell = props => { ...@@ -38,7 +41,7 @@ const ResizeableHeaderCell = props => {
const SuggestTable = (props) => { const SuggestTable = (props) => {
const { suggests, onSelect } = props; const { suggests, onSelect } = props;
const cols = [ const cols = [
{ {
title: '中文名称', title: '中文名称',
...@@ -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,38 +170,64 @@ const SuggestTable = (props) => { ...@@ -166,38 +170,64 @@ const SuggestTable = (props) => {
}; };
return ( return (
<Table <div className='suggest-table'>
rowSelection={rowSelection} <ResizeObserver
dataSource={suggests||[]} onResize={({ width }) => {
pagination={false}
rowClassName={(record, index) => { let newColumns = [...cols];
return 'pointer';
}} newColumns.forEach((column, index) => {
components={{
header: { if (!column.width) {
cell: ResizeableHeaderCell, const rowWidth = (columns.reduce((preVal, col) => (col.width?col.width:0) + preVal, 0)) + 50;
}
}} if (width > rowWidth) {
columns={ column.width = width - rowWidth;
columns.map((col, index) => ({
...col, } else {
onHeaderCell: column => ({ column.width = 200;
width: column.width, }
onResize: handleResize(index), }
}),
})) });
}
onRow={(record, index) => { setColumns(newColumns);
return { }}
onClick: (e) => { >
onSelect && onSelect(record); <Table
rowSelection={rowSelection}
dataSource={suggests||[]}
pagination={false}
loading={false}
rowClassName={(record, index) => {
return 'pointer';
}}
components={{
header: {
cell: ResizeableHeaderCell,
}
}}
columns={
columns.map((column, index) => {
return {
...column,
onHeaderCell: (column: { width: any; }) => ({
width: column.width,
onResize: handleResize(index),
}),
};
})
} }
} onRow={(record, index) => {
}} return {
scroll={{ onClick: (e) => {
x: 'max-content' onSelect && onSelect(record);
}} }
/> }
}}
/>
</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