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) {
nearestScope = scope;
}
const jsonschema = await scopeNode?.info?.plugin?.buildDataSchemas?.(
if (scopeNode) {
const tmpSchema = await scopeNode?.info?.plugin?.buildDataSchemas?.(
scopeNode,
region,
trigger
);
if (jsonschema) {
if (tmpSchema) {
const jsonschema = {
...tmpSchema,
...(tmpSchema?.$id
? {}
: {$id: `${scopeNode!.id}-${scopeNode!.type}`})
};
scope.removeSchema(jsonschema.$id);
scope.addSchema(jsonschema);
}
@ -2041,6 +2048,7 @@ export class EditorManager {
nearestScope = scope.parent;
}
}
}
scope = withoutSuper ? undefined : scope.parent;
}
@ -2050,17 +2058,23 @@ 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?.(
if (node) {
const tmpSchema = await node?.info?.plugin?.buildDataSchemas?.(
node,
region,
trigger
);
if (jsonschema) {
if (tmpSchema) {
const jsonschema = {
...tmpSchema,
...(tmpSchema?.$id ? {} : {$id: `${node!.id}-${node!.type}`})
};
scope.removeSchema(jsonschema.$id);
scope.addSchema(jsonschema);
}
}
}
}
// 存在当前行时找到最底层todo暂不考虑table套service+table的场景
const nearestScopeId =

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]
};
});
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?.(
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?.(
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?.(
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?.(
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?.(
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?.(
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}`})
};
}
}
}