From fe9b0f1dfb234faac91d13ce18210d5db56ef766 Mon Sep 17 00:00:00 2001 From: zhangwenshuai Date: Thu, 4 Feb 2021 17:43:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0formView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/apolloTable/editFormV3/index.tsx | 26 +++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/components/apolloTable/editFormV3/index.tsx b/components/apolloTable/editFormV3/index.tsx index f5ddf65..dd1f696 100644 --- a/components/apolloTable/editFormV3/index.tsx +++ b/components/apolloTable/editFormV3/index.tsx @@ -309,5 +309,27 @@ class FormWrap extends Component { ); } } - -export default Form.create({ name: 'editFormV3' })(FormWrap); +function mapPropsToFields(props) { + const { data, rowData } = props; + const returnObj:any = {}; + if (!data || typeof data !== 'object') return returnObj; + Object.keys(data).forEach((key) => { + const col = data[key]; + if (!col) { + return; + } + const { columnType, value, renderEditForm } = col; + let detailConfig: any; + if (typeof renderEditForm === 'function') { + detailConfig = renderEditForm({ cellData: value, rowData, columnConfig: col }); + } else { + detailConfig = config[String(columnType)] || config['1']; + } + const formatValue = getFormat(detailConfig, col, value); + returnObj[columnType] = Form.createFormField({ + value: formatValue, + }); + }); + return returnObj; +} +export default Form.create({ name: 'editFormV3', mapPropsToFields })(FormWrap); -- 2.21.0