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') {
|
if (typeof columns === 'string') {
|
||||||
columns = JSON.parse(columns);
|
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 repository = ctx.db.getRepository<any>(resourceName, resourceOf) as Repository;
|
||||||
const collection = repository.collection;
|
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({
|
const data = await repository.find({
|
||||||
filter,
|
filter,
|
||||||
fields,
|
fields,
|
||||||
|
@ -6,7 +6,7 @@ export function columns2Appends(columns, ctx) {
|
|||||||
const appendColumns = [];
|
const appendColumns = [];
|
||||||
for (let i = 0, iLen = column.dataIndex.length; i < iLen; i++) {
|
for (let i = 0, iLen = column.dataIndex.length; i < iLen; i++) {
|
||||||
let field = collection.getField(column.dataIndex[i]);
|
let field = collection.getField(column.dataIndex[i]);
|
||||||
if (field.target) {
|
if (field?.target) {
|
||||||
appendColumns.push(column.dataIndex[i]);
|
appendColumns.push(column.dataIndex[i]);
|
||||||
collection = ctx.db.getCollection(field.target);
|
collection = ctx.db.getCollection(field.target);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user