feat: support copyable for SimpleTable component

Support copyable attribute for SimpleTable component

Change-Id: Ia780bca1476c98d699059ee60755c0636997067d
This commit is contained in:
zhangjingwei 2024-01-31 10:27:36 +08:00
parent 8a1d7ab034
commit 7c97ddb3ce

View File

@ -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,