Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: inputTable组件中嵌套picker时数据域更新问题 #9094

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions packages/amis/src/renderers/Form/InputTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -1428,14 +1428,7 @@ export default class FormTable extends React.Component<TableProps, TableState> {

const origin = getTree(items, indexes);

const comboNames: Array<string> = [];
(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,
Expand All @@ -1444,14 +1437,13 @@ export default class FormTable extends React.Component<TableProps, TableState> {
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;
}
);
Expand Down
Loading