From 98ae8a62a192b1cad9004e2be12c5aee803aac96 Mon Sep 17 00:00:00 2001 From: chenos Date: Mon, 21 Dec 2020 14:19:31 +0800 Subject: [PATCH] fix: fields appends by view type --- packages/plugin-pages/src/actions/getView.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/plugin-pages/src/actions/getView.ts b/packages/plugin-pages/src/actions/getView.ts index 77506d1c2..68c3ee923 100644 --- a/packages/plugin-pages/src/actions/getView.ts +++ b/packages/plugin-pages/src/actions/getView.ts @@ -192,8 +192,24 @@ export default async (ctx, next) => { } else { title = `创建${title}`; } + + const viewType = view.get('type'); const actionDefaultParams:any = {}; - const appends = fields.filter(field => get(field, 'interface') === 'subTable').map(field => field.name).join(','); + const appends = fields.filter(field => { + if (field.get('interface') !== 'subTable') { + return false; + } + if (viewType === 'table') { + return !!field.get('component.showInTable'); + } + if (viewType === 'form') { + return !!field.get('component.showInForm'); + } + if (viewType === 'details') { + return !!field.get('component.showInDetail'); + } + return false; + }).map(field => field.name).join(','); actionDefaultParams['fields[appends]'] = appends; ctx.body = { ...view.get(),