Skip to content

Commit

Permalink
feat: tableList 增加 hidetableWhenNoData
Browse files Browse the repository at this point in the history
  • Loading branch information
MoYuM committed Jan 24, 2024
1 parent 0764d60 commit 4894267
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions packages/form-render/src/widgets/listTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ interface ListTableProps {
delConfirmProps: any;
renderCore: any;
rootPath: any;
/*
* 没有数据时是否隐藏表格
*/
hideTableWhenNoData?: boolean;
[key: string]: any;
};

Expand Down Expand Up @@ -57,6 +61,7 @@ const TableList: React.FC<ListTableProps> = (props) => {
hideMove,
hideAdd,
hideOperate,
hideTableWhenNoData,

addItem,
copyItem,
Expand Down Expand Up @@ -141,19 +146,19 @@ const TableList: React.FC<ListTableProps> = (props) => {
...otherActionColumnProps,
render: (_, field) => (
<Form.Item>
<Space className='fr-list-item-operate' split={operateBtnType !== 'icon' && <Divider type='vertical'/>}>
<Space className='fr-list-item-operate' split={operateBtnType !== 'icon' && <Divider type='vertical' />}>
{!hideMove && (
<>
<FButton
<FButton
disabled={field.name === 0}
onClick={() => moveItem(field.name, field.name - 1)}
icon={<ArrowUpOutlined/>}
icon={<ArrowUpOutlined />}
{...moveUpBtnProps}
/>
<FButton
<FButton
disabled={field.name === fields.length - 1}
onClick={() => moveItem(field.name, field.name + 1)}
icon={<ArrowDownOutlined/>}
icon={<ArrowDownOutlined />}
{...moveDownBtnProps}
/>
</>
Expand All @@ -164,16 +169,16 @@ const TableList: React.FC<ListTableProps> = (props) => {
{...delConfirmProps}
>
<FButton
icon={<CloseOutlined/>}
icon={<CloseOutlined />}
btnType={operateBtnType}
{...deleteBtnProps}
/>
</Popconfirm>
)}
{!hideCopy && (
<FButton
<FButton
onClick={() => handleCopy(field.name)}
icon={<CopyOutlined/>}
icon={<CopyOutlined />}
{...copyBtnProps}
/>
)}
Expand All @@ -183,17 +188,21 @@ const TableList: React.FC<ListTableProps> = (props) => {
});
}

const showTable = fields.length > 0 ? true : !hideTableWhenNoData;

return (
<div className={classnames('fr-table-list', { 'fr-table-list-no-popover': !islidatePopover })}>
<Table
size='middle'
scroll={{ x: 'max-content' }}
style={{ marginBottom: '12px'}}
{...retProps}
columns={columns}
dataSource={fields}
pagination={paginationConfig}
/>
{showTable && (
<Table
size='middle'
scroll={{ x: 'max-content' }}
style={{ marginBottom: '12px' }}
{...retProps}
columns={columns}
dataSource={fields}
pagination={paginationConfig}
/>
)}
{(!schema.max || fields.length < schema.max) && !hideAdd && (
<Button
icon={<PlusOutlined />}
Expand Down

0 comments on commit 4894267

Please sign in to comment.