Skip to content

Commit 899dd85

Browse files
author
liyuan-meng
committed
feat: 表格列文本和链接组件添加 tooltipValue 参数
1 parent 1b61aff commit 899dd85

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/components/c-table/columnTpl/link.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ import { isVoid } from '../util';
55
import Tooltip from '../../tooltip';
66
import './index.less';
77

8-
export default function LinkTpl({ value, row, linkKey, link, onClick, line = 1 }) {
8+
export default function LinkTpl({ value, row, linkKey, link, onClick, line = 1, tooltipValue }) {
99
const ref = useRef();
1010
const [tooltipContent, setTooltipContent] = useState('');
1111

1212
useEffect(() => {
13-
if (!isVoid(value)) {
13+
if (tooltipValue) {
14+
setTooltipContent(tooltipValue);
15+
} else if (!isVoid(value)) {
1416
if (ref.current.scrollHeight > ref.current.clientHeight + 4) {
1517
setTooltipContent(value);
1618
}
1719
}
18-
}, []);
20+
}, [tooltipValue]);
1921

2022
if (isVoid(value)) {
2123
return '-';

src/components/c-table/columnTpl/text.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ import { isVoid } from '../util';
55
import Tooltip from '../../tooltip';
66
import './index.less';
77

8-
export default function TextTpl({ value, line = 1 }) {
8+
export default function TextTpl({ value, line = 1, tooltipValue }) {
99
const ref = useRef();
1010
const [tooltipContent, setTooltipContent] = useState('');
1111

1212
useEffect(() => {
13-
if (!isVoid(value)) {
13+
if (tooltipValue) {
14+
setTooltipContent(tooltipValue);
15+
} else if (!isVoid(value)) {
1416
if (ref.current.scrollHeight > ref.current.clientHeight + 4) {
1517
setTooltipContent(value);
1618
}
1719
}
18-
}, []);
20+
}, [tooltipValue]);
1921

2022
if (isVoid(value)) {
2123
return '-';

src/components/c-table/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ this.tableRef.current.setColumn(columnData, isReloadGrid?);
224224
| ------------------- | -------------------------------------------- | --------------------------- | ---------------- |
225225
| value | 展示值,使用组件的形式必传,使用 typeConfig 忽略此字段 | string | - |
226226
| typeConfig.line | 展示行数 | number | 1 |
227+
| typeConfig.tooltipValue | 如果不想让tooltip展示value的值,可以单独配置 tooltipValue | string | - |
227228

228229
**(5)type 为 链接类型-`LINK`**
229230
_可根据下表配置 typeConfig,查看 [Demo](https://cloud-react.shuyun.com/v1/cloud-react/data/c-table#标准化表格-文本类型);也可以使用组件形式 <Table.LinkTpl/>,查看 [Demo](https://cloud-react.shuyun.com/v1/cloud-react/data/c-table#标准化表格-使用列模板形式)_
@@ -234,6 +235,7 @@ this.tableRef.current.setColumn(columnData, isReloadGrid?);
234235
| typeConfig.linkKey | 链接 key(取自 row 中的字段) | string | '' |
235236
| typeConfig.link | 链接值 | string | '' |
236237
| typeConfig.onClick | 点击链接的回调函数 | func | - |
238+
| typeConfig.tooltipValue | 如果不想让tooltip展示value的值,可以单独配置 tooltipValue | string | - |
237239

238240
**(6)type 为 标签类型-`TAG`**
239241
_可根据下表配置 typeConfig,查看 [Demo](https://cloud-react.shuyun.com/v1/cloud-react/data/c-table#标准化表格-标签类型);也可以使用组件形式 <Table.TagTpl/>,查看 [Demo](https://cloud-react.shuyun.com/v1/cloud-react/data/c-table#标准化表格-使用列模板形式)_

0 commit comments

Comments
 (0)