Merge pull request #9291 from hsm-lv/fix-context

fix:修复上下文重复问题
This commit is contained in:
hsm-lv 2024-01-02 21:13:20 +08:00 committed by GitHub
commit 9a48e514a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 132 additions and 90 deletions

View File

@ -2021,24 +2021,32 @@ export class EditorManager {
if (!nearestScope && scopeNode && !scopeNode.isSecondFactor) {
nearestScope = scope;
}
if (scopeNode) {
const tmpSchema = await scopeNode?.info?.plugin?.buildDataSchemas?.(
scopeNode,
region,
trigger
);
const jsonschema = await scopeNode?.info?.plugin?.buildDataSchemas?.(
scopeNode,
region,
trigger
);
if (jsonschema) {
scope.removeSchema(jsonschema.$id);
scope.addSchema(jsonschema);
}
if (tmpSchema) {
const jsonschema = {
...tmpSchema,
...(tmpSchema?.$id
? {}
: {$id: `${scopeNode!.id}-${scopeNode!.type}`})
};
scope.removeSchema(jsonschema.$id);
scope.addSchema(jsonschema);
}
// 记录each列表等组件顺序
if (scopeNode?.info?.isListComponent) {
listScope.unshift(scope);
// 记录each列表等组件顺序
if (scopeNode?.info?.isListComponent) {
listScope.unshift(scope);
// 如果当前节点是list类型节点当前scope从父节点上取
if (nodeId === id) {
nearestScope = scope.parent;
// 如果当前节点是list类型节点当前scope从父节点上取
if (nodeId === id) {
nearestScope = scope.parent;
}
}
}
@ -2050,14 +2058,20 @@ export class EditorManager {
for (let scope of listScope) {
const [id, type] = scope.id.split('-');
const node = this.store.getNodeById(id, type);
const jsonschema = await node?.info?.plugin?.buildDataSchemas?.(
node,
region,
trigger
);
if (jsonschema) {
scope.removeSchema(jsonschema.$id);
scope.addSchema(jsonschema);
if (node) {
const tmpSchema = await node?.info?.plugin?.buildDataSchemas?.(
node,
region,
trigger
);
if (tmpSchema) {
const jsonschema = {
...tmpSchema,
...(tmpSchema?.$id ? {} : {$id: `${node!.id}-${node!.type}`})
};
scope.removeSchema(jsonschema.$id);
scope.addSchema(jsonschema);
}
}
}
}

View File

@ -2178,20 +2178,25 @@ export class CRUDPlugin extends BasePlugin {
return;
}
let childSchame = await child.info.plugin.buildDataSchemas(
const tmpSchema = await child.info.plugin.buildDataSchemas?.(
child,
undefined,
trigger,
node
);
let childSchema = {
...tmpSchema,
...(tmpSchema?.$id ? {} : {$id: `${child.id}-${child.type}`})
};
// 兼容table的rows并自行merged异步数据
if (child.type === 'table') {
let itemsSchema: any = {}; // 收集选择记录中的列
const columns: EditorNodeType = child.children.find(
item => item.isRegion && item.region === 'columns'
);
const rowsSchema = childSchame.properties.rows?.items;
const rowsSchema = childSchema.properties.rows?.items;
if (trigger) {
const isColumnChild = someTree(
@ -2213,13 +2218,13 @@ export class CRUDPlugin extends BasePlugin {
...rowsSchema?.properties
};
if (isColumnChild) {
Object.keys(tmpProperties).map(key => {
itemsSchema[key] = {
...tmpProperties[key]
};
});
Object.keys(tmpProperties).map(key => {
itemsSchema[key] = {
...tmpProperties[key]
};
});
if (isColumnChild) {
const childScope = this.manager.dataSchema.getScope(
`${child.id}-${child.type}-currentRow`
);
@ -2236,23 +2241,22 @@ export class CRUDPlugin extends BasePlugin {
}
}
}
childSchame = {
$id: childSchame.$id,
type: childSchame.type,
childSchema = {
$id: childSchema.$id,
type: childSchema.type,
properties: {
items: childSchame.properties.rows,
items: childSchema.properties.rows,
selectedItems: {
...childSchame.properties.selectedItems,
...childSchema.properties.selectedItems,
items: {
...childSchame.properties.selectedItems.items,
...childSchema.properties.selectedItems.items,
properties: itemsSchema
}
},
unSelectedItems: {
...childSchame.properties.unSelectedItems,
...childSchema.properties.unSelectedItems,
items: {
...childSchame.properties.unSelectedItems.items,
...childSchema.properties.unSelectedItems.items,
properties: itemsSchema
}
},
@ -2268,7 +2272,7 @@ export class CRUDPlugin extends BasePlugin {
};
}
return childSchame;
return childSchema;
}
rendererBeforeDispatchEvent(node: EditorNodeType, e: any, data: any) {

View File

@ -1129,10 +1129,13 @@ export class BaseCRUDPlugin extends BasePlugin {
return;
}
const childDataSchema = await child.info.plugin.buildDataSchemas(
child,
region
);
const tmpSchema = await child.info.plugin.buildDataSchemas?.(child, region);
const childDataSchema = {
...tmpSchema,
...(tmpSchema?.$id ? {} : {$id: `${child.id}-${child.type}`})
};
const items =
childDataSchema?.properties?.rows ?? childDataSchema?.properties?.items;
const schema: any = {

View File

@ -722,13 +722,16 @@ export class ComboControlPlugin extends BasePlugin {
const current = pool.shift() as EditorNodeType;
const schema = current.schema;
if (schema?.name) {
itemsSchema.properties[schema.name] =
await current.info.plugin.buildDataSchemas?.(
current,
region,
trigger,
node
);
const tmpSchema = await current.info.plugin.buildDataSchemas?.(
current,
region,
trigger,
node
);
itemsSchema.properties[schema.name] = {
tmpSchema,
...(tmpSchema?.$id ? {} : {$id: `${current!.id}-${current!.type}`})
};
}
}

View File

@ -1259,13 +1259,16 @@ export class FormPlugin extends BasePlugin {
const schema = current.schema;
if (current.rendererConfig?.isFormItem && schema.name) {
jsonschema.properties[schema.name] =
await current.info.plugin.buildDataSchemas?.(
current,
region,
trigger,
node
);
const tmpSchema = await current.info.plugin.buildDataSchemas?.(
current,
region,
trigger,
node
);
jsonschema.properties[schema.name] = {
...tmpSchema,
...(tmpSchema?.$id ? {} : {$id: `${current.id}-${current.type}`})
};
} else {
pool.push(...current.children);
}

View File

@ -1440,13 +1440,16 @@ export class TableControlPlugin extends BasePlugin {
const schema = current.schema;
if (schema.name) {
itemsSchema.properties[schema.name] =
await current.info.plugin.buildDataSchemas?.(
current,
region,
trigger,
node
);
const tmpSchema = await current.info.plugin.buildDataSchemas?.(
current,
region,
trigger,
node
);
itemsSchema.properties[schema.name] = {
...tmpSchema,
...(tmpSchema?.$id ? {} : {$id: `${current!.id}-${current!.type}`})
};
}
}
}

View File

@ -408,13 +408,16 @@ export class PagePlugin extends BasePlugin {
const schema = current.schema;
if (current.rendererConfig?.isFormItem && schema?.name) {
jsonschema.properties[schema.name] =
await current.info.plugin.buildDataSchemas?.(
current,
undefined,
trigger,
node
);
const tmpSchema = await current.info.plugin.buildDataSchemas?.(
current,
undefined,
trigger,
node
);
jsonschema.properties[schema.name] = {
...tmpSchema,
...(tmpSchema?.$id ? {} : {$id: `${current.id}-${current.type}`})
};
} else if (!current.rendererConfig?.storeType) {
pool.push(...current.children);
}

View File

@ -402,13 +402,16 @@ export class ServicePlugin extends BasePlugin {
const schema = current.schema;
if (current.rendererConfig?.isFormItem && schema?.name) {
jsonschema.properties[schema.name] =
await current.info.plugin.buildDataSchemas?.(
current,
undefined,
trigger,
node
);
const tmpSchema = await current.info.plugin.buildDataSchemas?.(
current,
undefined,
trigger,
node
);
jsonschema.properties[schema.name] = {
...tmpSchema,
...(tmpSchema?.$id ? {} : {$id: `${current.id}-${current.type}`})
};
} else if (!current.rendererConfig?.storeType) {
pool.push(...current.children);
}

View File

@ -846,13 +846,16 @@ export class TablePlugin extends BasePlugin {
const current = items.shift() as EditorNodeType;
const schema = current.schema;
if (schema.name) {
itemsSchema.properties[schema.name] =
await current.info.plugin.buildDataSchemas?.(
current,
region,
trigger,
node
);
const tmpSchema = await current.info.plugin.buildDataSchemas?.(
current,
region,
trigger,
node
);
itemsSchema.properties[schema.name] = {
...tmpSchema,
...(tmpSchema?.$id ? {} : {$id: `${current!.id}-${current!.type}`})
};
}
}
index++;

View File

@ -643,13 +643,16 @@ export class Table2Plugin extends BasePlugin {
for (let current of columns.children) {
const schema = current.schema;
if (schema?.name) {
itemsSchema.properties[schema.name] = current.info?.plugin
?.buildDataSchemas
? await current.info.plugin.buildDataSchemas(current, region)
const tmpSchema = current.info?.plugin?.buildDataSchemas
? await current.info.plugin.buildDataSchemas?.(current, region)
: {
type: 'string',
title: schema.label || schema.title
};
itemsSchema.properties[schema.name] = {
...tmpSchema,
...(tmpSchema?.$id ? {} : {$id: `${current!.id}-${current!.type}`})
};
}
}
}