diff --git a/components/apolloTable/component/Cell.less b/components/apolloTable/component/Cell.less index dda1c1c2e07d5336407c393b9b5e0c39f9ff581f..fba0e6bc7a53744adea6a5810b72ac2febc23ce0 100644 --- a/components/apolloTable/component/Cell.less +++ b/components/apolloTable/component/Cell.less @@ -52,3 +52,12 @@ top: 0; left: 0; } +.menuPop { + width: 110px; + + :global(.ant-popover-inner-content) { + padding: @paddingSmX 0; + border-radius: @borderRadius; + background: #333333; + } +} diff --git a/components/apolloTable/component/Cell.tsx b/components/apolloTable/component/Cell.tsx index b5f6360ed7a1bef2c1fd359d1171192a9d1091b5..a3acf2a1e3a8ab8b37b0621d078f1514c17a2db5 100644 --- a/components/apolloTable/component/Cell.tsx +++ b/components/apolloTable/component/Cell.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { Checkbox, message } from 'antd'; +import { Checkbox, message, Popover } from 'antd'; import _ from 'lodash'; import { config } from './base/config'; import { getEditComponent } from './base'; @@ -28,6 +28,7 @@ const Cell = (props: CellProps) => { cellEditable, rowSelection, columns, + contentMenu, } = props; const { columnType, @@ -93,7 +94,8 @@ const Cell = (props: CellProps) => { }; const selfRenderDetailCell = () => { - let empty = !cellData || cellData.length === 0 || (cellData.length === 1 && !cellData[0].text && !cellData[0].value); + let empty = + !cellData || cellData.length === 0 || (cellData.length === 1 && !cellData[0].text && !cellData[0].value); let detailConfig; if (typeof renderDetailCell === 'function') { detailConfig = renderDetailCell({ cellData, rowData: record, columnConfig }); @@ -152,7 +154,7 @@ const Cell = (props: CellProps) => { return ; }; - return ( + const detail = (
{ @@ -162,7 +164,16 @@ const Cell = (props: CellProps) => { > {rowSelection && columnIndex === 0 &&
{getCheckbox()}
} {showIndex && columnIndex === 0 &&
{getIndex()}
} - {showExpand && columnIndex === 0 &&
} + {showExpand && columnIndex === 0 && ( +
+ +
+ )} {empty ? ( emptyPlaceholder || '-' ) : ( @@ -180,6 +191,35 @@ const Cell = (props: CellProps) => { )}
); + console.log('contentMenu', contentMenu); + + return contentMenu ? ( + + {contentMenu.map((item: any, i: number) => { + return ( +
+ {item.label} +
+ ); + })} + + } + > + {detail} +
+ ) : ( + detail + ); }; const selfRenderEditCell = () => { diff --git a/components/apolloTable/component/Table.tsx b/components/apolloTable/component/Table.tsx index 1f3b724071efbf350a5302a691783459184da4b6..79b425d68116542199746dfff3c5cb71054624f6 100644 --- a/components/apolloTable/component/Table.tsx +++ b/components/apolloTable/component/Table.tsx @@ -305,6 +305,7 @@ export default class AirTable extends Component { emptyPlaceholder, cellEditable, rowSelection, + contentMenu, } = this.props; if (showColumns.length === 0 || showData.length === 0) { return; @@ -331,6 +332,7 @@ export default class AirTable extends Component { emptyPlaceholder={emptyPlaceholder} cellEditable={cellEditable} rowSelection={position === 'right' ? false : rowSelection} + contentMenu={contentMenu} /> ); }; diff --git a/components/apolloTable/component/index.tsx b/components/apolloTable/component/index.tsx index f62c432e329c951b9db72548bdf0baef473ff53b..f1c46820185585feadf9d6b28afbcca7eac984c3 100644 --- a/components/apolloTable/component/index.tsx +++ b/components/apolloTable/component/index.tsx @@ -60,6 +60,7 @@ class AirTable extends React.Component { noDataPlaceholder, columnWidth, headerHeight, + contentMenu, } = this.props; const sortConfig = operateConfig && operateConfig.menusGroup @@ -93,6 +94,7 @@ class AirTable extends React.Component { loading={loading} rowSelection={rowSelection} noDataPlaceholder={noDataPlaceholder} + contentMenu={contentMenu} /> {paginationConfig && } diff --git a/components/apolloTable/component/interface.tsx b/components/apolloTable/component/interface.tsx index afe2a22704bf34ab3810e71b7b04a4ac72e6689e..febf48d4b5bf9019f1efda6fac541cd19e958f8f 100644 --- a/components/apolloTable/component/interface.tsx +++ b/components/apolloTable/component/interface.tsx @@ -70,6 +70,7 @@ export interface TableProps extends LoadConfigProps { loading?: boolean; rowSelection?: any; noDataPlaceholder?: any; + contentMenu?:any; } export interface TableState { columns: ColumnProps[]; @@ -111,6 +112,7 @@ export interface CellProps { emptyPlaceholder?: string; cellEditable?: boolean; rowSelection?: any; + contentMenu?:any; } export interface EditCellProps {