mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-10 01:48:18 +00:00
fix: fieldId 重复问题
This commit is contained in:
parent
956fdeb1c1
commit
e761b1ae86
@ -301,8 +301,11 @@ export class DocumentModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
import(schema: RootSchema, checkId = false) {
|
import(schema: RootSchema, checkId = false) {
|
||||||
|
// TODO: do purge
|
||||||
|
this.nodes.forEach(node => {
|
||||||
|
this.destroyNode(node);
|
||||||
|
});
|
||||||
this.rootNode.import(schema as any, checkId);
|
this.rootNode.import(schema as any, checkId);
|
||||||
// todo: purge something
|
|
||||||
// todo: select added and active track added
|
// todo: select added and active track added
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,11 +70,6 @@ export class Prop implements IPropParent {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 兼容 vision 之前逻辑
|
|
||||||
if (this.key === 'fieldId' && stage === TransformStage.Clone) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type === 'literal' || type === 'expression') {
|
if (type === 'literal' || type === 'expression') {
|
||||||
// TODO 后端改造之后删除此逻辑
|
// TODO 后端改造之后删除此逻辑
|
||||||
if (this._value === null && stage === TransformStage.Save) {
|
if (this._value === null && stage === TransformStage.Save) {
|
||||||
|
|||||||
@ -25,10 +25,17 @@ export const designer = new Designer({ editor: editor });
|
|||||||
editor.set(Designer, designer);
|
editor.set(Designer, designer);
|
||||||
editor.set('designer', designer);
|
editor.set('designer', designer);
|
||||||
|
|
||||||
|
const nodeCache: any = {};
|
||||||
designer.project.onCurrentDocumentChange((doc) => {
|
designer.project.onCurrentDocumentChange((doc) => {
|
||||||
doc.onRendererReady(() => {
|
doc.onRendererReady(() => {
|
||||||
bus.emit(VE_EVENTS.VE_PAGE_PAGE_READY);
|
bus.emit(VE_EVENTS.VE_PAGE_PAGE_READY);
|
||||||
});
|
});
|
||||||
|
doc.onNodeCreate((node) => {
|
||||||
|
nodeCache[node.id] = node;
|
||||||
|
});
|
||||||
|
doc.onNodeDestroy((node) => {
|
||||||
|
delete nodeCache[node.id];
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
interface Variable {
|
interface Variable {
|
||||||
@ -80,11 +87,23 @@ designer.addPropsReducer(upgradePropsReducer, TransformStage.Upgrade);
|
|||||||
// 节点 props 初始化
|
// 节点 props 初始化
|
||||||
designer.addPropsReducer((props, node) => {
|
designer.addPropsReducer((props, node) => {
|
||||||
// run initials
|
// run initials
|
||||||
|
const newProps: any = {
|
||||||
|
...props,
|
||||||
|
};
|
||||||
|
if (newProps.fieldId) {
|
||||||
|
const fieldIds: any = [];
|
||||||
|
Object.keys(nodeCache).forEach(nodeId => {
|
||||||
|
const fieldId = nodeCache[nodeId].getPropValue('fieldId');
|
||||||
|
if (fieldId) {
|
||||||
|
fieldIds.push(fieldId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (fieldIds.indexOf(props.fieldId) >= 0) {
|
||||||
|
newProps.fieldId = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
const initials = node.componentMeta.getMetadata().experimental?.initials;
|
const initials = node.componentMeta.getMetadata().experimental?.initials;
|
||||||
if (initials) {
|
if (initials) {
|
||||||
const newProps: any = {
|
|
||||||
...props,
|
|
||||||
};
|
|
||||||
const getRealValue = (propValue: any) => {
|
const getRealValue = (propValue: any) => {
|
||||||
if (isVariable(propValue)) {
|
if (isVariable(propValue)) {
|
||||||
return propValue.value;
|
return propValue.value;
|
||||||
@ -98,7 +117,7 @@ designer.addPropsReducer((props, node) => {
|
|||||||
// FIXME! this implements SettingTarget
|
// FIXME! this implements SettingTarget
|
||||||
try {
|
try {
|
||||||
// FIXME! item.name could be 'xxx.xxx'
|
// FIXME! item.name could be 'xxx.xxx'
|
||||||
const ov = props[item.name];
|
const ov = newProps[item.name];
|
||||||
const v = item.initial(node as any, getRealValue(ov));
|
const v = item.initial(node as any, getRealValue(ov));
|
||||||
if (ov === undefined && v !== undefined) {
|
if (ov === undefined && v !== undefined) {
|
||||||
newProps[item.name] = v;
|
newProps[item.name] = v;
|
||||||
@ -112,10 +131,8 @@ designer.addPropsReducer((props, node) => {
|
|||||||
node.props.add(newProps[item.name], item.name);
|
node.props.add(newProps[item.name], item.name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return newProps;
|
|
||||||
}
|
}
|
||||||
return props;
|
return newProps;
|
||||||
}, TransformStage.Init);
|
}, TransformStage.Init);
|
||||||
|
|
||||||
designer.addPropsReducer((props: any, node: Node) => {
|
designer.addPropsReducer((props: any, node: Node) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user