Skip to content

Commit

Permalink
fix: 修复 crud 其他模式构建脚手架初始化态状态错误 (baidu#9777)
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop committed Mar 14, 2024
1 parent d924373 commit 7071b75
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions packages/amis-editor/src/plugin/CRUD.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -665,19 +665,34 @@ export class CRUDPlugin extends BasePlugin {
if (value.filter) {
__features.push('filter');
}
// 收集 列操作
const lastIndex = findLastIndex(
value.columns || [],
(item: any) => item.type === 'operation'
);
if (lastIndex !== -1) {
const operBtns: Array<string> = ['update', 'view', 'delete'];
(value.columns[lastIndex].buttons || []).forEach((btn: any) => {
if (operBtns.includes(btn.editorSetting?.behavior || '')) {
__features.push(btn.editorSetting?.behavior);
}
});

let actions = [];
if (value.mode === 'cards' && Array.isArray(value.card?.body)) {
actions = Array.isArray(value.card.actions)
? value.card.actions.concat()
: [];
} else if (
value.mode === 'list' &&
Array.isArray(value.listItem?.body)
) {
actions = Array.isArray(value.listItem.actions)
? value.listItem.actions.concat()
: [];
} else if (Array.isArray(value.columns)) {
actions =
value.columns
.find((value: any) => value?.type === 'operation')
?.buttons?.concat() || [];
}

// 收集 列操作
const operBtns: Array<string> = ['update', 'view', 'delete'];
actions.forEach((btn: any) => {
if (operBtns.includes(btn.editorSetting?.behavior || '')) {
__features.push(btn.editorSetting?.behavior);
}
});

// 收集批量操作
if (Array.isArray(value.bulkActions)) {
value.bulkActions.forEach((item: any) => {
Expand Down

0 comments on commit 7071b75

Please sign in to comment.