Skip to content

Commit

Permalink
feat(form): add alwaysShowLines prop
Browse files Browse the repository at this point in the history
允许设置Form折叠时始终保持显示状态的行数

close: #1051
  • Loading branch information
mynetfan committed Aug 13, 2021
1 parent 61d853e commit 93f9a19
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### ✨ Features

- **BasicTree** 添加搜索功能相关属性和方法
- **BasicForm** 新增`alwaysShowLines`用于设置折叠时保留显示的行数

### 🐛 Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/src/hooks/useAdvanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default function ({
}
return { isAdvanced: advanceState.isAdvanced, itemColSum };
}
if (itemColSum > BASIC_COL_LEN) {
if (itemColSum > BASIC_COL_LEN * (unref(getProps).alwaysShowLines || 1)) {
return { isAdvanced: advanceState.isAdvanced, itemColSum };
} else {
// The first line is always displayed
Expand Down
2 changes: 2 additions & 0 deletions src/components/Form/src/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export const basicProps = {
rulesMessageJoinLabel: propTypes.bool.def(true),
// 超过3行自动折叠
autoAdvancedLine: propTypes.number.def(3),
// 不受折叠影响的行数
alwaysShowLines: propTypes.number.def(1),

// 是否显示操作按钮
showActionButtonGroup: propTypes.bool.def(true),
Expand Down
2 changes: 2 additions & 0 deletions src/components/Form/src/types/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export interface FormProps {
autoFocusFirstItem?: boolean;
// Automatically collapse over the specified number of rows
autoAdvancedLine?: number;
// Always show lines
alwaysShowLines?: number;
// Whether to show the operation button
showActionButtonGroup?: boolean;

Expand Down
16 changes: 14 additions & 2 deletions src/views/demo/form/AdvancedForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<BasicForm @register="register" />
</CollapseContainer>

<CollapseContainer title="超过3行自动收起" class="mt-4">
<CollapseContainer title="超过3行自动收起,折叠时保留2行" class="mt-4">
<BasicForm @register="register1" />
</CollapseContainer>
</PageWrapper>
Expand Down Expand Up @@ -160,14 +160,26 @@
compact: true,
showAdvancedButton: true,
});
const extraSchemas: FormSchema[] = [];
for (let i = 14; i < 30; i++) {
extraSchemas.push({
field: 'field' + i,
component: 'Input',
label: '字段' + i,
colProps: {
span: 8,
},
});
}
const [register1] = useForm({
labelWidth: 120,
schemas: [...getSchamas(), ...getAppendSchemas()],
schemas: [...getSchamas(), ...getAppendSchemas(), ...extraSchemas],
actionColOptions: {
span: 24,
},
compact: true,
showAdvancedButton: true,
alwaysShowLines: 2,
});
return {
register,
Expand Down

0 comments on commit 93f9a19

Please sign in to comment.