mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 06:15:11 +00:00
fix(plugin-export): filter non-existent fields
This commit is contained in:
parent
1a9cd78eb8
commit
12c3915a57
@ -10,10 +10,10 @@ export async function exportXlsx(ctx: Context, next: Next) {
|
||||
if (typeof columns === 'string') {
|
||||
columns = JSON.parse(columns);
|
||||
}
|
||||
const appends = columns2Appends(columns, ctx);
|
||||
columns = columns?.filter((col) => col?.dataIndex?.length > 0);
|
||||
const repository = ctx.db.getRepository<any>(resourceName, resourceOf) as Repository;
|
||||
const collection = repository.collection;
|
||||
columns = columns?.filter((col) => collection.hasField(col.dataIndex[0]) && col?.dataIndex?.length > 0);
|
||||
const appends = columns2Appends(columns, ctx);
|
||||
const data = await repository.find({
|
||||
filter,
|
||||
fields,
|
||||
|
@ -6,7 +6,7 @@ export function columns2Appends(columns, ctx) {
|
||||
const appendColumns = [];
|
||||
for (let i = 0, iLen = column.dataIndex.length; i < iLen; i++) {
|
||||
let field = collection.getField(column.dataIndex[i]);
|
||||
if (field.target) {
|
||||
if (field?.target) {
|
||||
appendColumns.push(column.dataIndex[i]);
|
||||
collection = ctx.db.getCollection(field.target);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user