refactor: improve action default params
This commit is contained in:
parent
4d07ef5116
commit
56c9f131a1
@ -197,27 +197,35 @@ export default async (ctx, next) => {
|
|||||||
if (mode === 'update') {
|
if (mode === 'update') {
|
||||||
title = `编辑${title}`;
|
title = `编辑${title}`;
|
||||||
} else {
|
} else {
|
||||||
title = `创建${title}`;
|
title = `新增${title}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const viewType = view.get('type');
|
const viewType = view.get('type');
|
||||||
const actionDefaultParams:any = {};
|
const actionDefaultParams:any = {};
|
||||||
const appends = fields.filter(field => {
|
const appends = [];
|
||||||
|
for (const field of fields) {
|
||||||
if (!['subTable', 'linkTo', 'attachment'].includes(field.get('interface'))) {
|
if (!['subTable', 'linkTo', 'attachment'].includes(field.get('interface'))) {
|
||||||
return false;
|
continue;
|
||||||
}
|
}
|
||||||
if (viewType === 'table') {
|
let showInKey;
|
||||||
return !!field.get('component.showInTable');
|
switch (viewType) {
|
||||||
|
case 'table':
|
||||||
|
showInKey = 'showInTable';
|
||||||
|
break;
|
||||||
|
case 'form':
|
||||||
|
showInKey = 'showInForm';
|
||||||
|
break;
|
||||||
|
case 'details':
|
||||||
|
showInKey = 'showInDetail';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (viewType === 'form') {
|
if (showInKey && field.get(`component.${showInKey}`)) {
|
||||||
return !!field.get('component.showInForm');
|
appends.push(field.name);
|
||||||
|
if (field.get('interface') === 'attachment') {
|
||||||
|
appends.push(`${field.name}.storage`);
|
||||||
}
|
}
|
||||||
if (viewType === 'details') {
|
|
||||||
return !!field.get('component.showInDetail');
|
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
}).map(field => field.name).join(',');
|
actionDefaultParams['fields[appends]'] = appends.join(',');
|
||||||
actionDefaultParams['fields[appends]'] = appends;
|
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
...view.get(),
|
...view.get(),
|
||||||
title,
|
title,
|
||||||
|
Loading…
Reference in New Issue
Block a user