fix(data-source): 迭代内容多层嵌套下子组件条件配置不生效

This commit is contained in:
roymondchen 2024-08-22 19:05:06 +08:00 committed by roymondchen
parent b2410a8739
commit e057ddc187
2 changed files with 20 additions and 11 deletions

View File

@ -250,20 +250,17 @@ class DataSourceManager extends EventEmitter {
return nodes;
}
return nodes.map((item) => {
const node = compliedIteratorItem({
return nodes.map((item) =>
compliedIteratorItem({
compile: (value: any) => compiledNodeField(value, ctxData),
dsId: ds.id,
item,
deps,
});
if (condDeps[node.id]?.keys.length && this.app.platform !== 'editor') {
node.condResult = compliedConditions(node, ctxData);
}
return node;
});
condDeps,
inEditor: this.app.platform === 'editor',
ctxData,
}),
);
}
public destroy() {

View File

@ -191,17 +191,29 @@ export const compliedIteratorItem = ({
dsId,
item,
deps,
condDeps,
inEditor,
ctxData,
}: {
compile: (value: any) => any;
dsId: string;
item: MNode;
deps: DepData;
condDeps: DepData;
inEditor: boolean;
ctxData: DataSourceManagerData;
}) => {
const { items, ...node } = item;
const newNode = cloneDeep(node);
if (condDeps[node.id]?.keys.length && !inEditor) {
newNode.condResult = compliedConditions(node, ctxData);
}
if (Array.isArray(items) && items.length) {
newNode.items = items.map((item) => compliedIteratorItem({ compile, dsId, item, deps }));
newNode.items = items.map((item) =>
compliedIteratorItem({ compile, dsId, item, deps, condDeps, inEditor, ctxData }),
);
} else if (items) {
newNode.items = items;
}