Timeline 时间轴

时间轴组件

基本用法

  1. {
  2. "type": "page",
  3. "body": [
  4. {
  5. "type": "timeline",
  6. "items": [
  7. {
  8. "time": "2019-02-07",
  9. "title": "节点数据",
  10. "detail": "error",
  11. },
  12. {
  13. "time": "2019-02-08",
  14. "title": "节点数据",
  15. "detail": "success",
  16. },
  17. {
  18. "time": "2019-02-09",
  19. "title": "节点数据",
  20. "detail": "error",
  21. }
  22. ]
  23. }
  24. ]
  25. }

时间轴节点颜色设置

  1. {
  2. "type": "page",
  3. "body": [
  4. {
  5. "type": "timeline",
  6. "items": [
  7. {
  8. "time": "2019-02-07",
  9. "title": "节点数据",
  10. "color": "#ffb200",
  11. },
  12. {
  13. "time": "2019-02-08",
  14. "title": "节点数据",
  15. "color": "#4F86F4",
  16. },
  17. {
  18. "time": "2019-02-09",
  19. "title": "节点数据",
  20. "color": "success",
  21. },
  22. {
  23. "time": "2019-02-09",
  24. "title": "节点数据",
  25. "color": "warning",
  26. }
  27. ]
  28. }
  29. ]
  30. }

时间轴节点图标设置

  1. {
  2. "type": "page",
  3. "body": [
  4. {
  5. "type": "timeline",
  6. "items": [
  7. {
  8. "time": "2019-02-07",
  9. "title": "节点数据error",
  10. "detail": "error",
  11. "icon": "status-fail"
  12. },
  13. {
  14. "time": "2019-02-08",
  15. "title": "节点数据success",
  16. "detail": "success",
  17. "icon": "status-success"
  18. },
  19. {
  20. "time": "2019-02-09",
  21. "title": "节点数据warning",
  22. "detail": "warning",
  23. "icon": "status-warning"
  24. }
  25. ]
  26. }
  27. ]
  28. }

节点标题自定义

  1. {
  2. "type": "page",
  3. "body": [
  4. {
  5. "type": "timeline",
  6. "items": [
  7. {
  8. "time": "2019-02-07",
  9. "title": [
  10. {
  11. "type": "text",
  12. "value": "2019年02月7日"
  13. },
  14. {
  15. "type": "button",
  16. "label": "查看",
  17. "actionType": "dialog",
  18. "level": "link",
  19. "dialog": {
  20. "title": "查看详情",
  21. "body": "这是详细内容。"
  22. }
  23. },
  24. {
  25. "type": "button",
  26. "label": "删除",
  27. "level": "link",
  28. "actionType": "dialog",
  29. "dialog": {
  30. "title": "删除",
  31. "body": "确认删除吗?"
  32. }
  33. }
  34. ]
  35. },
  36. {
  37. "time": "2019-02-10",
  38. "title": [
  39. {
  40. "type": "text",
  41. "value": "2019年02月10日"
  42. },
  43. {
  44. "type": "button",
  45. "label": "查看",
  46. "actionType": "dialog",
  47. "level": "link",
  48. "dialog": {
  49. "title": "查看详情",
  50. "body": "这是详细内容。"
  51. }
  52. },
  53. {
  54. "type": "button",
  55. "label": "删除",
  56. "level": "link",
  57. "actionType": "dialog",
  58. "dialog": {
  59. "title": "删除",
  60. "body": "确认删除吗?"
  61. }
  62. }
  63. ]
  64. },
  65. ]
  66. }
  67. ]
  68. }

设置节点数据倒序

  1. {
  2. "type": "page",
  3. "body": [
  4. {
  5. "type": "timeline",
  6. direction: "vertical",
  7. reverse: true,
  8. "items": [
  9. {
  10. "time": "2019-02-07",
  11. "title": "节点数据",
  12. },
  13. {
  14. "time": "2019-02-08",
  15. "title": "节点数据",
  16. },
  17. {
  18. "time": "2019-02-09",
  19. "title": "节点数据",
  20. },
  21. {
  22. "time": "2019-02-10",
  23. "title": "节点数据",
  24. },
  25. ]
  26. }
  27. ]
  28. }

