From ee8d57a0802fabf25dece721b32246bd32d21a2c Mon Sep 17 00:00:00 2001 From: huangxj29 Date: Mon, 11 Dec 2023 13:53:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20inputTable=E7=BB=84=E4=BB=B6=E4=B8=AD?= =?UTF-8?q?=E5=B5=8C=E5=A5=97picker=E6=97=B6=E6=95=B0=E6=8D=AE=E5=9F=9F?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../amis/src/renderers/Form/InputTable.tsx | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/packages/amis/src/renderers/Form/InputTable.tsx b/packages/amis/src/renderers/Form/InputTable.tsx index d5242b1b3d8..0051665ce8f 100644 --- a/packages/amis/src/renderers/Form/InputTable.tsx +++ b/packages/amis/src/renderers/Form/InputTable.tsx @@ -36,7 +36,7 @@ import {SchemaApi, SchemaCollection, SchemaClassName} from '../../Schema'; import find from 'lodash/find'; import moment from 'moment'; import merge from 'lodash/merge'; -import mergeWith from 'lodash/mergeWith'; +import assignWith from 'lodash/assignWith'; import type {SchemaTokenizeableString} from '../../Schema'; @@ -1428,14 +1428,7 @@ export default class FormTable extends React.Component { const origin = getTree(items, indexes); - const comboNames: Array = []; - (props.$schema.columns ?? []).forEach((e: any) => { - if (e.type === 'combo' && !Array.isArray(diff)) { - comboNames.push(e.name); - } - }); - - const data = mergeWith( + const data = assignWith( {}, origin, diff, @@ -1444,14 +1437,13 @@ export default class FormTable extends React.Component { srcValue: any, key: string, object: any, - source: any, - stack: any + source: any ) => { - if (Array.isArray(objValue) && Array.isArray(srcValue)) { - // 处理combo - return srcValue; + // 若变更前后都是对象,则进行递归合并 + if (isObject(objValue) && isObject(srcValue)) { + return merge({}, objValue, srcValue); } - // 直接return,默认走的mergeWith自身的merge + // 直接return,默认走的assignWith自身的merge return; } );