MatrixCheckboxes 矩阵

矩阵类型的输入框。

基本用法

```schema: scope=”body” { “type”: “form”, “api”: “/api/mock2/form/saveForm”, “debug”: true, “body”: [ { “type”: “matrix-checkboxes”, “name”: “matrix”, “label”: “Matrix”, “rowLabel”: “行标题说明”, “columns”: [ { “label”: “列1” }, { “label”: “列2” } ], “rows”: [ { “label”: “行1” }, { “label”: “行2” } ] } ] }

  1. ## 单选模式
  2. 配置`"multiple": false`可以设置单选,配置`singleSelectMode`可以设置单选模式
  3. ```schema: scope="body"
  4. {
  5. "type": "form",
  6. "api": "/api/mock2/form/saveForm",
  7. "debug": true,
  8. "body": [
  9. {
  10. "type": "matrix-checkboxes",
  11. "name": "matrix",
  12. "label": "Matrix",
  13. "rowLabel": "行标题说明",
  14. "multiple": false,
  15. "columns": [
  16. {
  17. "label": "列1"
  18. },
  19. {
  20. "label": "列2"
  21. }
  22. ],
  23. "rows": [
  24. {
  25. "label": "行1"
  26. },
  27. {
  28. "label": "行2"
  29. }
  30. ]
  31. }
  32. ]
  33. }

动态选项

可以配置 source 渲染动态选项

```schema: scope=”body” { “type”: “form”, “api”: “/api/mock2/form/saveForm”, “body”: [ { “name”: “matrix”, “type”: “matrix-checkboxes”, “label”: “动态矩阵组件”, “source”: “/api/mock2/options/matrix?waitSeconds=1” } ] }

  1. 以上面为例,source 接口返回格式如下:
  2. ```json
  3. {
  4. "status": 0,
  5. "msg": "ok",
  6. "data": {
  7. "columns": [
  8. {
  9. "label": "Col A",
  10. "col": "a"
  11. },
  12. {
  13. "label": "Col B",
  14. "col": "b"
  15. },
  16. {
  17. "label": "Col C",
  18. "col": "c"
  19. },
  20. {
  21. "label": "Col D",
  22. "col": "d"
  23. },
  24. {
  25. "label": "Col E",
  26. "col": "e"
  27. }
  28. ],
  29. "rows": [
  30. {
  31. "label": "Row 1",
  32. "rol": 1
  33. },
  34. {
  35. "label": "Row 2",
  36. "rol": 2
  37. },
  38. {
  39. "label": "Row 3",
  40. "rol": 3
  41. },
  42. {
  43. "label": "Row 4",
  44. "rol": 4
  45. },
  46. {
  47. "label": "Row 5",
  48. "rol": 5
  49. },
  50. {
  51. "label": "Row 6",
  52. "rol": 6
  53. }
  54. ]
  55. }
  56. }

column 模式

默认为 column 模式,即每列只能单选某个单元格

```schema: scope=”body” { “type”: “form”, “api”: “/api/mock2/form/saveForm”, “body”: [ { “type”: “matrix-checkboxes”, “name”: “matrix”, “label”: “Matrix”, “rowLabel”: “行标题说明”, “multiple”: false, “columns”: [ { “label”: “列1” }, { “label”: “列2” } ], “rows”: [ { “label”: “行1” }, { “label”: “行2” } ] } ] }

  1. ### cell 模式
  2. cell 模式,指全部选项中只能单选某个单元格
  3. ```schema: scope="body"
  4. {
  5. "type": "form",
  6. "api": "/api/mock2/form/saveForm",
  7. "body": [
  8. {
  9. "type": "matrix-checkboxes",
  10. "name": "matrix",
  11. "label": "Matrix",
  12. "rowLabel": "行标题说明",
  13. "multiple": false,
  14. "singleSelectMode": "cell",
  15. "columns": [
  16. {
  17. "label": "列1"
  18. },
  19. {
  20. "label": "列2"
  21. }
  22. ],
  23. "rows": [
  24. {
  25. "label": "行1"
  26. },
  27. {
  28. "label": "行2"
  29. }
  30. ]
  31. }
  32. ]
  33. }

row 模式

row 模式,每行只能单选某个单元格

schema: scope="body" { "type": "form", "api": "/api/mock2/form/saveForm", "body": [ { "type": "matrix-checkboxes", "name": "matrix", "label": "Matrix", "rowLabel": "行标题说明", "multiple": false, "singleSelectMode": "row", "columns": [ { "label": "列1" }, { "label": "列2" } ], "rows": [ { "label": "行1" }, { "label": "行2" } ] } ] }

属性表

除了支持 普通表单项属性表 中的配置以外,还支持下面一些配置

属性名 类型 默认值 说明
columns Array<column> 列信息,数组中 label 字段是必须给出的
rows Array<row> 行信息, 数组中 label 字段是必须给出的
rowLabel string 行标题说明
source API Api 地址,如果选项组不固定,可以通过配置 source 动态拉取。
multiple boolean true 是否多选
singleSelectMode string "column" 设置单选模式,multiplefalse时有效,可设置为cell, row, column 分别为全部选项中只能单选某个单元格、每行只能单选某个单元格,每列只能单选某个单元格

事件表

当前组件会对外派发以下事件,可以通过onEvent来监听这些事件,并通过actions来配置执行的动作,在actions中可以通过event.data.xxx事件参数变量来获取事件产生的数据,详细请查看事件动作

事件名称 事件参数 说明
change event.data.value: Array 选中值 选中值变化时触发

动作表

当前组件对外暴露以下特性动作,其他组件可以通过指定actionType: 动作名称componentId: 该组件id来触发这些动作,动作配置可以通过args: {动作配置项名称: xxx}来配置具体的参数,详细请查看事件动作

动作名称 动作配置 说明
clear - 清空
reset - 将值重置为resetValue,若没有配置resetValue,则清空
reload - 重新加载,调用 source,刷新数据域数据刷新(重新加载)
setValue value: Array 更新的值 更新数据