fix: bug T-3026

This commit is contained in:
dream2023 2024-02-02 11:04:24 +08:00
parent d18c7b389b
commit 56be4a38c5

View File

@ -22,7 +22,7 @@ export class InheritanceCollectionMixin extends CollectionV2 {
const parents: string[] = []; const parents: string[] = [];
const getParentCollectionsInner = (collectionName: string) => { const getParentCollectionsInner = (collectionName: string) => {
const collection = this.collectionManager.getCollection(collectionName); const collection = this.collectionManager.getCollection(collectionName, { dataSource: this.dataSource });
if (collection) { if (collection) {
const { inherits } = collection; const { inherits } = collection;
if (inherits) { if (inherits) {
@ -45,7 +45,7 @@ export class InheritanceCollectionMixin extends CollectionV2 {
return this.parentCollections; return this.parentCollections;
} }
this.parentCollections = this.getParentCollectionsName().map((collectionName) => { this.parentCollections = this.getParentCollectionsName().map((collectionName) => {
return this.collectionManager.getCollection(collectionName); return this.collectionManager.getCollection(collectionName, { dataSource: this.dataSource });
}); });
return this.parentCollections; return this.parentCollections;
} }
@ -57,7 +57,7 @@ export class InheritanceCollectionMixin extends CollectionV2 {
} }
const children: string[] = []; const children: string[] = [];
const collections = this.collectionManager.getCollections(); const collections = this.collectionManager.getCollections({ dataSource: this.dataSource });
const getChildrenCollectionsInner = (collectionName: string) => { const getChildrenCollectionsInner = (collectionName: string) => {
const inheritCollections = collections.filter((v) => { const inheritCollections = collections.filter((v) => {
return v.inherits?.includes(collectionName); return v.inherits?.includes(collectionName);
@ -90,7 +90,7 @@ export class InheritanceCollectionMixin extends CollectionV2 {
return this.childrenCollections[cacheKey]; return this.childrenCollections[cacheKey];
} }
this.childrenCollections[cacheKey] = this.getChildrenCollectionsName(isSupportView).map((collectionName) => { this.childrenCollections[cacheKey] = this.getChildrenCollectionsName(isSupportView).map((collectionName) => {
return this.collectionManager.getCollection(collectionName); return this.collectionManager.getCollection(collectionName, { dataSource: this.dataSource });
}); });
return this.childrenCollections[cacheKey]; return this.childrenCollections[cacheKey];
} }
@ -102,7 +102,10 @@ export class InheritanceCollectionMixin extends CollectionV2 {
const parentCollections = this.getParentCollectionsName(); const parentCollections = this.getParentCollectionsName();
this.inheritsFields = parentCollections this.inheritsFields = parentCollections
.map((collectionName) => this.collectionManager.getCollection(collectionName)?.getFields()) .map(
(collectionName) =>
this.collectionManager.getCollection(collectionName, { dataSource: this.dataSource })?.getFields(),
)
.flat() .flat()
.filter(Boolean); .filter(Boolean);
@ -134,14 +137,18 @@ export class InheritanceCollectionMixin extends CollectionV2 {
const currentFields = this.getCurrentFields(); const currentFields = this.getCurrentFields();
const parentCollections = this.getParentCollectionsName(); const parentCollections = this.getParentCollectionsName();
const parentCollection = this.collectionManager.getCollection<InheritanceCollectionMixin>(parentCollectionName); const parentCollection = this.collectionManager.getCollection<InheritanceCollectionMixin>(parentCollectionName, {
dataSource: this.dataSource,
});
const parentFields = parentCollection.getCurrentFields(); const parentFields = parentCollection.getCurrentFields();
const index = parentCollections.indexOf(parentCollectionName); const index = parentCollections.indexOf(parentCollectionName);
let filterFields = currentFields; let filterFields = currentFields;
if (index > 0) { if (index > 0) {
parentCollections.splice(index); parentCollections.splice(index);
parentCollections.forEach((collectionName) => { parentCollections.forEach((collectionName) => {
const collection = this.collectionManager.getCollection<InheritanceCollectionMixin>(collectionName); const collection = this.collectionManager.getCollection<InheritanceCollectionMixin>(collectionName, {
dataSource: this.dataSource,
});
filterFields = filterFields.concat(collection.getCurrentFields()); filterFields = filterFields.concat(collection.getCurrentFields());
}); });
} }
@ -161,7 +168,9 @@ export class InheritanceCollectionMixin extends CollectionV2 {
const collectionsInheritChain = [this.name]; const collectionsInheritChain = [this.name];
const getInheritChain = (name: string) => { const getInheritChain = (name: string) => {
const collection = this.collectionManager.getCollection<InheritanceCollectionMixin>(name); const collection = this.collectionManager.getCollection<InheritanceCollectionMixin>(name, {
dataSource: this.dataSource,
});
if (collection) { if (collection) {
const { inherits } = collection; const { inherits } = collection;
const children = collection.getChildrenCollectionsName(); const children = collection.getChildrenCollectionsName();
@ -179,7 +188,7 @@ export class InheritanceCollectionMixin extends CollectionV2 {
// 搜寻后代表 // 搜寻后代表
if (children) { if (children) {
for (let index = 0; index < children.length; index++) { for (let index = 0; index < children.length; index++) {
const collection = this.collectionManager.getCollection(children[index]); const collection = this.collectionManager.getCollection(children[index], { dataSource: this.dataSource });
const collectionKey = collection.name; const collectionKey = collection.name;
if (collectionsInheritChain.includes(collectionKey)) { if (collectionsInheritChain.includes(collectionKey)) {
continue; continue;
@ -202,7 +211,7 @@ export class InheritanceCollectionMixin extends CollectionV2 {
} }
const collectionsInheritChain = [this.name]; const collectionsInheritChain = [this.name];
const getInheritChain = (name: string) => { const getInheritChain = (name: string) => {
const collection = this.collectionManager.getCollection(name); const collection = this.collectionManager.getCollection(name, { dataSource: this.dataSource });
if (collection) { if (collection) {
const { inherits } = collection; const { inherits } = collection;
if (inherits) { if (inherits) {