Skip to content

Commit

Permalink
Merge pull request #1505 from alibaba/feat-drawerlist-columnhidden
Browse files Browse the repository at this point in the history
feat: drawerList、tableList 增加列隐藏操作
  • Loading branch information
lhbxs authored Mar 23, 2024
2 parents 3091520 + a88b19a commit 3ed749b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
16 changes: 11 additions & 5 deletions packages/form-render/src/widgets/listDrawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import React, { useState, useRef } from 'react';
import { Space, Table, Form, Button, Popconfirm, Tooltip, Divider } from 'antd';
import { ArrowDownOutlined, ArrowUpOutlined, PlusOutlined, InfoCircleOutlined, CloseOutlined, CopyOutlined } from '@ant-design/icons';
import type { FormListFieldData, FormListOperation, TableColumnsType } from 'antd';
import sortProperties from '../../models/sortProperties';
import FormDrawer from './drawerForm';
import FButton from '../components/FButton';
import './index.less';
Expand Down Expand Up @@ -54,6 +55,7 @@ const TableList: React.FC<Props> = (props: any) => {
actionColumnProps,
editorBtnProps,

hideOperate,
hideDelete,
hideCopy,
hideMove,
Expand Down Expand Up @@ -105,15 +107,19 @@ const TableList: React.FC<Props> = (props: any) => {
indexRef.current = null;
};

const columns: TableColumnsType<FormListFieldData> = Object.keys(columnSchema).map(dataIndex => {
const { title, tooltip, width } = columnSchema[dataIndex];
const tooltipProps = getTooltip(tooltip);
const columns: any = sortProperties(Object.entries(columnSchema)).map(([dataIndex, item]) => {
const { required, title, tooltip, width, columnHidden } = item;
if (columnHidden) {
return null;
}

const tooltipProps = getTooltip(tooltip);
return {
dataIndex,
width,
title: (
<>
{required && <span style={{ color: 'red', marginRight: '3px' }}>*</span>}
<span>{title}</span>
{tooltipProps && (
<Tooltip placement='top' {...tooltipProps}>
Expand All @@ -136,9 +142,9 @@ const TableList: React.FC<Props> = (props: any) => {
return renderCore({ schema: fieldSchema, parentPath: [field.name], rootPath: [...rootPath, field.name] });
}
}
});
}).filter(item => item);

if (!readOnly) {
if (!readOnly && !hideOperate) {
columns.push({
title: colHeaderText,
width: '190px',
Expand Down
10 changes: 7 additions & 3 deletions packages/form-render/src/widgets/listTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ const TableList: React.FC<ListTableProps> = (props) => {
copyItem(value);
};

const columns: TableColumnsType<FormListFieldData> = sortProperties(Object.entries(itemSchema)).map(([dataIndex, item]) => {
const { required, title, width, tooltip } = item;
const columns: any = sortProperties(Object.entries(itemSchema)).map(([dataIndex, item]) => {
const { required, title, width, tooltip, columnHidden } = item;
if (columnHidden) {
return null;
}

const tooltipProps = getTooltip(tooltip);
return {
dataIndex,
Expand Down Expand Up @@ -135,7 +139,7 @@ const TableList: React.FC<ListTableProps> = (props) => {
);
}
};
});
}).filter(item => item);

if (!readOnly && !hideOperate) {
columns.push({
Expand Down

0 comments on commit 3ed749b

Please sign in to comment.