fix:修复上下文重复问题

This commit is contained in:
lvxiaojiao 2024-01-02 15:59:35 +08:00
parent d9ace501e3
commit 77d1ea97a9
10 changed files with 132 additions and 90 deletions

View File

@ -2021,13 +2021,20 @@ export class EditorManager {
if (!nearestScope && scopeNode && !scopeNode.isSecondFactor) { if (!nearestScope && scopeNode && !scopeNode.isSecondFactor) {
nearestScope = scope; nearestScope = scope;
} }
if (scopeNode) {
const jsonschema = await scopeNode?.info?.plugin?.buildDataSchemas?.( const tmpSchema = await scopeNode?.info?.plugin?.buildDataSchemas?.(
scopeNode, scopeNode,
region, region,
trigger trigger
); );
if (jsonschema) {
if (tmpSchema) {
const jsonschema = {
...tmpSchema,
...(tmpSchema?.$id
? {}
: {$id: `${scopeNode!.id}-${scopeNode!.type}`})
};
scope.removeSchema(jsonschema.$id); scope.removeSchema(jsonschema.$id);
scope.addSchema(jsonschema); scope.addSchema(jsonschema);
} }
@ -2041,6 +2048,7 @@ export class EditorManager {
nearestScope = scope.parent; nearestScope = scope.parent;
} }
} }
}
scope = withoutSuper ? undefined : scope.parent; scope = withoutSuper ? undefined : scope.parent;
} }
@ -2050,17 +2058,23 @@ export class EditorManager {
for (let scope of listScope) { for (let scope of listScope) {
const [id, type] = scope.id.split('-'); const [id, type] = scope.id.split('-');
const node = this.store.getNodeById(id, type); const node = this.store.getNodeById(id, type);
const jsonschema = await node?.info?.plugin?.buildDataSchemas?.( if (node) {
const tmpSchema = await node?.info?.plugin?.buildDataSchemas?.(
node, node,
region, region,
trigger trigger
); );
if (jsonschema) { if (tmpSchema) {
const jsonschema = {
...tmpSchema,
...(tmpSchema?.$id ? {} : {$id: `${node!.id}-${node!.type}`})
};
scope.removeSchema(jsonschema.$id); scope.removeSchema(jsonschema.$id);
scope.addSchema(jsonschema); scope.addSchema(jsonschema);
} }
} }
} }
}
// 存在当前行时找到最底层todo暂不考虑table套service+table的场景 // 存在当前行时找到最底层todo暂不考虑table套service+table的场景
const nearestScopeId = const nearestScopeId =

View File

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

View File

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

View File

@ -722,13 +722,16 @@ export class ComboControlPlugin extends BasePlugin {
const current = pool.shift() as EditorNodeType; const current = pool.shift() as EditorNodeType;
const schema = current.schema; const schema = current.schema;
if (schema?.name) { if (schema?.name) {
itemsSchema.properties[schema.name] = const tmpSchema = await current.info.plugin.buildDataSchemas?.(
await current.info.plugin.buildDataSchemas?.(
current, current,
region, region,
trigger, trigger,
node 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; const schema = current.schema;
if (current.rendererConfig?.isFormItem && schema.name) { if (current.rendererConfig?.isFormItem && schema.name) {
jsonschema.properties[schema.name] = const tmpSchema = await current.info.plugin.buildDataSchemas?.(
await current.info.plugin.buildDataSchemas?.(
current, current,
region, region,
trigger, trigger,
node node
); );
jsonschema.properties[schema.name] = {
...tmpSchema,
...(tmpSchema?.$id ? {} : {$id: `${current.id}-${current.type}`})
};
} else { } else {
pool.push(...current.children); pool.push(...current.children);
} }

View File

@ -1440,13 +1440,16 @@ export class TableControlPlugin extends BasePlugin {
const schema = current.schema; const schema = current.schema;
if (schema.name) { if (schema.name) {
itemsSchema.properties[schema.name] = const tmpSchema = await current.info.plugin.buildDataSchemas?.(
await current.info.plugin.buildDataSchemas?.(
current, current,
region, region,
trigger, trigger,
node 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; const schema = current.schema;
if (current.rendererConfig?.isFormItem && schema?.name) { if (current.rendererConfig?.isFormItem && schema?.name) {
jsonschema.properties[schema.name] = const tmpSchema = await current.info.plugin.buildDataSchemas?.(
await current.info.plugin.buildDataSchemas?.(
current, current,
undefined, undefined,
trigger, trigger,
node node
); );
jsonschema.properties[schema.name] = {
...tmpSchema,
...(tmpSchema?.$id ? {} : {$id: `${current.id}-${current.type}`})
};
} else if (!current.rendererConfig?.storeType) { } else if (!current.rendererConfig?.storeType) {
pool.push(...current.children); pool.push(...current.children);
} }

View File

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

View File

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

View File

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