Static 静态展示

用来在表单中,展示静态数据

基本用法

```schema: scope=”body” { “type”: “form”, “body”: [ { “name”: “static”, “type”: “static”, “label”: “静态展示”, “value”: “aaa” } ] }

  1. ## 数据域变量映射
  2. 除了显式配置`value`属性,来展示数据以外,支持通过配置`name`属性,来自动映射数据域中的相关变量
  3. ```schema: scope="body"
  4. {
  5. "type": "form",
  6. "body": [
  7. {
  8. "type": "select",
  9. "name": "select",
  10. "label": "select",
  11. "options": [
  12. {
  13. "label":"A",
  14. "value":"a"
  15. },
  16. {
  17. "label":"B",
  18. "value":"b"
  19. },
  20. {
  21. "label":"C",
  22. "value":"c"
  23. }
  24. ]
  25. },
  26. {
  27. "type": "static",
  28. "name": "select",
  29. "label": "选中的值是"
  30. }
  31. ]
  32. }

展示其他组件

支持通过配置typestatic-xxx的形式,展示其他 表单项 组件,例如:

```schema: scope=”body” { “type”: “form”, “body”: [ { “type”: “static-json”, “name”: “json”, “label”: “静态展示JSON”, “value”: { “a”: “aaa”, “b”: “bbb” } } ] }

  1. 理论上可以支持所有非表达项的所有组件,并且支持对应的配置项,下面是一些示例:
  2. ```schema: scope="body"
  3. {
  4. "type": "form",
  5. "data": {
  6. "id": 1,
  7. "image": "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg",
  8. "images": [
  9. {
  10. "image": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80",
  11. "src": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg"
  12. },
  13. {
  14. "image": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692942/d8e4992057f9.jpeg@s_0,w_216,l_1,f_jpg,q_80",
  15. "src": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692942/d8e4992057f9.jpeg"
  16. },
  17. {
  18. "image": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693148/1314a2a3d3f6.jpeg@s_0,w_216,l_1,f_jpg,q_80",
  19. "src": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693148/1314a2a3d3f6.jpeg"
  20. },
  21. {
  22. "image": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693379/8f2e79f82be0.jpeg@s_0,w_216,l_1,f_jpg,q_80",
  23. "src": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693379/8f2e79f82be0.jpeg"
  24. },
  25. {
  26. "image": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693566/552b175ef11d.jpeg@s_0,w_216,l_1,f_jpg,q_80",
  27. "src": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693566/552b175ef11d.jpeg"
  28. }
  29. ]
  30. },
  31. "api": "/api/mock2/saveForm?waitSeconds=2",
  32. "title": "表单项静态展示",
  33. "mode": "horizontal",
  34. "body": [
  35. {
  36. "type": "static",
  37. "label": "文本",
  38. "value": "文本"
  39. },
  40. {
  41. "type": "divider"
  42. },
  43. {
  44. "type": "static-tpl",
  45. "label": "模板",
  46. "tpl": "自己拼接 HTML 取变量 \\${id}: ${id}"
  47. },
  48. {
  49. "type": "divider"
  50. },
  51. {
  52. "type": "static-date",
  53. "label": "日期",
  54. "value": 1593327764
  55. },
  56. {
  57. "type": "divider"
  58. },
  59. {
  60. "type": "static-datetime",
  61. "label": "日期时间",
  62. "value": 1593327764
  63. },
  64. {
  65. "type": "divider"
  66. },
  67. {
  68. "type": "static-mapping",
  69. "label": "映射",
  70. "value": 2,
  71. "map": {
  72. "0": "<span class='label label-info'>一</span>",
  73. "1": "<span class='label label-success'>二</span>",
  74. "2": "<span class='label label-danger'>三</span>",
  75. "3": "<span class='label label-warning'>四</span>",
  76. "4": "<span class='label label-primary'>五</span>",
  77. "*": "<span class='label label-default'>-</span>"
  78. }
  79. },
  80. {
  81. "type": "divider"
  82. },
  83. {
  84. "type": "static-progress",
  85. "label": "进度",
  86. "value": 66.66
  87. },
  88. {
  89. "type": "divider"
  90. },
  91. {
  92. "type": "static-image",
  93. "label": "图片",
  94. "name": "image",
  95. "thumbMode": "cover",
  96. "thumbRatio": "4:3",
  97. "title": "233",
  98. "imageCaption": "jfe fjkda fejfkda fejk fdajf dajfe jfkda",
  99. "popOver": {
  100. "title": "查看大图",
  101. "body": "<div class=\"w-xxl\"><img class=\"w-full\" src=\"${image}\"/></div>"
  102. }
  103. },
  104. {
  105. "type": "divider"
  106. },
  107. {
  108. "type": "static-image",
  109. "label": "图片自带放大",
  110. "name": "image",
  111. "thumbMode": "cover",
  112. "thumbRatio": "4:3",
  113. "title": "233",
  114. "imageCaption": "jfe fjkda fejfkda fejk fdajf dajfe jfkda",
  115. "enlargeAble": true,
  116. "originalSrc": "${image}"
  117. },
  118. {
  119. "type": "static-images",
  120. "label": "图片集",
  121. "name": "images",
  122. "thumbMode": "cover",
  123. "thumbRatio": "4:3",
  124. "enlargeAble": true,
  125. "originalSrc": "${src}"
  126. },
  127. {
  128. "type": "divider"
  129. },
  130. {
  131. "type": "static-json",
  132. "label": "JSON",
  133. "value": {
  134. "a": 1,
  135. "b": 2,
  136. "c": {
  137. "d": 3
  138. }
  139. }
  140. },
  141. {
  142. "type": "divider"
  143. },
  144. {
  145. "type": "static",
  146. "label": "可复制",
  147. "value": "文本",
  148. "copyable": {
  149. "content": "内容,支持变量 ${id}"
  150. }
  151. },
  152. {
  153. "type": "divider"
  154. },
  155. {
  156. "type": "static",
  157. "name": "text",
  158. "label": "可快速编辑",
  159. "value": "文本",
  160. "quickEdit": true
  161. }
  162. ]
  163. }

想要调整展示组件的配置,请查阅相应组件的文档。

快速编辑

通过 quickEdit 开启快速编辑功能,比如

```schema: scope=”body” { “type”: “form”, “body”: [ { “name”: “static”, “type”: “static”, “label”: “静态展示”, “value”: “aaa”, “quickEdit”: { “type”: “number” } } ] }

  1. 其他配置项参考 [快速编辑](../crud#快速编辑)
  2. ## 弹出框(popOver)
  3. 可以通过 `popOver` 属性配置弹出框
  4. ```schema: scope="body"
  5. {
  6. "type": "form",
  7. "body": [
  8. {
  9. "name": "static",
  10. "type": "static",
  11. "label": "静态展示",
  12. "value": "aaa",
  13. "popOver": {
  14. "body": {
  15. "type": "tpl",
  16. "tpl": "弹出内容"
  17. }
  18. }
  19. }
  20. ]
  21. }