设置时间轴方向

  1. {
  2. "type": "page",
  3. "body": [
  4. {
  5. "type": "timeline",
  6. direction: "horizontal",
  7. "items": [
  8. {
  9. "time": "2019-02-07",
  10. "title": "节点数据",
  11. },
  12. {
  13. "time": "2019-02-08",
  14. "title": "节点数据",
  15. },
  16. {
  17. "time": "2019-02-09",
  18. "title": "节点数据",
  19. },
  20. {
  21. "time": "2019-02-10",
  22. "title": "节点数据",
  23. },
  24. ]
  25. }
  26. ]
  27. }

设置文字相对时间轴方向(时间轴横向时不支持)

文字位于时间轴左侧

  1. {
  2. "type": "page",
  3. "body": [
  4. {
  5. "type": "timeline",
  6. "mode": "left",
  7. "items": [
  8. {
  9. "time": "2019-02-07",
  10. "title": "节点数据",
  11. "detail": "error",
  12. },
  13. {
  14. "time": "2019-02-08",
  15. "title": "节点数据",
  16. "detail": "success",
  17. }
  18. ]
  19. },
  20. ]
  21. }

文字交替位于时间轴两侧

  1. {
  2. "type": "page",
  3. "body": [
  4. {
  5. "type": "timeline",
  6. "mode": "alternate",
  7. "items": [
  8. {
  9. "time": "2019-02-07",
  10. "title": "节点数据",
  11. "detail": "error",
  12. },
  13. {
  14. "time": "2019-02-08",
  15. "title": "节点数据",
  16. "detail": "success",
  17. }
  18. ]
  19. }
  20. ]
  21. }

文字位于时间轴右侧

  1. {
  2. "type": "page",
  3. "body": [
  4. {
  5. "type": "timeline",
  6. "mode": "right",
  7. "items": [
  8. {
  9. "time": "2019-02-07",
  10. "title": "节点数据",
  11. "detail": "error",
  12. },
  13. {
  14. "time": "2019-02-08",
  15. "title": "节点数据",
  16. "detail": "success",
  17. }
  18. ]
  19. },
  20. ]
  21. }

远程数据

  1. {
  2. "type": "page",
  3. "body": [
  4. {
  5. "type": "timeline",
  6. "source": {
  7. "method": "get",
  8. "url": "/api/mock2/timeline/timelineItems"
  9. }
  10. }
  11. ]
  12. }

“source”: “/api/mock2/timeline/timelineItems”,

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

  1. {
  2. "status": 0,
  3. "msg": "",
  4. "data": {
  5. "items": [
  6. {"time": "2019-02-07", "title": "数据开发", "detail": "2019-02-07detail", "color":"#ffb200", "icon": "close"},
  7. {"time": "2019-02-08", "title": "管理中心", "detail": "2019-02-08detail" },
  8. {"time": "2019-02-09", "title": "SQL语句", "detail": "2019-02-09detail", "color":"warning"},
  9. {"time": "2019-02-10", "title": "一键部署", "detail": "2019-02-10detail", "icon": "compress-alt"},
  10. {"time": "2019-02-10", "title": "一键部署", "detail": "2019-02-11detail"},
  11. {"time": "2019-02-10", "title": "一键部署", "detail": "2019-02-12detail", "icon": "close"},
  12. {"time": "2019-02-10", "title": "一键部署", "detail": "2019-02-13detail"}
  13. ]
  14. }
  15. }

属性表

属性名 类型 默认值 说明
type string "timeline" 指定为 时间轴 渲染器
items Array<timelineItem> [] 配置节点数据
source API 数据源,可通过数据映射获取当前数据域变量、或者配置 API 对象
mode left \ right \ alternate right 指定文字相对于时间轴的位置,仅 direction=vertical时支持
direction vertical \ horizontal vertical 时间轴方向
reverse boolean false 根据时间倒序显示

timeline.item

属性名 类型 默认值 说明
time string 节点时间
title `string \ SchemaNode` 节点标题
detail string 节点详细描述(折叠)
detailCollapsedText string 展开 详细内容折叠时按钮文案
detailExpandedText string 折叠 详细内容展开时按钮文案
color `string \ level样式(info、success、warning、danger)` #DADBDD 时间轴节点颜色
icon string icon 名,支持 fontawesome v4 或使用 url(优先级高于color)