FieldSet 表单项集合

FieldSet 是用于分组展示表单项的一种容器型组件,可以折叠。

基本用法

可以通过配置标题title和表单项数组body,实现多个表单项分组展示

```schema: scope=”body” { “type”: “form”, “api”: “/api/mock2/form/saveForm”, “body”: [ { “type”: “fieldSet”, “title”: “基本配置”, “body”: [ { “name”: “text1”, “type”: “input-text”, “label”: “文本1” },

  1. {
  2. "name": "text2",
  3. "type": "input-text",
  4. "label": "文本2"
  5. }
  6. ]
  7. }

] }

  1. ## 展示模式
  2. 可以通过设置`mode`调整展示模式,用法同 [Form 展示模式]($docs-zh-CN-components-form-index#%E8%A1%A8%E5%8D%95%E5%B1%95%E7%A4%BA)
  3. 下面`group`我们配置了`"mode": "horizontal"`,观察显示情况
  4. ```schema: scope="body"
  5. {
  6. "type": "form",
  7. "body": [
  8. {
  9. "type": "input-text",
  10. "name": "text",
  11. "label": "文本"
  12. },
  13. {
  14. "type": "divider"
  15. },
  16. {
  17. "type": "fieldSet",
  18. "title": "基本配置",
  19. "mode": "horizontal",
  20. "body": [
  21. {
  22. "name": "text1",
  23. "type": "input-text",
  24. "label": "文本1"
  25. },
  26. {
  27. "name": "text2",
  28. "type": "input-text",
  29. "label": "文本2"
  30. }
  31. ]
  32. }
  33. ]
  34. }

可折叠

配置"collapsable": true可以实现点击标题折叠显隐表单项。

```schema: scope=”body” { “type”: “form”, “api”: “/api/mock2/form/saveForm”, “body”: [ { “type”: “fieldSet”, “title”: “基本配置”, “collapsable”: true, “body”: [ { “name”: “text1”, “type”: “input-text”, “label”: “文本1” },

  1. {
  2. "name": "text2",
  3. "type": "input-text",
  4. "label": "文本2"
  5. }
  6. ]
  7. }

] }

  1. ### 默认是否折叠
  2. 默认是展开的,如果想默认折叠,那么配置`"collapsed": true`默认折叠。
  3. ```schema: scope="body"
  4. {
  5. "type": "form",
  6. "api": "/api/mock2/form/saveForm",
  7. "body": [
  8. {
  9. "type": "fieldSet",
  10. "title": "基本配置",
  11. "collapsable": true,
  12. "collapsed": true,
  13. "body": [
  14. {
  15. "name": "text1",
  16. "type": "input-text",
  17. "label": "文本1"
  18. },
  19. {
  20. "name": "text2",
  21. "type": "input-text",
  22. "label": "文本2"
  23. }
  24. ]
  25. }
  26. ]
  27. }

标题放底部

fieldSet 的另一种标题展现样式,不同的是展开的时候收起文本是在下方的,如果组件比较多的时候更容易收起。

设置 "titlePosition": "bottom"

```schema: scope=”body” { “type”: “form”, “api”: “/api/mock2/form/saveForm”, “body”: [ { “type”: “fieldSet”, “title”: “展开更多设置”, “collapseTitle”: “收起设置”, “titlePosition”: “bottom”, “collapsable”: true, “collapsed”: true, “body”: [ { “name”: “text1”, “type”: “input-text”, “label”: “文本1” },

  1. {
  2. "name": "text2",
  3. "type": "input-text",
  4. "label": "文本2"
  5. }
  6. ]
  7. }

] } ```

属性表

属性名 类型 默认值 说明
className string CSS 类名
headingClassName string 标题 CSS 类名
bodyClassName string 内容区域 CSS 类名
title SchemaNode 标题
body Array<表单项> 表单项集合
mode string 展示默认,同 Form 中的模式
collapsable boolean false 是否可折叠
collapsed booelan false 默认是否折叠
collapseTitle SchemaNode 收起 收起的标题