Merge "feat: support copyable for SimpleTable component"
This commit is contained in:
commit
4dc20fff27
@ -16,7 +16,7 @@ import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
import PropTypes from 'prop-types';
|
||||
import { get, isString, isEmpty, isEqual, has } from 'lodash';
|
||||
import { Table } from 'antd';
|
||||
import { Table, Typography } from 'antd';
|
||||
import {
|
||||
getColumnSorter,
|
||||
getSortOrder,
|
||||
@ -33,6 +33,8 @@ import {
|
||||
import { getNoValue } from 'utils/index';
|
||||
import styles from './index.less';
|
||||
|
||||
const { Paragraph } = Typography;
|
||||
|
||||
export default class SimpleTable extends React.Component {
|
||||
static propTypes = {
|
||||
data: PropTypes.array.isRequired,
|
||||
@ -89,6 +91,7 @@ export default class SimpleTable extends React.Component {
|
||||
linkPrefix,
|
||||
valueMap,
|
||||
unit,
|
||||
copyable,
|
||||
...rest
|
||||
} = column;
|
||||
if (column.key === 'operation') {
|
||||
@ -123,6 +126,14 @@ export default class SimpleTable extends React.Component {
|
||||
if (dataIndex === 'cost' || isPrice) {
|
||||
newRender = this.getPriceRender(newRender, column);
|
||||
}
|
||||
if (copyable) {
|
||||
newRender = (value) => {
|
||||
if (value && value !== '-') {
|
||||
return <Paragraph copyable>{value}</Paragraph>;
|
||||
}
|
||||
return '-';
|
||||
};
|
||||
}
|
||||
const newColumn = {
|
||||
...rest,
|
||||
dataIndex,
|
||||
|
Loading…
Reference in New Issue
Block a user