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