From c6f92259b26b79f3c95642d85d9fcab36b9bdaf2 Mon Sep 17 00:00:00 2001 From: "Jingwei.Zhang" Date: Mon, 7 Aug 2023 14:30:04 +0800 Subject: [PATCH] feat: support custom option col support custom label and content col for detail card in base detail tab Change-Id: I4a1d92451ee8adc872e754cf270d2a96f3598570 --- src/components/DetailCard/index.jsx | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/components/DetailCard/index.jsx b/src/components/DetailCard/index.jsx index fbc76f44..0ac762ce 100644 --- a/src/components/DetailCard/index.jsx +++ b/src/components/DetailCard/index.jsx @@ -90,14 +90,22 @@ const renderLabel = (option) => { const renderOptions = (options, data, loading, labelCol, contentCol) => options .filter((option) => !option.hidden) - .map((option, index) => ( - - - {renderLabel(option)} - {getContent(data, option)} - - - )); + .map((option, index) => { + const currentLabelCol = has(option, 'labelCol') + ? option.labelCol + : labelCol; + const currentContentCol = has(option, 'contentCol') + ? option.contentCol + : contentCol; + return ( + + + {renderLabel(option)} + {getContent(data, option)} + + + ); + }); const DetailCard = ({ title, @@ -145,6 +153,8 @@ const detailProps = PropTypes.shape({ tooltip: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), dataIndex: PropTypes.string, valueRender: PropTypes.string, + labelCol: PropTypes.number, + contentCol: PropTypes.number, }); DetailCard.defaultProps = {