fix: 修复循环类组件绑定数据时,无法识别定义在root scope中的schema的问题(#11034) (#11092)

Co-authored-by: chenfan02 <chenfan02@baidu.com>
This commit is contained in:
Franck Chan 2024-10-22 19:38:42 +08:00 committed by GitHub
parent 8624ec5468
commit be917022ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 66 additions and 44 deletions

View File

@ -545,18 +545,24 @@ export class CardsPlugin extends BasePlugin {
node.schema.source && String(node.schema.source).match(/{([\w-_]+)}/);
let field = node.schema.name || match?.[1];
const scope = this.manager.dataSchema.getScope(`${node.id}-${node.type}`);
const schema = scope?.parent?.getSchemaByPath(field);
if (isObject(schema?.items)) {
dataSchema = {
...dataSchema,
...(schema!.items as any)
};
// 列表添加序号方便处理
set(dataSchema, 'properties.index', {
type: 'number',
title: '索引'
});
if (scope) {
const origin = this.manager.dataSchema.current;
this.manager.dataSchema.switchTo(scope.parent!);
const schema = this.manager.dataSchema.getSchemaByPath(field);
this.manager.dataSchema.switchTo(origin);
if (isObject(schema?.items)) {
dataSchema = {
...dataSchema,
...(schema!.items as any)
};
// 列表添加序号方便处理
set(dataSchema, 'properties.index', {
type: 'number',
title: '索引'
});
}
}
return dataSchema;

View File

@ -397,19 +397,24 @@ export class EachPlugin extends BasePlugin {
node.schema.source && String(node.schema.source).match(/{([\w-_]+)}/);
let field = node.schema.name || match?.[1];
const scope = this.manager.dataSchema.getScope(`${node.id}-${node.type}`);
const schema = scope?.parent?.getSchemaByPath(field);
if (isObject(schema?.items)) {
dataSchema = {
...dataSchema,
...(schema!.items as any)
};
if (scope) {
const origin = this.manager.dataSchema.current;
this.manager.dataSchema.switchTo(scope.parent!);
const schema = this.manager.dataSchema.getSchemaByPath(field);
this.manager.dataSchema.switchTo(origin);
if (isObject(schema?.items)) {
dataSchema = {
...dataSchema,
...(schema!.items as any)
};
// 循环添加索引方便渲染序号
set(dataSchema, 'properties.index', {
type: 'number',
title: '索引'
});
// 列表添加序号方便处理
set(dataSchema, 'properties.index', {
type: 'number',
title: '索引'
});
}
}
return dataSchema;

View File

@ -353,19 +353,24 @@ export class ListPlugin extends BasePlugin {
node.schema.source && String(node.schema.source).match(/{([\w-_]+)}/);
let field = node.schema.name || match?.[1];
const scope = this.manager.dataSchema.getScope(`${node.id}-${node.type}`);
const schema = scope?.parent?.getSchemaByPath(field);
if (isObject(schema?.items)) {
dataSchema = {
...dataSchema,
...(schema!.items as any)
};
if (scope) {
const origin = this.manager.dataSchema.current;
this.manager.dataSchema.switchTo(scope.parent!);
const schema = this.manager.dataSchema.getSchemaByPath(field);
this.manager.dataSchema.switchTo(origin);
if (isObject(schema?.items)) {
dataSchema = {
...dataSchema,
...(schema!.items as any)
};
// 循环添加序号方便处理
set(dataSchema, 'properties.index', {
type: 'number',
title: '序号'
});
// 列表添加序号方便处理
set(dataSchema, 'properties.index', {
type: 'number',
title: '索引'
});
}
}
return dataSchema;

View File

@ -421,18 +421,24 @@ export class List2Plugin extends BasePlugin {
node.schema.source && String(node.schema.source).match(/{([\w-_]+)}/);
let field = node.schema.name || match?.[1];
const scope = this.manager.dataSchema.getScope(`${node.id}-${node.type}`);
const schema = scope?.parent?.getSchemaByPath(field);
if (isObject(schema?.items)) {
dataSchema = {
...dataSchema,
...(schema!.items as any)
};
// 列表添加序号方便处理
set(dataSchema, 'properties.index', {
type: 'number',
title: '索引'
});
if (scope) {
const origin = this.manager.dataSchema.current;
this.manager.dataSchema.switchTo(scope.parent!);
const schema = this.manager.dataSchema.getSchemaByPath(field);
this.manager.dataSchema.switchTo(origin);
if (isObject(schema?.items)) {
dataSchema = {
...dataSchema,
...(schema!.items as any)
};
// 列表添加序号方便处理
set(dataSchema, 'properties.index', {
type: 'number',
title: '索引'
});
}
}
return dataSchema;