fix: default exportable fields (#506)
This commit is contained in:
parent
308fe7a123
commit
2defd4c0d2
@ -1,7 +1,6 @@
|
|||||||
import { Schema, useFieldSchema } from '@formily/react';
|
import { Schema, useFieldSchema } from '@formily/react';
|
||||||
import { merge } from '@formily/shared';
|
import { merge } from '@formily/shared';
|
||||||
import { SchemaInitializer, useCollection, useCompile, useDesignable } from '@nocobase/client';
|
import { SchemaInitializer, useCollection, useCompile, useDesignable } from '@nocobase/client';
|
||||||
import { cloneDeep } from 'lodash';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useFields } from './useFields';
|
import { useFields } from './useFields';
|
||||||
|
|
||||||
@ -34,24 +33,7 @@ export const useCurrentSchema = (action: string, key: string, find = findSchema,
|
|||||||
};
|
};
|
||||||
|
|
||||||
const initExportSettings = (fields) => {
|
const initExportSettings = (fields) => {
|
||||||
const exportSettings = [];
|
const exportSettings = fields?.filter((f) => !f.children).map((f) => ({ dataIndex: [f.name] }));
|
||||||
const generateDataIndex = (di, preFields, fNodes: any[]) => {
|
|
||||||
let child = cloneDeep(preFields);
|
|
||||||
fNodes.reduce((buf, cur) => {
|
|
||||||
if (cur.children) {
|
|
||||||
const childDI = [];
|
|
||||||
preFields.dataIndex.push(cur.name);
|
|
||||||
generateDataIndex(childDI, cloneDeep(preFields), cur.children);
|
|
||||||
preFields.dataIndex.pop();
|
|
||||||
di.push(...childDI);
|
|
||||||
} else {
|
|
||||||
child.dataIndex.push(cur.name);
|
|
||||||
di.push(child);
|
|
||||||
child = cloneDeep(preFields);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
};
|
|
||||||
generateDataIndex(exportSettings, { dataIndex: [] }, fields);
|
|
||||||
return exportSettings;
|
return exportSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user