Steps 步骤条

步骤条组件

基本用法

  1. {
  2. "type": "page",
  3. "body": [
  4. {
  5. "type": "steps",
  6. "value": 1,
  7. "steps": [
  8. {
  9. "title": "First",
  10. "subTitle": "this is subTitle",
  11. "description": "this is description"
  12. },
  13. {
  14. "title": "Second"
  15. },
  16. {
  17. "title": "Last"
  18. }
  19. ]
  20. }
  21. ]
  22. }

设置状态

  1. {
  2. "type": "page",
  3. "body": {
  4. "type": "steps",
  5. "value": 1,
  6. "status": "error",
  7. "steps": [
  8. {
  9. "title": "First"
  10. },
  11. {
  12. "title": "Second",
  13. "subTitle": "this is subTitle",
  14. "description": "this is description"
  15. },
  16. {
  17. "title": "Last"
  18. }
  19. ]
  20. }
  21. }

指定步骤条方向

  1. {
  2. "type": "page",
  3. "body": {
  4. "type": "steps",
  5. "mode": 'vertical',
  6. "value": 1,
  7. "steps": [
  8. {
  9. "title": "First",
  10. "subTitle": "this is subTitle",
  11. "description": "this is description"
  12. },
  13. {
  14. "title": "Second",
  15. "subTitle": "this is subTitle",
  16. "description": "this is description"
  17. },
  18. {
  19. "title": "Last",
  20. "subTitle": "this is subTitle",
  21. "description": "this is description"
  22. }
  23. ]
  24. }
  25. }

指定标签放置位置

  1. {
  2. "type": "page",
  3. "body": {
  4. "type": "steps",
  5. "value": 1,
  6. "labelPlacement": "vertical",
  7. "steps": [
  8. {
  9. "title": "First",
  10. "subTitle": "this is subTitle",
  11. "description": "this is description"
  12. },
  13. {
  14. "title": "Second",
  15. "subTitle": "this is subTitle",
  16. "description": "this is description"
  17. },
  18. {
  19. "title": "Last",
  20. "subTitle": "this is subTitle",
  21. "description": "this is description"
  22. }
  23. ]
  24. }
  25. }

点状步骤条

  1. {
  2. "type": "page",
  3. "body": {
  4. "type": "steps",
  5. "value": 1,
  6. "progressDot": true,
  7. "steps": [
  8. {
  9. "title": "First",
  10. "subTitle": "this is subTitle",
  11. "description": "this is description"
  12. },
  13. {
  14. "title": "Second",
  15. "subTitle": "this is subTitle",
  16. "description": "this is description"
  17. },
  18. {
  19. "title": "Last",
  20. "subTitle": "this is subTitle",
  21. "description": "this is description"
  22. }
  23. ]
  24. }
  25. }

数据映射

当前处于第几步统一通过 name 关联变量名,其他配置可通过 "${xxx}" 关联上下文变量。

  1. {
  2. "type": "page",
  3. "data": {
  4. "step": 1,
  5. "status": "error",
  6. "secondTitle": "Second"
  7. },
  8. "body": [
  9. {
  10. "type": "steps",
  11. "name": "step",
  12. "status": "${status}",
  13. "steps": [
  14. {
  15. "title": "First",
  16. "subTitle": "this is subTitle",
  17. "description": "this is description"
  18. },
  19. {
  20. "title": "${secondTitle}"
  21. },
  22. {
  23. "title": "Last"
  24. }
  25. ]
  26. }
  27. ]
  28. }

接口映射

接口返回的数据也是一样,都会在同一个数据域,所以取值方式是一样的。

  1. {
  2. "type": "page",
  3. "initApi": "/api/mock2/steps/get",
  4. "body": [
  5. {
  6. "type": "steps",
  7. "name": "step",
  8. "status": "${status}",
  9. "steps": [
  10. {
  11. "title": "First",
  12. "subTitle": "this is subTitle",
  13. "description": "this is description"
  14. },
  15. {
  16. "title": "Secord"
  17. },
  18. {
  19. "title": "Last"
  20. }
  21. ]
  22. }
  23. ]
  24. }

Form 中静态展示

  1. {
  2. "type": "page",
  3. "body": {
  4. "type": "form",
  5. "initApi": "/api/mock2/steps/steps",
  6. "body": [
  7. {
  8. "type": "steps",
  9. "source": "${steps}",
  10. "name": "current"
  11. }
  12. ]
  13. }
  14. }

动态数据

远程拉取

除了可以通过数据映射获取当前数据域中的变量以外,source 还支持配置接口,格式为 API,用于动态返回选项组。

  1. {
  2. "type": "page",
  3. "body": {
  4. "type": "form",
  5. "body": [
  6. {
  7. "type": "steps",
  8. "name": "steps",
  9. "source": "/api/mock2/steps/steps"
  10. }
  11. ]
  12. }
  13. }

远程拉取接口时,返回的数据结构除了需要满足 amis 接口要求的基本数据结构 以外,必须用”steps”作为选项组的 key 值,如下:

  1. {
  2. "status": 0,
  3. "msg": "",
  4. "data": {
  5. "steps": [
  6. {
  7. "title": "First",
  8. "subTitle": "this is sub title",
  9. "value": "first"
  10. },
  11. {
  12. "title": "Secord",
  13. "description": "this is description",
  14. "value": "secord"
  15. },
  16. {
  17. "title": "Last",
  18. "value": "last"
  19. }
  20. ]
  21. }
  22. }

数据域变量配置

1.9.1 及以上版本

  1. {
  2. "type": "page",
  3. "data": {
  4. "steps": [
  5. {
  6. "title": "First",
  7. "subTitle": "this is subTitle",
  8. "description": "this is description"
  9. },
  10. {
  11. "title": "Second"
  12. },
  13. {
  14. "title": "Last"
  15. }
  16. ]
  17. },
  18. "body": [
  19. {
  20. "type": "steps",
  21. "name": "step",
  22. "source": "${steps}"
  23. }
  24. ]
  25. }

自定义不同步骤以及状态

  1. {
  2. "type": "page",
  3. "body": {
  4. "type": "steps",
  5. "value": "b",
  6. "status": {
  7. "a": "finish",
  8. "b": "error",
  9. "c": "wait"
  10. },
  11. "steps": [
  12. {
  13. "title": "First",
  14. "value": "a"
  15. },
  16. {
  17. "title": "Second",
  18. "subTitle": "this is subTitle",
  19. "description": "this is description",
  20. "value": "b"
  21. },
  22. {
  23. "title": "Third",
  24. "value": "c"
  25. }
  26. ]
  27. }
  28. }

属性表

属性名 类型 默认值 说明
type string "steps" 指定为 步骤条 渲染器
steps Array<step> [] 数组,配置步骤信息
source API数据映射 选项组源,可通过数据映射获取当前数据域变量、或者配置 API 对象
name string 关联上下文变量
value string \ number - 设置默认值,注意不支持表达式
status StepStatus \ {[propName: string]: stepStatus;} - 状态
className string - 自定义类名
mode horizontal \ vertical horizontal 指定步骤条方向。目前支持水平(horizontal)和竖直(vertical)两种方向
labelPlacement horizontal \ vertical horizontal 指定标签放置位置,默认水平放图标右侧,可选 (vertical) 放图标下方
progressDot boolean false 点状步骤条

step

属性名 类型 默认值 说明
title string \ SchemaNode 标题
subTitle string \ SchemaNode 子标题
description string \ SchemaNode 详细描述
icon string icon 名,支持 fontawesome v4 或使用 url
value string value
className string 自定义类名

StepStatus

wait | process | finish | error