diff --git a/packages/form-schema/src/base.ts b/packages/form-schema/src/base.ts index e429baa2..e2326be4 100644 --- a/packages/form-schema/src/base.ts +++ b/packages/form-schema/src/base.ts @@ -720,6 +720,12 @@ export interface GroupListConfig extends FormItem { title?: string | FilterFunction; itemExtra?: string | FilterFunction; expandAll?: boolean; + /** + * 默认展开的数量,用于控制分组列表默认展示的项数 + * 当设置为数字时,表示默认展开指定数量的项 + * 当未设置时,默认展开第一项 + */ + defaultExpandQuantity?: number; addable?: (mForm: FormState | undefined, data: any) => boolean | 'undefined' | boolean; defaultAdd?: (mForm: FormState | undefined, data: any) => any; delete?: (model: any, index: number | string | symbol, values: any) => boolean | boolean; diff --git a/packages/form/src/containers/GroupListItem.vue b/packages/form/src/containers/GroupListItem.vue index 765cc1a2..e609bdcd 100644 --- a/packages/form/src/containers/GroupListItem.vue +++ b/packages/form/src/containers/GroupListItem.vue @@ -133,7 +133,9 @@ const props = defineProps<{ const emit = defineEmits(['swap-item', 'remove-item', 'change', 'addDiffCount', 'copy-item']); const mForm = inject('mForm'); -const expand = ref(props.config.expandAll || !props.index); + +const defaultExpandQuantity = props.config.defaultExpandQuantity ?? 7; +const expand = ref(props.config.expandAll || defaultExpandQuantity > props.index); const rowConfig = computed(() => ({ type: 'row',