mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:48:55 +08:00
fix: 修复弹窗编辑问题 (#10083)
This commit is contained in:
parent
5f76ea8b5d
commit
c3bcbf2a70
@ -1506,11 +1506,6 @@ export function mergeDefinitions(
|
||||
|
||||
let schema = originSchema;
|
||||
Object.keys(definitions).forEach(key => {
|
||||
// 弹窗里面用到了才更新
|
||||
if (!refs.includes(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 要修改就复制一份,避免污染原始数据
|
||||
if (schema === originSchema) {
|
||||
schema = {...schema, definitions: {...schema.definitions}};
|
||||
@ -1518,10 +1513,16 @@ export function mergeDefinitions(
|
||||
|
||||
const {$$originId, ...def} = definitions[key];
|
||||
|
||||
if ($$originId) {
|
||||
const parent = JSONGetParentById(schema, $$originId);
|
||||
|
||||
// 当前更新弹窗里面用到了需要转成 ref
|
||||
if (refs.includes(key)) {
|
||||
if (schema.$$id === $$originId) {
|
||||
schema = JSONUpdate(schema, $$originId, JSONPipeIn(def));
|
||||
} else if ($$originId) {
|
||||
const parent = JSONGetParentById(schema, $$originId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!parent) {
|
||||
throw new Error('Can not find modal action.');
|
||||
}
|
||||
@ -1539,7 +1540,23 @@ export function mergeDefinitions(
|
||||
})
|
||||
});
|
||||
schema.definitions[key] = JSONPipeIn(def);
|
||||
} else {
|
||||
} else if (parent) {
|
||||
// 没用到,可能修改了弹窗的内容为引用其他弹窗,同样需要更新,但是不会提取为 definitions
|
||||
const modalType = def.type === 'drawer' ? 'drawer' : 'dialog';
|
||||
schema = JSONUpdate(schema, parent.$$id, {
|
||||
...parent,
|
||||
__actionModals: undefined,
|
||||
args: undefined,
|
||||
dialog: undefined,
|
||||
drawer: undefined,
|
||||
actionType: def.actionType ?? modalType,
|
||||
[modalType]: JSONPipeIn({
|
||||
...def,
|
||||
$$originId: undefined
|
||||
})
|
||||
});
|
||||
}
|
||||
} else if (refs.includes(key)) {
|
||||
schema.definitions[key] = JSONPipeIn(def);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user