Commit 93f9a19aa16a3e9cb95338417c52d9a398e3f70b
1 parent
61d853e6
feat(form): add `alwaysShowLines` prop
允许设置Form折叠时始终保持显示状态的行数 close: #1051
Showing
5 changed files
with
20 additions
and
3 deletions
CHANGELOG.zh_CN.md
src/components/Form/src/hooks/useAdvanced.ts
... | ... | @@ -103,7 +103,7 @@ export default function ({ |
103 | 103 | } |
104 | 104 | return { isAdvanced: advanceState.isAdvanced, itemColSum }; |
105 | 105 | } |
106 | - if (itemColSum > BASIC_COL_LEN) { | |
106 | + if (itemColSum > BASIC_COL_LEN * (unref(getProps).alwaysShowLines || 1)) { | |
107 | 107 | return { isAdvanced: advanceState.isAdvanced, itemColSum }; |
108 | 108 | } else { |
109 | 109 | // The first line is always displayed | ... | ... |
src/components/Form/src/props.ts
... | ... | @@ -59,6 +59,8 @@ export const basicProps = { |
59 | 59 | rulesMessageJoinLabel: propTypes.bool.def(true), |
60 | 60 | // 超过3行自动折叠 |
61 | 61 | autoAdvancedLine: propTypes.number.def(3), |
62 | + // 不受折叠影响的行数 | |
63 | + alwaysShowLines: propTypes.number.def(1), | |
62 | 64 | |
63 | 65 | // 是否显示操作按钮 |
64 | 66 | showActionButtonGroup: propTypes.bool.def(true), | ... | ... |
src/components/Form/src/types/form.ts
... | ... | @@ -97,6 +97,8 @@ export interface FormProps { |
97 | 97 | autoFocusFirstItem?: boolean; |
98 | 98 | // Automatically collapse over the specified number of rows |
99 | 99 | autoAdvancedLine?: number; |
100 | + // Always show lines | |
101 | + alwaysShowLines?: number; | |
100 | 102 | // Whether to show the operation button |
101 | 103 | showActionButtonGroup?: boolean; |
102 | 104 | ... | ... |
src/views/demo/form/AdvancedForm.vue
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | <BasicForm @register="register" /> |
5 | 5 | </CollapseContainer> |
6 | 6 | |
7 | - <CollapseContainer title="超过3行自动收起" class="mt-4"> | |
7 | + <CollapseContainer title="超过3行自动收起,折叠时保留2行" class="mt-4"> | |
8 | 8 | <BasicForm @register="register1" /> |
9 | 9 | </CollapseContainer> |
10 | 10 | </PageWrapper> |
... | ... | @@ -160,14 +160,26 @@ |
160 | 160 | compact: true, |
161 | 161 | showAdvancedButton: true, |
162 | 162 | }); |
163 | + const extraSchemas: FormSchema[] = []; | |
164 | + for (let i = 14; i < 30; i++) { | |
165 | + extraSchemas.push({ | |
166 | + field: 'field' + i, | |
167 | + component: 'Input', | |
168 | + label: '字段' + i, | |
169 | + colProps: { | |
170 | + span: 8, | |
171 | + }, | |
172 | + }); | |
173 | + } | |
163 | 174 | const [register1] = useForm({ |
164 | 175 | labelWidth: 120, |
165 | - schemas: [...getSchamas(), ...getAppendSchemas()], | |
176 | + schemas: [...getSchamas(), ...getAppendSchemas(), ...extraSchemas], | |
166 | 177 | actionColOptions: { |
167 | 178 | span: 24, |
168 | 179 | }, |
169 | 180 | compact: true, |
170 | 181 | showAdvancedButton: true, |
182 | + alwaysShowLines: 2, | |
171 | 183 | }); |
172 | 184 | return { |
173 | 185 | register, | ... | ... |