fix:表单项reset支持重置为初始值

This commit is contained in:
lvxiaojiao 2024-04-26 20:48:27 +08:00
parent 3a5be06556
commit 1e197fb99e
106 changed files with 5432 additions and 319 deletions

View File

@ -231,8 +231,8 @@ order: 36
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| setValue | `value: string` 更新的值 | 更新数据 |
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` 更新的值 | 更新数据 |

View File

@ -264,6 +264,188 @@ order: 6
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
| setValue | `value: string` 更新的值 | 更新数据 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "button-group-select",
"label": "选项",
"name": "type",
"id": "clear_type",
"options": [
{
"label": "Option A",
"value": "a"
},
{
"label": "Option B",
"value": "b"
},
{
"label": "Option C",
"value": "c"
}
],
"value": "b"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_type"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"data": {
"abc": {
"type": "c"
}
},
"body": [
{
"type": "button-group-select",
"label": "选项",
"name": "type",
"id": "reset_type",
"options": [
{
"label": "Option A",
"value": "a"
},
{
"label": "Option B",
"value": "b"
},
{
"label": "Option C",
"value": "c"
}
],
"value": "b"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_type"
}
]
}
}
}
]
}
```
### reload
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "button-group-select",
"label": "选项",
"name": "type",
"id": "reload_type",
"source": "/api/mock2/form/getOptions?waitSeconds=1"
},
{
"type": "button",
"label": "重新加载",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reload",
"componentId": "reload_type"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "button-group-select",
"label": "选项",
"name": "type",
"id": "setvalue_type",
"options": [
{
"label": "Option A",
"value": "a"
},
{
"label": "Option B",
"value": "b"
},
{
"label": "Option C",
"value": "c"
}
],
"value": "b"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_type",
"args": {
"value": "c"
}
}
]
}
}
}
]
}
```

View File

@ -102,6 +102,145 @@ order: 7
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
| setValue | `value: string` 更新的值 | 更新数据,多个值用`,`分隔 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "type",
"id": "clear_type",
"type": "chained-select",
"label": "链式下拉",
"source": "/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4",
"value": "a,b"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_type"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "type",
"id": "reset_type",
"type": "chained-select",
"label": "链式下拉",
"source": "/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4",
"value": "a,b"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_type"
}
]
}
}
}
]
}
```
### reload
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "type",
"id": "reload_type",
"type": "chained-select",
"label": "链式下拉",
"source": "/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4",
"value": "a,b"
},
{
"type": "button",
"label": "重新加载",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reload",
"componentId": "reload_type"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "type",
"id": "setvalue_type",
"type": "chained-select",
"label": "链式下拉",
"source": "/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4",
"value": "a,b"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_type",
"args": {
"value": "c"
}
}
]
}
}
}
]
}
```

View File

@ -143,8 +143,112 @@ order: 8
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------------------------- | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| setValue | `value: string \|number \|boolean` 更新的值 | 更新数据 |
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------------------------- | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string \|number \|boolean` 更新的值 | 更新数据 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "checkbox",
"label": "选项",
"name": "type",
"id": "clear_type",
"option": "选项说明",
"value": true
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_type"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "checkbox",
"label": "选项",
"name": "type",
"id": "reset_type",
"option": "选项说明",
"value": true
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_type"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "checkbox",
"label": "选项",
"name": "type",
"id": "setvalue_type",
"option": "选项说明",
"value": true
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_type",
"args": {
"value": false
}
}
]
}
}
}
]
}
```

View File

@ -682,6 +682,183 @@ order: 9
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
| setValue | `value: string` 更新的值 | 更新数据,多个值用`,`分隔 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "checkboxes",
"label": "选项",
"name": "type",
"id": "clear_type",
"options": [
{
"label": "Option A",
"value": "a"
},
{
"label": "Option B",
"value": "b"
},
{
"label": "Option C",
"value": "c"
}
],
"value": "b"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_type"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "checkboxes",
"label": "选项",
"name": "type",
"id": "reset_type",
"options": [
{
"label": "Option A",
"value": "a"
},
{
"label": "Option B",
"value": "b"
},
{
"label": "Option C",
"value": "c"
}
],
"value": "b"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_type"
}
]
}
}
}
]
}
```
### reload
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "checkboxes",
"label": "选项",
"name": "type",
"id": "reload_type",
"source": "/api/mock2/form/getOptions?waitSeconds=1"
},
{
"type": "button",
"label": "重新加载",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reload",
"componentId": "reload_type"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "checkboxes",
"label": "选项",
"name": "type",
"id": "setvalue_type",
"options": [
{
"label": "Option A",
"value": "a"
},
{
"label": "Option B",
"value": "b"
},
{
"label": "Option C",
"value": "c"
}
],
"value": "b"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_type",
"args": {
"value": "c"
}
}
]
}
}
}
]
}
```

View File

@ -1134,9 +1134,113 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
| -------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| addItem | `item: object` 新增项的值 | 只有开启`multiple`模式才能使用, `multiple`模式下,给新增项添加默认值 |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: object \| Array<object>` 更新的值<br/>`index?: number` 指定更新的数据索引, 1.10.1 及以上版本引入 | 更新数据,对象数组针对开启`multiple`模式, `multiple`模式下可以通过指定`index`来更新指定索引的数据 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "combo",
"name": "type",
"id": "clear_type",
"label": "用户",
"items": [
{
"name": "text",
"label": "名字",
"type": "input-text"
},
{
"name": "gender",
"label": "性别",
"type": "select",
"options": [
"男",
"女"
]
}
],
"value": {
"text": "amis",
"gender": "男"
}
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_type"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "combo",
"name": "type",
"id": "reset_type",
"label": "用户",
"items": [
{
"name": "text",
"label": "名字",
"type": "input-text"
},
{
"name": "gender",
"label": "性别",
"type": "select",
"options": [
"男",
"女"
]
}
],
"value": {
"text": "amis",
"gender": "男"
}
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_type"
}
]
}
}
}
]
}
```
### setValue
#### 复制数值
@ -1145,12 +1249,12 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
此示例主要用来演示如何通过已有数据快速填充 combo 某条数据。点击 copy 按钮会弹出一个 crud 列表,点击对应行上的复制按钮,将选中数据填充到外层的 combo.
注意事项:
1. 需要给 combo 设置个 id 属性,用来给事件动作指定目标用。
2. 弹窗按钮配置了数据映射 `{comboIndex: "${index}"}` 因为 crud 的行数据上也有 index 变量,派送动作时获取 index 变量是 crud 所在行的序号。所以弹出弹窗的时候,先把 combo 的序号赋值给 comboIndex
3. crud 操作栏里面添加了个按钮close: true 设置是让动作完成后关闭弹窗。
4. 按钮里面添加了 onEvent 配置click 时做 `setValue` 动作,并设置参数 index 为 '${comboIndex}' 值为 `${&}`。其中 `${&}` 是特殊语法,用来取整个上下数据。
> 注意事项:
>
> 1. 需要给 combo 设置个 id 属性,用来给事件动作指定目标用。
> 2. 弹窗按钮配置了数据映射 `{comboIndex: "${index}"}` 因为 crud 的行数据上也有 index 变量,派送动作时获取 index 变量是 crud 所在行的序号。所以弹出弹窗的时候,先把 combo 的序号赋值给 comboIndex
> 3. crud 操作栏里面添加了个按钮close: true 设置是让动作完成后关闭弹窗。
> 4. 按钮里面添加了 onEvent 配置click 时做 `setValue` 动作,并设置参数 index 为 '${comboIndex}' 值为 `${&}`。其中 `${&}` 是特殊语法,用来取整个上下数据。
```schema: scope="body"
{

View File

@ -100,9 +100,146 @@ order: 17
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------------------- | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| focus | - | 获取焦点,焦点落在右侧编辑面板 |
| setValue | `value: string` 更新的右侧编辑面板中的值 | 更新数据 |
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------------------- | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| focus | - | 获取焦点,焦点落在右侧编辑面板 |
| setValue | `value: string` 更新的右侧编辑面板中的值 | 更新数据 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "diff-editor",
"name": "diff",
"id": "clear_text",
"label": "Diff-Editor",
"diffValue": "hello world",
"value": "hello"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"id": "reset_text",
"type": "diff-editor",
"name": "diff",
"label": "Diff-Editor",
"diffValue": "hello world",
"value": "hello"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### focus
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"id": "focus_text",
"type": "diff-editor",
"name": "diff",
"label": "Diff-Editor",
"diffValue": "hello world",
"value": "hello"
},
{
"type": "button",
"label": "聚焦",
"onEvent": {
"click": {
"actions": [
{
"actionType": "focus",
"componentId": "focus_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"id": "setvalue_text",
"type": "diff-editor",
"name": "diff",
"label": "Diff-Editor",
"diffValue": "hello world",
"value": "hello"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "amis go go go!"
}
}
]
}
}
}
]
}
```

View File

@ -181,9 +181,142 @@ amis 的编辑器是基于 monaco 开发的,如果想进行深度定制,比
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| focus | - | 获取焦点 |
| setValue | `value: string` 更新的值 | 更新数据 |
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| focus | - | 获取焦点 |
| setValue | `value: string` 更新的值 | 更新数据 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "editor",
"name": "editor",
"label": "编辑器",
"id": "clear_text",
"value": "hello"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "editor",
"id": "reset_text",
"name": "editor",
"label": "编辑器",
"value": "hello"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### focus
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "editor",
"id": "focus_text",
"name": "editor",
"label": "编辑器",
"value": "hello"
},
{
"type": "button",
"label": "聚焦",
"onEvent": {
"click": {
"actions": [
{
"actionType": "focus",
"componentId": "focus_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "editor",
"id": "setvalue_text",
"name": "editor",
"label": "编辑器",
"value": "hello"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "amis go go go!"
}
}
]
}
}
}
]
}
```

View File

@ -145,8 +145,109 @@ order: 10
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------------- | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| setValue | `value: string \| number` 更新的值 | 更新数据 |
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------------- | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string \| number` 更新的值 | 更新数据 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "city",
"type": "input-city",
"label": "城市",
"id": "clear_text",
"value": "110000"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "city",
"type": "input-city",
"label": "城市",
"id": "reset_text",
"value": "110000"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "city",
"type": "input-city",
"label": "城市",
"id": "setvalue_text",
"value": "110000"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "110100"
}
}
]
}
}
}
]
}
```

View File

@ -372,5 +372,106 @@ function transform(value, config, props, data) {
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------------------------- | ----------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,,依赖格式`format`,例如:'1650556800,1652889599' |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-date-range",
"name": "date",
"label": "日期",
"id": "clear_text",
"value": "1714060800,1714319999"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-date-range",
"name": "date",
"label": "日期",
"id": "reset_text",
"value": "1714060800,1714319999"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-date-range",
"name": "date",
"label": "日期",
"id": "setvalue_text",
"value": "1714060800,1714319999"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "1714060800,1714492799"
}
}
]
}
}
}
]
}
```

View File

@ -444,8 +444,109 @@ order: 13
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------- | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1650556800' |
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------- | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1650556800' |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-date",
"name": "date",
"label": "日期",
"id": "clear_text",
"value": "1714060800"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-date",
"name": "date",
"label": "日期",
"id": "reset_text",
"value": "1714060800"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-date",
"name": "date",
"label": "日期",
"id": "setvalue_text",
"value": "1714060800"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "1714233600"
}
}
]
}
}
}
]
}
```

View File

@ -159,5 +159,5 @@ order: 16
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------------------------- | -------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1650556800,1652889599' |

View File

@ -444,8 +444,8 @@ order: 14
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------- | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1650556800' |
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------- | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1650556800' |

View File

@ -275,17 +275,16 @@ interface InputExcelData {
}
```
## 属性表
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
| ------------ | ----------------------- | ------------------------------- | ------------------ | ------- |
| allSheets | `boolean` | false | 是否解析所有 sheet |
| parseMode | `'array'``'object'` | 'object' | 解析模式 |
| includeEmpty | `boolean` | true | 是否包含空值 |
| plainText | `boolean` | true | 是否解析为纯文本 |
| placeholder | `string` | `"拖拽 Excel 到这,或点击上传"` | 占位文本提示 | `2.8.1` |
| autoFill | `Record<string, string>` | | 自动填充 | `3.5.0` |
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
| ------------ | ------------------------ | ------------------------------- | ------------------ | ------- |
| allSheets | `boolean` | false | 是否解析所有 sheet |
| parseMode | `'array'``'object'` | 'object' | 解析模式 |
| includeEmpty | `boolean` | true | 是否包含空值 |
| plainText | `boolean` | true | 是否解析为纯文本 |
| placeholder | `string` | `"拖拽 Excel 到这,或点击上传"` | 占位文本提示 | `2.8.1` |
| autoFill | `Record<string, string>` | | 自动填充 | `3.5.0` |
## 事件表
@ -301,8 +300,117 @@ interface InputExcelData {
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------------------------- | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| setValue | `value: Array<object>` 更新的 excel 解析后数据 | 更新数据 |
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------------------------- | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: Array<object>` 更新的 excel 解析后数据 | 更新数据 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-excel",
"name": "excel",
"label": "上传 Excel",
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-excel",
"name": "excel",
"label": "上传 Excel",
"id": "reset_text",
"value": [
{
"ID": "1",
"NAME": "amis"
}
]
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-excel",
"name": "excel",
"label": "上传 Excel",
"id": "setvalue_text"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": [
{
"ID": "1",
"NAME": "amis"
}
]
}
}
]
}
}
}
]
}
```

View File

@ -185,7 +185,7 @@ order: 21
## 作为表单项上传
如果不希望 InputFile 组件在提交Form之前上传可以配置 `asBlob` 或者 `asBase64`,采用这种方式后,组件不再自己上传了,而是直接把文件数据作为表单项的值,文件内容会在 Form 表单提交的接口里面一起带上。
如果不希望 InputFile 组件在提交 Form 之前上传,可以配置 `asBlob` 或者 `asBase64`,采用这种方式后,组件不再自己上传了,而是直接把文件数据作为表单项的值,文件内容会在 Form 表单提交的接口里面一起带上。
```schema: scope="body"
{
@ -435,7 +435,6 @@ order: 21
}
```
## 属性表
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
@ -502,3 +501,36 @@ order: 21
| 动作名称 | 动作配置 | 说明 |
| -------- | -------- | ---- |
| clear | - | 清空 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-file",
"name": "file",
"label": "File",
"accept": "*",
"receiver": "/api/upload/file",
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```

View File

@ -733,3 +733,35 @@ app.listen(8080, function () {});
| 动作名称 | 动作配置 | 说明 |
| -------- | -------- | ---- |
| clear | - | 清空 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-image",
"name": "image",
"label": "Image",
"receiver": "/api/upload/file",
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```

View File

@ -222,8 +222,8 @@ key 只能是字符串,因此输入格式是 `input-text`,但 value 格式
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| setValue | `value: object` 更新的值 | 更新数据 |
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: object` 更新的值 | 更新数据 |

View File

@ -102,5 +102,5 @@ order: 15
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------------------------- | -------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1646064000,1651334399' |

View File

@ -171,8 +171,8 @@ order: 81
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------- | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`valueFormat`,例如:'1646064000' |
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------- | --------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`valueFormat`,例如:'1646064000' |

View File

@ -314,3 +314,104 @@ order: 32
| clear | - | 清空 |
| reset | - | 将值重置为 `resetValue`,若没有配置 `resetValue`,则清空 |
| setValue | `value: number` 更新的数值 | 更新数据 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-number",
"name": "number",
"label": "数字",
"id": "clear_text",
"value": 1
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-number",
"name": "number",
"label": "数字",
"id": "reset_text",
"value": 1
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-number",
"name": "number",
"label": "数字",
"id": "setvalue_text",
"value": 1
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": 2
}
}
]
}
}
}
]
}
```

View File

@ -101,5 +101,5 @@ order: 15
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------------------------- | -------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1640966400,1664553600' |

View File

@ -42,8 +42,8 @@ order: 62
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------- | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1640966400' |
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------- | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1640966400' |

View File

@ -232,7 +232,7 @@ order: 38
## 显示单位
在打开`showInput`输入框且设置了`unit`单位的前提下,开启`showInputUnit`可在input框中显示已配置的单位。
在打开`showInput`输入框且设置了`unit`单位的前提下,开启`showInputUnit`可在 input 框中显示已配置的单位。
```schema: scope="body"
{
@ -311,18 +311,18 @@ order: 38
| showSteps | `boolean` | `false` | 是否显示步长 |
| parts | `number` or `number[]` | `1` | 分割的块数<br/>主持数组传入分块的节点 |
| marks | <code>{ [number &#124; string]: string &#124; number &#124; SchemaObject }</code> or <code>{ [number &#124; string]: { style: CSSProperties, label: string } }</code> | | 刻度标记<br/>- 支持自定义样式<br/>- 设置百分比 |
| tooltipVisible | `boolean` | `false` | 是否显示滑块标签 |
| tooltipPlacement | `auto` or `bottom` or `left` or `right` | `top` | 滑块标签的位置,默认`auto`,方向自适应<br/>前置条件tooltipVisible 不为 false 时有效 |
| tipFormatter | `function` | | 控制滑块标签显隐函数<br/>前置条件tooltipVisible 不为 false 时有效 |
| multiple | `boolean` | `false` | 支持选择范围 |
| joinValues | `boolean` | `true` | 默认为 `true`,选择的 `value` 会通过 `delimiter` 连接起来,否则直接将以`{min: 1, max: 100}`的形式提交<br/>前置条件:开启`multiple`时有效 |
| delimiter | `string` | `,` | 分隔符 |
| unit | `string` | | 单位 |
| clearable | `boolean` | `false` | 是否可清除<br/>前置条件:开启`showInput`时有效 |
| showInput | `boolean` | `false` | 是否显示输入框 |
| showInputUnit | `boolean` | `false` | 是否显示输入框单位<br/>前置条件:开启`showInput`且配置了`unit`单位时有效 |`6.0.0`后支持变量
| onChange | `function` | | 当 组件 的值发生改变时,会触发 onChange 事件,并把改变后的值作为参数传入 |
| onAfterChange | `function` | | 与 `onmouseup` 触发时机一致,把当前值作为参数传入 |
| tooltipVisible | `boolean` | `false` | 是否显示滑块标签 |
| tooltipPlacement | `auto` or `bottom` or `left` or `right` | `top` | 滑块标签的位置,默认`auto`,方向自适应<br/>前置条件tooltipVisible 不为 false 时有效 |
| tipFormatter | `function` | | 控制滑块标签显隐函数<br/>前置条件tooltipVisible 不为 false 时有效 |
| multiple | `boolean` | `false` | 支持选择范围 |
| joinValues | `boolean` | `true` | 默认为 `true`,选择的 `value` 会通过 `delimiter` 连接起来,否则直接将以`{min: 1, max: 100}`的形式提交<br/>前置条件:开启`multiple`时有效 |
| delimiter | `string` | `,` | 分隔符 |
| unit | `string` | | 单位 |
| clearable | `boolean` | `false` | 是否可清除<br/>前置条件:开启`showInput`时有效 |
| showInput | `boolean` | `false` | 是否显示输入框 |
| showInputUnit | `boolean` | `false` | 是否显示输入框单位<br/>前置条件:开启`showInput`且配置了`unit`单位时有效 | `6.0.0`后支持变量 |
| onChange | `function` | | 当 组件 的值发生改变时,会触发 onChange 事件,并把改变后的值作为参数传入 |
| onAfterChange | `function` | | 与 `onmouseup` 触发时机一致,把当前值作为参数传入 |
## 事件表
@ -433,8 +433,109 @@ order: 38
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------------------------------------------- | ---------------------------------------------------------- |
| clear | - | 清除输入框<br />前置条件showInput 和 clearable 都为 true |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| setValue | `value: number \| string \| {min: number, max: number}` 更新的值 | 更新数据 |
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------------------------------------------- | ------------------------------------------------ |
| clear | - | 清除输入框 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: number \| string \| {min: number, max: number}` 更新的值 | 更新数据 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-range",
"label": "滑块",
"name": "range",
"value": 20,
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-range",
"label": "滑块",
"name": "range",
"value": 20,
"id": "reset_text"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-range",
"label": "滑块",
"name": "range",
"value": 20,
"id": "setvalue_text"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": 30
}
}
]
}
}
}
]
}
```

View File

@ -174,8 +174,115 @@ order: 37
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| setValue | `value: number` 更新的值 | 更新数据 |
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: number` 更新的值 | 更新数据 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-rating",
"name": "rating",
"label": "评分",
"count": 5,
"value": 3.5,
"half": true,
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-rating",
"name": "rating",
"label": "评分",
"count": 5,
"value": 3.5,
"half": true,
"id": "reset_text"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-rating",
"name": "rating",
"label": "评分",
"count": 5,
"value": 3.5,
"half": true,
"id": "setvalue_text"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": 4
}
}
]
}
}
}
]
}
```

View File

@ -2549,7 +2549,7 @@ order: 54
"label": "表格表单",
"id": "reset-input-table",
"name": "table",
"resetValue": [
"value": [
{
"a": "a-resetValue1",
"b": "b-resetValue1"

View File

@ -256,6 +256,164 @@ order: 55
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
| setValue | `value: string` 更新的值 | 更新数据,多个值用`,`分隔 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-tag",
"name": "tag",
"label": "标签",
"placeholder": "请选择标签",
"options": [
"Aaron Rodgers",
"Tom Brady",
"Charlse Woodson",
"Aaron Jones"
],
"value": "Charlse Woodson",
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-tag",
"name": "tag",
"label": "标签",
"placeholder": "请选择标签",
"options": [
"Aaron Rodgers",
"Tom Brady",
"Charlse Woodson",
"Aaron Jones"
],
"value": "Charlse Woodson",
"id": "reset_text"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### reload
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-tag",
"name": "tag",
"label": "标签",
"placeholder": "请选择标签",
"id": "reload_type",
"source": "/api/mock2/form/getOptions?waitSeconds=1",
"value": "a"
},
{
"type": "button",
"label": "重新加载",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reload",
"componentId": "reload_type"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-tag",
"name": "tag",
"label": "标签",
"placeholder": "请选择标签",
"options": [
"Aaron Rodgers",
"Tom Brady",
"Charlse Woodson",
"Aaron Jones"
],
"value": "Charlse Woodson",
"id": "setvalue_text"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "Tom Brady"
}
}
]
}
}
}
]
}
```

View File

@ -626,3 +626,173 @@ order: 56
| focus | - | 获取焦点 |
| reload | - | 刷新(重新加载),只针对配置了`source`的输入框有效 |
| setValue | `value: string` 更新的值 | 更新数据,开启`multiple`多选时用`,`分隔 |
### clear
如果配置了`clearValueOnEmpty: true`,则清空时将置为`undefined`,否则置为空字符串。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "text",
"id": "clear_text",
"type": "input-text",
"label": "text",
"value": "清空我"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "text",
"id": "reset_text",
"type": "input-text",
"label": "text",
"value": "重置我"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### focus
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "text",
"id": "focus_text",
"type": "input-text",
"label": "text",
"value": "聚焦我"
},
{
"type": "button",
"label": "聚焦",
"onEvent": {
"click": {
"actions": [
{
"actionType": "focus",
"componentId": "focus_text"
}
]
}
}
}
]
}
```
### reload
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "text",
"id": "reload_text",
"type": "input-text",
"label": "text",
"value": "a",
"source": "/api/mock2/form/getOptions?waitSeconds=1"
},
{
"type": "button",
"label": "重新加载",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reload",
"componentId": "reload_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "text",
"id": "setvalue_text",
"type": "input-text",
"label": "text",
"value": "amis"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "amis go go go!"
}
}
]
}
}
}
]
}
```

View File

@ -118,5 +118,5 @@ order: 15
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------------------------- | -------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1617206400,1743436800' |

View File

@ -276,8 +276,8 @@ order: 58
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------- | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1648746120' |
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------- | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1648746120' |

View File

@ -1453,5 +1453,139 @@ true false false [{label: 'A/B/C', value: 'a/b/c'},{label: 'A
| delete | value: ` any` | 删除数据项的 value如果配置了 valueField以 valueField 的字段值为准) |
| reload | - | 刷新 |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-tree",
"name": "tree",
"label": "Tree",
"options": [
{
"label": "Folder A",
"value": 1,
"children": [
{
"label": "file A",
"value": 2
},
{
"label": "Folder B",
"value": 3,
"children": [
{
"label": "file b1",
"value": 3.1
},
{
"label": "file b2",
"value": 3.2
}
]
}
]
},
{
"label": "file C",
"value": 4
},
{
"label": "file D",
"value": 5
}
],
"value": 5,
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "input-tree",
"name": "tree",
"label": "Tree",
"options": [
{
"label": "Folder A",
"value": 1,
"children": [
{
"label": "file A",
"value": 2
},
{
"label": "Folder B",
"value": 3,
"children": [
{
"label": "file b1",
"value": 3.1
},
{
"label": "file b2",
"value": 3.2
}
]
}
]
},
{
"label": "file C",
"value": 4
},
{
"label": "file D",
"value": 5
}
],
"value": 5,
"id": "reset_text"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```

View File

@ -101,5 +101,5 @@ order: 15
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------------------------- | -------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1648746120,1648760760' |

View File

@ -42,8 +42,8 @@ order: 61
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------- | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1617206400' |
| 动作名称 | 动作配置 | 说明 |
| -------- | ---------------------------- | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1617206400' |

View File

@ -147,6 +147,176 @@ ListSelect 一般用来实现选择,可以单选也可以多选,和 Radio/Ch
| 动作名称 | 动作配置 | 说明 |
| -------- | -------------------------------------- | --------------------------------------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
| setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "list-select",
"name": "select",
"label": "单选",
"clearable": true,
"options": [
{
"label": "Option A",
"value": "a"
},
{
"label": "Option B",
"value": "b"
}
],
"value": "a",
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "list-select",
"name": "select",
"label": "单选",
"clearable": true,
"options": [
{
"label": "Option A",
"value": "a"
},
{
"label": "Option B",
"value": "b"
}
],
"value": "a",
"id": "reset_text"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### reload
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "list-select",
"name": "select",
"label": "单选",
"clearable": true,
"id": "reload_type",
"source": "/api/mock2/form/getOptions?waitSeconds=1",
"value": "a"
},
{
"type": "button",
"label": "重新加载",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reload",
"componentId": "reload_type"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "list-select",
"name": "select",
"label": "单选",
"clearable": true,
"options": [
{
"label": "Option A",
"value": "a"
},
{
"label": "Option B",
"value": "b"
}
],
"value": "a",
"id": "setvalue_text"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "b"
}
}
]
}
}
}
]
}
```

View File

@ -123,8 +123,129 @@ order: 30
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | -------- | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| setValue | `value` | 参考 [`LocationData`](#LocationData) |
| 动作名称 | 动作配置 | 说明 |
| -------- | -------- | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value` | 参考 [`LocationData`](#LocationData) |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "location-picker",
"name": "location",
"ak": "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7",
"label": "地址",
"value": {
"address":"北京市西城区府右街131号",
"lat":39.916383659908185,
"lng":116.38854914523102,
"city":"北京市",
"vendor":"baidu"
},
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "location-picker",
"name": "location",
"ak": "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7",
"label": "地址",
"value": {
"address":"北京市西城区府右街131号",
"lat":39.916383659908185,
"lng":116.38854914523102,
"city":"北京市",
"vendor":"baidu"
},
"id": "reset_text"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "location-picker",
"name": "location",
"ak": "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7",
"label": "地址",
"id": "setvalue_text"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": {
"address":"北京市西城区府右街131号",
"lat":39.916383659908185,
"lng":116.38854914523102,
"city":"北京市",
"vendor":"baidu"
}
}
}
]
}
}
}
]
}
```

View File

@ -383,6 +383,257 @@ row 模式,每行只能单选某个单元格
| 动作名称 | 动作配置 | 说明 |
| -------- | ----------------------- | ------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
| setValue | `value: Array` 更新的值 | 更新数据 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "matrix-checkboxes",
"name": "matrix",
"label": "Matrix",
"rowLabel": "行标题说明",
"columns": [
{
"label": "列1"
},
{
"label": "列2"
}
],
"rows": [
{
"label": "行1"
},
{
"label": "行2"
}
],
"value": [
[
{
"label": "列1",
"checked": true
},
{
"label": "列1",
"checked": false
}
],
[
{
"label": "列2",
"checked": false
},
{
"label": "列2",
"checked": true
}
]
],
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "matrix-checkboxes",
"name": "matrix",
"label": "Matrix",
"rowLabel": "行标题说明",
"columns": [
{
"label": "列1"
},
{
"label": "列2"
}
],
"rows": [
{
"label": "行1"
},
{
"label": "行2"
}
],
"value": [
[
{
"label": "列1",
"checked": true
},
{
"label": "列1",
"checked": false
}
],
[
{
"label": "列2",
"checked": false
},
{
"label": "列2",
"checked": true
}
]
],
"id": "reset_text"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### reload
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "list-select",
"name": "select",
"label": "单选",
"clearable": true,
"id": "reload_type",
"source": "/api/mock2/form/getOptions?waitSeconds=1",
"value": "a"
},
{
"type": "button",
"label": "重新加载",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reload",
"componentId": "reload_type"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "matrix-checkboxes",
"name": "matrix",
"label": "Matrix",
"rowLabel": "行标题说明",
"columns": [
{
"label": "列1"
},
{
"label": "列2"
}
],
"rows": [
{
"label": "行1"
},
{
"label": "行2"
}
],
"value": "a",
"id": "setvalue_text"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": [
[
{
"label": "列1",
"checked": true
},
{
"label": "列1",
"checked": true
}
],
[
{
"label": "列2",
"checked": false
},
{
"label": "列2",
"checked": true
}
]
]
}
}
]
}
}
}
]
}
```

View File

@ -844,6 +844,226 @@ order: 31
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
| setValue | `value: string` 更新的值 | 更新数据,开启`multiple`时,多个值用`,`分隔 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "nested-select",
"name": "nestedSelect",
"label": "级联选择器",
"options": [
{
"label": "A",
"value": "a"
},
{
"label": "B",
"value": "b",
"children": [
{
"label": "B-1",
"value": "b-1"
},
{
"label": "B-2",
"value": "b-2"
},
{
"label": "B-3",
"value": "b-3"
}
]
},
{
"label": "C",
"value": "c"
}
],
"value": "a",
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "nested-select",
"name": "nestedSelect",
"label": "级联选择器",
"options": [
{
"label": "A",
"value": "a"
},
{
"label": "B",
"value": "b",
"children": [
{
"label": "B-1",
"value": "b-1"
},
{
"label": "B-2",
"value": "b-2"
},
{
"label": "B-3",
"value": "b-3"
}
]
},
{
"label": "C",
"value": "c"
}
],
"value": "a",
"id": "reset_text"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### reload
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "nested-select",
"name": "nestedSelect",
"label": "级联选择器",
"id": "reload_type",
"source": "/api/mock2/form/getTreeOptions",
"value": "a"
},
{
"type": "button",
"label": "重新加载",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reload",
"componentId": "reload_type"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "nested-select",
"name": "nestedSelect",
"label": "级联选择器",
"options": [
{
"label": "A",
"value": "a"
},
{
"label": "B",
"value": "b",
"children": [
{
"label": "B-1",
"value": "b-1"
},
{
"label": "B-2",
"value": "b-2"
},
{
"label": "B-3",
"value": "b-3"
}
]
},
{
"label": "C",
"value": "c"
}
],
"value": "a",
"id": "setvalue_text"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "b"
}
}
]
}
}
}
]
}
```

View File

@ -210,8 +210,112 @@ order: 8
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------------------------- | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| setValue | `value: string \|number \|boolean` 更新的值 | 更新数据 |
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------------------------- | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string \|number \|boolean` 更新的值 | 更新数据 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "radio",
"label": "选项",
"name": "type",
"id": "clear_type",
"option": "选项说明",
"value": true
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_type"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "radio",
"label": "选项",
"name": "type",
"id": "reset_type",
"option": "选项说明",
"value": false
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_type"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "radio",
"label": "选项",
"name": "type",
"id": "setvalue_type",
"option": "选项说明",
"value": true
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_type",
"args": {
"value": false
}
}
]
}
}
}
]
}
```

View File

@ -313,6 +313,196 @@ api 返回内容需要包含 options 字段
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
| setValue | `value: string` 更新的值 | 更新数据 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "radios",
"type": "radios",
"label": "radios",
"options": [
{
"label": "OptionA",
"value": "a"
},
{
"label": "OptionB",
"value": "b"
},
{
"label": "OptionC",
"value": "c"
},
{
"label": "OptionD",
"value": "d"
}
],
"value": "a",
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "radios",
"type": "radios",
"label": "radios",
"options": [
{
"label": "OptionA",
"value": "a"
},
{
"label": "OptionB",
"value": "b"
},
{
"label": "OptionC",
"value": "c"
},
{
"label": "OptionD",
"value": "d"
}
],
"value": "a",
"id": "reset_text"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### reload
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "radios",
"type": "radios",
"label": "radios",
"id": "reload_type",
"source": "/api/mock2/form/getOptions",
"value": "a"
},
{
"type": "button",
"label": "重新加载",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reload",
"componentId": "reload_type"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "radios",
"type": "radios",
"label": "radios",
"options": [
{
"label": "OptionA",
"value": "a"
},
{
"label": "OptionB",
"value": "b"
},
{
"label": "OptionC",
"value": "c"
},
{
"label": "OptionD",
"value": "d"
}
],
"value": "a",
"id": "setvalue_text"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "b"
}
}
]
}
}
}
]
}
```

View File

@ -1566,10 +1566,112 @@ leftOptions 动态加载,默认 source 接口是返回 options 部分,而 le
| 动作名称 | 动作配置 | 说明 |
| -------- | -------------------------------------- | --------------------------------------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
| setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "select",
"type": "select",
"label": "select",
"options": [
{
"label": "OptionA",
"value": "a"
},
{
"label": "OptionB",
"value": "b"
},
{
"label": "OptionC",
"value": "c"
},
{
"label": "OptionD",
"value": "d"
}
],
"value": "a",
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "select",
"type": "select",
"label": "select",
"options": [
{
"label": "OptionA",
"value": "a"
},
{
"label": "OptionB",
"value": "b"
},
{
"label": "OptionC",
"value": "c"
},
{
"label": "OptionD",
"value": "d"
}
],
"value": "a",
"id": "reset_text"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### 刷新数据源 reload
```schema: scope="body"
@ -1635,3 +1737,56 @@ leftOptions 动态加载,默认 source 接口是返回 options 部分,而 le
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "select",
"type": "select",
"label": "select",
"options": [
{
"label": "OptionA",
"value": "a"
},
{
"label": "OptionB",
"value": "b"
},
{
"label": "OptionC",
"value": "c"
},
{
"label": "OptionD",
"value": "d"
}
],
"value": "a",
"id": "setvalue_text"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "b"
}
}
]
}
}
}
]
}
```

View File

@ -102,7 +102,7 @@ order: 51
}
```
### 使用Schema配置文本
### 使用 Schema 配置文本
> `3.6.0` 版本之后支持
@ -142,7 +142,6 @@ order: 51
}
```
## 默认值
和其它表单项一样,如果要设置默认值,可以使用 value 属性
@ -294,15 +293,15 @@ order: 51
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
| ---------- | --------------------------- | ------- | -------------------- | --- |
| option | `string` | | 选项说明 |
| onText | `string \| IconSchema \| SchemaCollection` | | 开启时开关显示的内容 | `3.6.0`支持Schema |
| offText | `string \| IconSchema \| SchemaCollection` | | 关闭时开关显示的内容 | `3.6.0`支持Schema |
| trueValue | `boolean \| string \| number` | `true` | 标识真值 |
| falseValue | `boolean \| string \| number` | `false` | 标识假值 |
| size | `"sm" \| "md"` | `"md"` | 开关大小 |
| loading | `boolean` | `false` | 是否处于加载状态 | `3.6.0` |
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
| ---------- | ------------------------------------------ | ------- | -------------------- | ------------------ |
| option | `string` | | 选项说明 |
| onText | `string \| IconSchema \| SchemaCollection` | | 开启时开关显示的内容 | `3.6.0`支持 Schema |
| offText | `string \| IconSchema \| SchemaCollection` | | 关闭时开关显示的内容 | `3.6.0`支持 Schema |
| trueValue | `boolean \| string \| number` | `true` | 标识真值 |
| falseValue | `boolean \| string \| number` | `false` | 标识假值 |
| size | `"sm" \| "md"` | `"md"` | 开关大小 |
| loading | `boolean` | `false` | 是否处于加载状态 | `3.6.0` |
IconSchema 配置
| 属性名 | 类型 | 默认值 | 说明 |
@ -420,9 +419,76 @@ switch 值更新时弹出确认提示,确认后发送请求。
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------------------- | -------- |
| setValue | `value: string \| boolean` 更新的数据 | 更新数据 |
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------------------- | ---------------------------------------------------------------------- | --- |
| clear | - | 清空6.3.1 及以上版本支持 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue`6.3.1 及以上版本支持 | |
| setValue | `value: string \| boolean` 更新的数据 | 更新数据 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "switch",
"label": "开关",
"type": "switch",
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "switch",
"label": "开关",
"type": "switch",
"id": "reset_text",
"value": true
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### setValue

View File

@ -169,5 +169,391 @@ icon:
| 动作名称 | 动作配置 | 说明 |
| -------- | -------------------------------------- | --------------------------------------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"label": "穿梭选择器",
"type": "tabs-transfer-picker",
"name": "a",
"sortable": true,
"selectMode": "tree",
"options": [
{
"label": "成员",
"selectMode": "tree",
"searchable": true,
"children": [
{
"label": "法师",
"children": [
{
"label": "诸葛亮",
"value": "zhugeliang"
}
]
},
{
"label": "战士",
"children": [
{
"label": "曹操",
"value": "caocao"
},
{
"label": "钟无艳",
"value": "zhongwuyan"
}
]
},
{
"label": "打野",
"children": [
{
"label": "李白",
"value": "libai"
},
{
"label": "韩信",
"value": "hanxin"
},
{
"label": "云中君",
"value": "yunzhongjun"
}
]
}
]
},
{
"label": "用户",
"selectMode": "chained",
"children": [
{
"label": "法师",
"children": [
{
"label": "诸葛亮",
"value": "zhugeliang2"
}
]
},
{
"label": "战士",
"children": [
{
"label": "曹操",
"value": "caocao2"
},
{
"label": "钟无艳",
"value": "zhongwuyan2"
}
]
},
{
"label": "打野",
"children": [
{
"label": "李白",
"value": "libai2"
},
{
"label": "韩信",
"value": "hanxin2"
},
{
"label": "云中君",
"value": "yunzhongjun2"
}
]
}
]
}
],
"value": "zhugeliang",
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"label": "穿梭选择器",
"type": "tabs-transfer-picker",
"name": "a",
"sortable": true,
"selectMode": "tree",
"options": [
{
"label": "成员",
"selectMode": "tree",
"searchable": true,
"children": [
{
"label": "法师",
"children": [
{
"label": "诸葛亮",
"value": "zhugeliang"
}
]
},
{
"label": "战士",
"children": [
{
"label": "曹操",
"value": "caocao"
},
{
"label": "钟无艳",
"value": "zhongwuyan"
}
]
},
{
"label": "打野",
"children": [
{
"label": "李白",
"value": "libai"
},
{
"label": "韩信",
"value": "hanxin"
},
{
"label": "云中君",
"value": "yunzhongjun"
}
]
}
]
},
{
"label": "用户",
"selectMode": "chained",
"children": [
{
"label": "法师",
"children": [
{
"label": "诸葛亮",
"value": "zhugeliang2"
}
]
},
{
"label": "战士",
"children": [
{
"label": "曹操",
"value": "caocao2"
},
{
"label": "钟无艳",
"value": "zhongwuyan2"
}
]
},
{
"label": "打野",
"children": [
{
"label": "李白",
"value": "libai2"
},
{
"label": "韩信",
"value": "hanxin2"
},
{
"label": "云中君",
"value": "yunzhongjun2"
}
]
}
]
}
],
"value": "zhugeliang",
"id": "reset_text"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"label": "穿梭选择器",
"type": "tabs-transfer-picker",
"name": "a",
"sortable": true,
"selectMode": "tree",
"options": [
{
"label": "成员",
"selectMode": "tree",
"searchable": true,
"children": [
{
"label": "法师",
"children": [
{
"label": "诸葛亮",
"value": "zhugeliang"
}
]
},
{
"label": "战士",
"children": [
{
"label": "曹操",
"value": "caocao"
},
{
"label": "钟无艳",
"value": "zhongwuyan"
}
]
},
{
"label": "打野",
"children": [
{
"label": "李白",
"value": "libai"
},
{
"label": "韩信",
"value": "hanxin"
},
{
"label": "云中君",
"value": "yunzhongjun"
}
]
}
]
},
{
"label": "用户",
"selectMode": "chained",
"children": [
{
"label": "法师",
"children": [
{
"label": "诸葛亮",
"value": "zhugeliang2"
}
]
},
{
"label": "战士",
"children": [
{
"label": "曹操",
"value": "caocao2"
},
{
"label": "钟无艳",
"value": "zhongwuyan2"
}
]
},
{
"label": "打野",
"children": [
{
"label": "李白",
"value": "libai2"
},
{
"label": "韩信",
"value": "hanxin2"
},
{
"label": "云中君",
"value": "yunzhongjun2"
}
]
}
]
}
],
"value": "zhugeliang",
"id": "setvalue_text"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "yunzhongjun2"
}
}
]
}
}
}
]
}
```

View File

@ -631,7 +631,393 @@ icon:
| 动作名称 | 动作配置 | 说明 |
| ------------ | -------------------------------------- | --------------------------------------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| selectAll | - | 全选 |
| changeTabKey | `activeKey: number` 选中的 Tab | 修改当前选中 tab来选择其他选项 |
| setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"label": "组合穿梭器",
"type": "tabs-transfer",
"name": "a",
"sortable": true,
"selectMode": "tree",
"options": [
{
"label": "成员",
"selectMode": "tree",
"searchable": true,
"children": [
{
"label": "法师",
"children": [
{
"label": "诸葛亮",
"value": "zhugeliang"
}
]
},
{
"label": "战士",
"children": [
{
"label": "曹操",
"value": "caocao"
},
{
"label": "钟无艳",
"value": "zhongwuyan"
}
]
},
{
"label": "打野",
"children": [
{
"label": "李白",
"value": "libai"
},
{
"label": "韩信",
"value": "hanxin"
},
{
"label": "云中君",
"value": "yunzhongjun"
}
]
}
]
},
{
"label": "用户",
"selectMode": "chained",
"children": [
{
"label": "法师",
"children": [
{
"label": "诸葛亮",
"value": "zhugeliang2"
}
]
},
{
"label": "战士",
"children": [
{
"label": "曹操",
"value": "caocao2"
},
{
"label": "钟无艳",
"value": "zhongwuyan2"
}
]
},
{
"label": "打野",
"children": [
{
"label": "李白",
"value": "libai2"
},
{
"label": "韩信",
"value": "hanxin2"
},
{
"label": "云中君",
"value": "yunzhongjun2"
}
]
}
]
}
],
"value": "zhugeliang",
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"label": "组合穿梭器",
"type": "tabs-transfer",
"name": "a",
"sortable": true,
"selectMode": "tree",
"options": [
{
"label": "成员",
"selectMode": "tree",
"searchable": true,
"children": [
{
"label": "法师",
"children": [
{
"label": "诸葛亮",
"value": "zhugeliang"
}
]
},
{
"label": "战士",
"children": [
{
"label": "曹操",
"value": "caocao"
},
{
"label": "钟无艳",
"value": "zhongwuyan"
}
]
},
{
"label": "打野",
"children": [
{
"label": "李白",
"value": "libai"
},
{
"label": "韩信",
"value": "hanxin"
},
{
"label": "云中君",
"value": "yunzhongjun"
}
]
}
]
},
{
"label": "用户",
"selectMode": "chained",
"children": [
{
"label": "法师",
"children": [
{
"label": "诸葛亮",
"value": "zhugeliang2"
}
]
},
{
"label": "战士",
"children": [
{
"label": "曹操",
"value": "caocao2"
},
{
"label": "钟无艳",
"value": "zhongwuyan2"
}
]
},
{
"label": "打野",
"children": [
{
"label": "李白",
"value": "libai2"
},
{
"label": "韩信",
"value": "hanxin2"
},
{
"label": "云中君",
"value": "yunzhongjun2"
}
]
}
]
}
],
"value": "zhugeliang",
"id": "reset_text"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"label": "组合穿梭器",
"type": "tabs-transfer",
"name": "a",
"sortable": true,
"selectMode": "tree",
"options": [
{
"label": "成员",
"selectMode": "tree",
"searchable": true,
"children": [
{
"label": "法师",
"children": [
{
"label": "诸葛亮",
"value": "zhugeliang"
}
]
},
{
"label": "战士",
"children": [
{
"label": "曹操",
"value": "caocao"
},
{
"label": "钟无艳",
"value": "zhongwuyan"
}
]
},
{
"label": "打野",
"children": [
{
"label": "李白",
"value": "libai"
},
{
"label": "韩信",
"value": "hanxin"
},
{
"label": "云中君",
"value": "yunzhongjun"
}
]
}
]
},
{
"label": "用户",
"selectMode": "chained",
"children": [
{
"label": "法师",
"children": [
{
"label": "诸葛亮",
"value": "zhugeliang2"
}
]
},
{
"label": "战士",
"children": [
{
"label": "曹操",
"value": "caocao2"
},
{
"label": "钟无艳",
"value": "zhongwuyan2"
}
]
},
{
"label": "打野",
"children": [
{
"label": "李白",
"value": "libai2"
},
{
"label": "韩信",
"value": "hanxin2"
},
{
"label": "云中君",
"value": "yunzhongjun2"
}
]
}
]
}
],
"value": "zhugeliang",
"id": "setvalue_text"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "yunzhongjun2"
}
}
]
}
}
}
]
}
```

View File

@ -121,9 +121,142 @@ order: 57
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| focus | - | 获取焦点 |
| setValue | `value: string` 更新的值 | 更新数据 |
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| focus | - | 获取焦点 |
| setValue | `value: string` 更新的值 | 更新数据 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "text",
"id": "clear_text",
"type": "textarea",
"label": "text",
"value": "清空我"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "text",
"id": "reset_text",
"type": "textarea",
"label": "text",
"value": "重置我"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### focus
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "text",
"id": "focus_text",
"type": "textarea",
"label": "text",
"value": "聚焦我"
},
{
"type": "button",
"label": "聚焦",
"onEvent": {
"click": {
"actions": [
{
"actionType": "focus",
"componentId": "focus_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"name": "text",
"id": "setvalue_text",
"type": "textarea",
"label": "text",
"value": "amis"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "amis go go go!"
}
}
]
}
}
}
]
}
```

View File

@ -117,12 +117,13 @@ icon:
```
## 属性表
下面属性为`transfer-picker`独占属性, 更多属性用法,参考[穿梭器Transfer](./transfer)
| 属性名 | 类型 | 默认值 | 说明
| ----------------- | --------- | ------- | -------------------------------------------------
| borderMode | `'full'` \| `'half'` \| `'none'` | | 边框模式,`'full'`为全边框,`'half'`为半边框,`'none'`为没边框 |
| pickerSize | string | | 弹窗大小,支持: xs、sm、md、lg、xl、full |
| 属性名 | 类型 | 默认值 | 说明 |
| ---------- | -------------------------------- | ------ | -------------------------------------------------------------- |
| borderMode | `'full'` \| `'half'` \| `'none'` | | 边框模式,`'full'`为全边框,`'half'`为半边框,`'none'`为没边框 |
| pickerSize | string | | 弹窗大小,支持: xs、sm、md、lg、xl、full |
## 事件表
@ -143,5 +144,187 @@ icon:
| 动作名称 | 动作配置 | 说明 |
| -------- | -------------------------------------- | --------------------------------------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"label": "默认",
"type": "transfer-picker",
"name": "transfer",
"value": "zhugeliang,libai",
"options": [
{
"label": "诸葛亮",
"value": "zhugeliang"
},
{
"label": "曹操",
"value": "caocao"
},
{
"label": "钟无艳",
"value": "zhongwuyan"
},
{
"label": "李白",
"value": "libai"
},
{
"label": "韩信",
"value": "hanxin"
},
{
"label": "云中君",
"value": "yunzhongjun"
}
],
"value": "zhugeliang",
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"label": "默认",
"type": "transfer-picker",
"name": "transfer",
"value": "zhugeliang,libai",
"options": [
{
"label": "诸葛亮",
"value": "zhugeliang"
},
{
"label": "曹操",
"value": "caocao"
},
{
"label": "钟无艳",
"value": "zhongwuyan"
},
{
"label": "李白",
"value": "libai"
},
{
"label": "韩信",
"value": "hanxin"
},
{
"label": "云中君",
"value": "yunzhongjun"
}
],
"value": "zhugeliang",
"id": "reset_text"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"label": "默认",
"type": "transfer-picker",
"name": "transfer",
"value": "zhugeliang,libai",
"options": [
{
"label": "诸葛亮",
"value": "zhugeliang"
},
{
"label": "曹操",
"value": "caocao"
},
{
"label": "钟无艳",
"value": "zhongwuyan"
},
{
"label": "李白",
"value": "libai"
},
{
"label": "韩信",
"value": "hanxin"
},
{
"label": "云中君",
"value": "yunzhongjun"
}
],
"value": "zhugeliang",
"id": "setvalue_text"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "yunzhongjun"
}
}
]
}
}
}
]
}
```

View File

@ -1101,7 +1101,189 @@ icon:
| 动作名称 | 动作配置 | 说明 |
| ----------- | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| clearSearch | `left: boolean` 左侧搜索、`right:boolean`右侧搜索 | 默认清除所有搜索态,可以单独配置`left`、`right`为`true`来清空对应左侧或者右侧面板(`3.4.0`及以上版本支持) |
| selectAll | - | 全选 |
| setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"label": "默认",
"type": "transfer",
"name": "transfer",
"value": "zhugeliang,libai",
"options": [
{
"label": "诸葛亮",
"value": "zhugeliang"
},
{
"label": "曹操",
"value": "caocao"
},
{
"label": "钟无艳",
"value": "zhongwuyan"
},
{
"label": "李白",
"value": "libai"
},
{
"label": "韩信",
"value": "hanxin"
},
{
"label": "云中君",
"value": "yunzhongjun"
}
],
"value": "zhugeliang",
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"label": "默认",
"type": "transfer",
"name": "transfer",
"value": "zhugeliang,libai",
"options": [
{
"label": "诸葛亮",
"value": "zhugeliang"
},
{
"label": "曹操",
"value": "caocao"
},
{
"label": "钟无艳",
"value": "zhongwuyan"
},
{
"label": "李白",
"value": "libai"
},
{
"label": "韩信",
"value": "hanxin"
},
{
"label": "云中君",
"value": "yunzhongjun"
}
],
"value": "zhugeliang",
"id": "reset_text"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```
### setValue
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"label": "默认",
"type": "transfer",
"name": "transfer",
"value": "zhugeliang,libai",
"options": [
{
"label": "诸葛亮",
"value": "zhugeliang"
},
{
"label": "曹操",
"value": "caocao"
},
{
"label": "钟无艳",
"value": "zhongwuyan"
},
{
"label": "李白",
"value": "libai"
},
{
"label": "韩信",
"value": "hanxin"
},
{
"label": "云中君",
"value": "yunzhongjun"
}
],
"value": "zhugeliang",
"id": "setvalue_text"
},
{
"type": "button",
"label": "赋值",
"onEvent": {
"click": {
"actions": [
{
"actionType": "setValue",
"componentId": "setvalue_text",
"args": {
"value": "yunzhongjun"
}
}
]
}
}
}
]
}
```

View File

@ -823,5 +823,139 @@ order: 60
| delete | value: ` any` | 删除数据项的 value如果配置了 valueField以 valueField 的字段值为准) |
| reload | - | 刷新 |
| clear | - | 清空 |
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 |
### clear
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "tree-select",
"name": "tree",
"label": "Tree",
"options": [
{
"label": "Folder A",
"value": 1,
"children": [
{
"label": "file A",
"value": 2
},
{
"label": "Folder B",
"value": 3,
"children": [
{
"label": "file b1",
"value": 3.1
},
{
"label": "file b2",
"value": 3.2
}
]
}
]
},
{
"label": "file C",
"value": 4
},
{
"label": "file D",
"value": 5
}
],
"value": 5,
"id": "clear_text"
},
{
"type": "button",
"label": "清空",
"onEvent": {
"click": {
"actions": [
{
"actionType": "clear",
"componentId": "clear_text"
}
]
}
}
}
]
}
```
### reset
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
```schema: scope="body"
{
"type": "form",
"debug": true,
"body": [
{
"type": "tree-select",
"name": "tree",
"label": "Tree",
"options": [
{
"label": "Folder A",
"value": 1,
"children": [
{
"label": "file A",
"value": 2
},
{
"label": "Folder B",
"value": 3,
"children": [
{
"label": "file b1",
"value": 3.1
},
{
"label": "file b2",
"value": 3.2
}
]
}
]
},
{
"label": "file C",
"value": 4
},
{
"label": "file D",
"value": 5
}
],
"value": 5,
"id": "reset_text"
},
{
"type": "button",
"label": "重置",
"onEvent": {
"click": {
"actions": [
{
"actionType": "reset",
"componentId": "reset_text"
}
]
}
}
}
]
}
```

View File

@ -632,9 +632,7 @@ extendLocale('en-US', {
'528609917710d813a55e5a6cecf1e458': 'Selected value',
'288f0c404c4e546aa3683ff5054e85e2': 'Clear',
'c374a44713fa5ff5da2565beb398c7d3': 'Delete selected value',
'8db57ba01ffb9bf29c1656de5f0208f5':
'Reset the value to resetValue. If the resetValue is not configured, the value is cleared.',
'8f40db3b25528063f1b6a59602a05cd5': 'Value assignment',
'8db57ba01ffb9bf29c1656de5f0208f5': 'Reset the value to the initial value.',
'944908c981a86bfa0cfab9360ab38184':
'Allow the button to occupy the parent container fully. The width of individual buttons is adaptive.',
'ac3880323853de9adc4f66bc06d438ff': 'Button style',

View File

@ -636,8 +636,7 @@ extendLocale('zh-CN', {
'528609917710d813a55e5a6cecf1e458': '选中值',
'288f0c404c4e546aa3683ff5054e85e2': '清空',
'c374a44713fa5ff5da2565beb398c7d3': '清除选中值',
'8db57ba01ffb9bf29c1656de5f0208f5':
'将值重置为resetValue若没有配置resetValue则清空',
'8db57ba01ffb9bf29c1656de5f0208f5': '将值重置为初始值',
'8f40db3b25528063f1b6a59602a05cd5': '赋值',
'944908c981a86bfa0cfab9360ab38184': '使按钮宽度占满父容器,各按钮宽度自适应',
'0b98b0bea3db6ae5b67a09c7bb2d032b': '按钮选中样式',

View File

@ -131,7 +131,7 @@ export class CalendarPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'setValue',

View File

@ -100,7 +100,7 @@ export class ButtonGroupControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'reload',

View File

@ -88,7 +88,7 @@ export class ChainedSelectControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'reload',

View File

@ -108,7 +108,7 @@ export class CheckboxControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'setValue',

View File

@ -113,7 +113,7 @@ export class CheckboxesControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'reload',

View File

@ -120,7 +120,7 @@ export class CodeEditorControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'focus',

View File

@ -254,7 +254,7 @@ export class ComboControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'addItem',

View File

@ -127,7 +127,7 @@ export class DiffEditorControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'focus',

View File

@ -253,7 +253,7 @@ export class DateControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'setValue',

View File

@ -299,7 +299,7 @@ export class DateRangeControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'setValue',

View File

@ -85,7 +85,7 @@ export class ExcelControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'setValue',

View File

@ -118,7 +118,7 @@ export class KVControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'setValue',

View File

@ -160,7 +160,7 @@ export class RangeControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'setValue',

View File

@ -85,7 +85,7 @@ export class RateControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'setValue',

View File

@ -1094,7 +1094,7 @@ export class TableControlPlugin extends BasePlugin {
// {
// actionType: 'reset',
// actionLabel: '重置',
// description: '将值重置为resetValue若没有配置resetValue则清空'
// description: '将值重置为初始值'
// },
{
actionType: 'clear',

View File

@ -190,7 +190,7 @@ export class TextControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'reload',

View File

@ -107,7 +107,7 @@ export class ListControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'reload',

View File

@ -95,7 +95,7 @@ export class LocationControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'setValue',

View File

@ -201,7 +201,7 @@ export class NestedSelectControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'reload',

View File

@ -103,7 +103,7 @@ export class RadiosControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'reload',

View File

@ -176,7 +176,7 @@ export class SelectControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'reload',

View File

@ -94,6 +94,16 @@ export class SwitchControlPlugin extends BasePlugin {
// 动作定义
actions: RendererPluginAction[] = [
{
actionType: 'clear',
actionLabel: '清空',
description: '清除选中值'
},
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为初始值'
},
{
actionType: 'setValue',
actionLabel: '赋值',

View File

@ -119,7 +119,7 @@ export class TextareaControlPlugin extends BasePlugin {
{
actionType: 'reset',
actionLabel: '重置',
description: '将值重置为resetValue若没有配置resetValue则清空'
description: '将值重置为初始值'
},
{
actionType: 'setValue',

View File

@ -1446,9 +1446,8 @@ export class DateRangePicker extends React.Component<
}
// 重置
reset() {
reset(resetValue?: any) {
const {
resetValue,
onChange,
format,
valueFormat,
@ -1458,17 +1457,16 @@ export class DateRangePicker extends React.Component<
displayFormat,
data
} = this.props;
if (!resetValue) {
return;
}
const tmpResetValue = resetValue ?? this.props.resetValue;
const {startDate, endDate} = DateRangePicker.unFormatValue(
resetValue,
tmpResetValue,
valueFormat || (format as string),
joinValues,
delimiter,
data
);
onChange(resetValue);
onChange?.(tmpResetValue);
this.setState({
startInputValue: startDate?.format(displayFormat || inputFormat),
endInputValue: endDate?.format(displayFormat || inputFormat)

View File

@ -15,7 +15,6 @@ test('EventAction:locationPicker', async () => {
id: 'location-picker',
ak: 'LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7',
coordinatesType: 'bd09',
value: '',
name: 'location',
resetValue: {
address: '北京市东城区天安门广场中央',

View File

@ -1,5 +1,11 @@
import React = require('react');
import {render, cleanup, fireEvent, waitFor, screen} from '@testing-library/react';
import {
render,
cleanup,
fireEvent,
waitFor,
screen
} from '@testing-library/react';
import '../../../src';
import {render as amisRender} from '../../../src';
import {makeEnv, replaceReactAriaIds, wait} from '../../helper';
@ -354,36 +360,40 @@ describe('Renderer:text with options and multiple', () => {
test('Renderer:text with options auto ellipsis', async () => {
const longText = 'OptionB (with long suffix for testing ellipsis)';
const {container} = await setup({
"name": "text",
"type": "input-text",
"label": "text",
"multiple": true,
"options": [
name: 'text',
type: 'input-text',
label: 'text',
multiple: true,
options: [
{
"label": "OptionA",
"value": "a"
label: 'OptionA',
value: 'a'
},
{
"label": longText,
"value": "b"
label: longText,
value: 'b'
},
{
"label": "OptionC",
"value": "c"
label: 'OptionC',
value: 'c'
},
{
"label": "OptionD",
"value": "d"
label: 'OptionD',
value: 'd'
}
]
});
const textControl = container.querySelector('.cxd-TextControl-input') as HTMLElement;
const textControl = container.querySelector(
'.cxd-TextControl-input'
) as HTMLElement;
fireEvent.click(textControl);
await wait(300);
replaceReactAriaIds(container);
const listItems = container.querySelectorAll('.cxd-TextControl-sugs .cxd-TextControl-sugItem');
const listItems = container.querySelectorAll(
'.cxd-TextControl-sugs .cxd-TextControl-sugItem'
);
expect(listItems.length).toBe(4);
// 选中长文本项
@ -503,7 +513,7 @@ test('Renderer:text with resetValue and trimContents', async () => {
await wait(500);
expect(input.value).toBe('reset-value');
expect(input.value).toBe('text-value');
// trimContents
const textControl = container.querySelector(

View File

@ -2,7 +2,9 @@ import React from 'react';
import {
OptionsControl,
OptionsControlProps,
FormOptionsControl
FormOptionsControl,
filter,
getVariable
} from 'amis-core';
import {Option, TestIdBuilder} from 'amis-core';
import {ActionObject, isObject} from 'amis-core';
@ -49,13 +51,15 @@ export default class ButtonGroupControl extends React.Component<
};
doAction(action: ActionObject, data: object, throwErrors: boolean) {
const {resetValue, onChange} = this.props;
const {resetValue, onChange, formStore, store, name} = this.props;
const actionType = action?.actionType as string;
if (actionType === 'clear') {
onChange('');
} else if (actionType === 'reset') {
onChange(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange(pristineVal ?? '');
}
}

View File

@ -5,7 +5,8 @@ import {
OptionsControlProps,
Option,
FormOptionsControl,
resolveEventData
resolveEventData,
getVariable
} from 'amis-core';
import {Select, Spinner} from 'amis-ui';
import {Api, ApiObject} from 'amis-core';
@ -89,13 +90,15 @@ export default class ChainedSelectControl extends React.Component<
}
doAction(action: ActionObject, data: object, throwErrors: boolean) {
const {resetValue, onChange} = this.props;
const {resetValue, onChange, formStore, store, name} = this.props;
const actionType = action?.actionType as string;
if (actionType === 'clear') {
onChange('');
} else if (actionType === 'reset') {
onChange(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange(pristineVal ?? '');
}
}

View File

@ -3,7 +3,8 @@ import {
FormItem,
FormControlProps,
FormBaseControl,
resolveEventData
resolveEventData,
getVariable
} from 'amis-core';
import cx from 'classnames';
import {Checkbox} from 'amis-ui';
@ -70,13 +71,15 @@ export default class CheckboxControl extends React.Component<
};
doAction(action: ActionObject, data: object, throwErrors: boolean) {
const {resetValue, onChange} = this.props;
const {resetValue, onChange, formStore, store, name} = this.props;
const actionType = action?.actionType as string;
if (actionType === 'clear') {
onChange('');
} else if (actionType === 'reset') {
onChange(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange(pristineVal ?? '');
}
}

View File

@ -6,7 +6,8 @@ import {
autobind,
hasAbility,
columnsSplit,
flattenTreeWithLeafNodes
flattenTreeWithLeafNodes,
getVariable
} from 'amis-core';
import type {ActionObject, Api, OptionsControlProps, Option} from 'amis-core';
import {Checkbox, Icon, Spinner} from 'amis-ui';
@ -86,13 +87,15 @@ export default class CheckboxesControl extends React.Component<
};
doAction(action: ActionObject, data: object, throwErrors: boolean) {
const {resetValue, onChange} = this.props;
const {resetValue, onChange, formStore, store, name} = this.props;
const actionType = action?.actionType as string;
if (actionType === 'clear') {
onChange('');
} else if (actionType === 'reset') {
onChange(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange(pristineVal ?? '');
}
}

View File

@ -516,14 +516,19 @@ export default class ComboControl extends React.Component<ComboProps> {
args?: any
) {
const actionType = action?.actionType as string;
const {onChange, resetValue} = this.props;
const {onChange, resetValue, formStore, store, name} = this.props;
if (actionType === 'addItem') {
this.addItemValue(args?.item ?? {});
} else if (actionType === 'clear') {
onChange('');
} else if (actionType === 'reset') {
onChange(resetValue ?? '');
const pristineVal =
getVariable(
formStore?.pristine ?? store?.parentStore?.pristine,
name
) ?? resetValue;
onChange(pristineVal ?? '');
}
}

View File

@ -3,7 +3,8 @@ import {
FormItem,
FormControlProps,
FormBaseControl,
resolveEventData
resolveEventData,
getVariable
} from 'amis-core';
import {LazyComponent} from 'amis-core';
import {isPureVariable, resolveVariableAndFilter} from 'amis-core';
@ -119,12 +120,14 @@ export class DiffEditor extends React.Component<DiffEditorProps, any> {
args?: any
) {
const actionType = action?.actionType as string;
const {onChange, resetValue} = this.props;
const {onChange, resetValue, formStore, store, name} = this.props;
if (actionType === 'clear') {
onChange('');
} else if (actionType === 'reset') {
onChange(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange(pristineVal ?? '');
} else if (actionType === 'focus') {
this.focus();
}

View File

@ -3,7 +3,8 @@ import {
FormItem,
FormControlProps,
FormBaseControl,
resolveEventData
resolveEventData,
getVariable
} from 'amis-core';
import {LazyComponent} from 'amis-core';
import {Editor} from 'amis-ui';
@ -167,12 +168,14 @@ export default class EditorControl extends React.Component<EditorProps, any> {
args?: any
) {
const actionType = action?.actionType as string;
const {onChange, resetValue} = this.props;
const {onChange, resetValue, formStore, store, name} = this.props;
if (actionType === 'clear') {
onChange('');
} else if (actionType === 'reset') {
onChange(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange(pristineVal ?? '');
} else if (actionType === 'focus') {
this.focus();
}

View File

@ -3,7 +3,8 @@ import {
FormItem,
FormControlProps,
FormBaseControl,
resolveEventData
resolveEventData,
getVariable
} from 'amis-core';
import {ClassNamesFn, themeable, ThemeProps} from 'amis-core';
import {Spinner, SpinnerExtraProps} from 'amis-ui';
@ -515,13 +516,15 @@ export class LocationControl extends React.Component<LocationControlProps> {
@autobind
doAction(action: ActionObject, data: object, throwErrors: boolean) {
const {resetValue, onChange} = this.props;
const {resetValue, onChange, formStore, store, name} = this.props;
const actionType = action?.actionType as string;
if (actionType === 'clear') {
onChange('');
} else if (actionType === 'reset') {
onChange(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange(pristineVal ?? '');
}
}

View File

@ -5,7 +5,8 @@ import {
FormBaseControl,
resolveEventData,
str2function,
normalizeDate
normalizeDate,
getVariable
} from 'amis-core';
import cx from 'classnames';
import {filterDate, isPureVariable, resolveVariableAndFilter} from 'amis-core';
@ -558,15 +559,17 @@ export default class DateControl extends React.PureComponent<
// 动作
doAction(action: ActionObject, data: object, throwErrors: boolean) {
const {resetValue} = this.props;
const {resetValue, formStore, store, name} = this.props;
if (action.actionType === 'clear') {
this.dateRef?.clear();
return;
}
if (action.actionType === 'reset' && resetValue) {
this.dateRef?.reset(resetValue);
if (action.actionType === 'reset') {
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
this.dateRef?.reset(pristineVal);
}
}

View File

@ -3,7 +3,8 @@ import {
FormItem,
FormControlProps,
FormBaseControl,
resolveEventData
resolveEventData,
getVariable
} from 'amis-core';
import cx from 'classnames';
import {filterDate, parseDuration} from 'amis-core';
@ -240,15 +241,17 @@ export default class DateRangeControl extends React.Component<DateRangeProps> {
// 动作
doAction(action: ActionObject, data: object, throwErrors: boolean) {
const {resetValue} = this.props;
const {resetValue, formStore, store, name} = this.props;
if (action.actionType === 'clear') {
this.dateRef?.clear();
return;
}
if (action.actionType === 'reset' && resetValue) {
this.dateRef?.reset();
if (action.actionType === 'reset') {
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
this.dateRef?.reset(pristineVal);
}
}

View File

@ -11,7 +11,8 @@ import {
isObject,
resolveEventData,
dataMapping,
TestIdBuilder
TestIdBuilder,
getVariable
} from 'amis-core';
import {FormBaseControlSchema, SchemaTokenizeableString} from '../../Schema';
import type {CellValue, CellRichTextValue} from 'exceljs';
@ -388,12 +389,14 @@ export default class ExcelControl extends React.PureComponent<
doAction(action: any, data: object, throwErrors: boolean) {
const actionType = action?.actionType as string;
const {onChange, resetValue} = this.props;
const {onChange, resetValue, formStore, store, name} = this.props;
if (actionType === 'clear') {
onChange('');
} else if (actionType === 'reset') {
onChange(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange(pristineVal ?? '');
}
}

View File

@ -8,7 +8,8 @@ import {
CustomStyle,
formatInputThemeCss,
setThemeClassName,
TestIdBuilder
TestIdBuilder,
getVariable
} from 'amis-core';
import cx from 'classnames';
import {NumberInput, Select} from 'amis-ui';
@ -238,7 +239,10 @@ export default class NumberControl extends React.Component<
resetValue,
big,
onChange,
clearValueOnEmpty
clearValueOnEmpty,
formStore,
store,
name
} = this.props;
if (actionType === 'clear') {
@ -248,12 +252,14 @@ export default class NumberControl extends React.Component<
this.filterNum(precision),
this.filterNum(step)
);
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
const value = NumberInput.normalizeValue(
resetValue ?? '',
pristineVal ?? '',
this.filterNum(min, big),
this.filterNum(max, big),
finalPrecision,
resetValue ?? '',
pristineVal ?? '',
clearValueOnEmpty,
big
);

View File

@ -15,7 +15,8 @@ import {
isMobile,
isPureVariable,
resolveVariableAndFilter,
isNumeric
isNumeric,
getVariable
} from 'amis-core';
import {Range as InputRange, NumberInput, Icon} from 'amis-ui';
import {FormBaseControlSchema, SchemaObject} from '../../Schema';
@ -590,26 +591,44 @@ export default class RangeControl extends React.PureComponent<
doAction(action: ActionObject, data: object, throwErrors: boolean) {
const actionType = action?.actionType as string;
if (!!~['clear', 'reset'].indexOf(actionType)) {
this.clearValue(actionType);
if (actionType === 'reset') {
this.resetValue();
} else if (actionType === 'clear') {
this.clearValue();
}
}
@autobind
resetValue() {
const {
multiple,
min: rawMin,
max: rawMax,
data,
onChange,
formStore,
store,
name,
resetValue
} = this.props;
const min = resolveNumVariable(rawMin, data, 0);
const max = resolveNumVariable(rawMax, data, 100);
let pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
const value = this.getFormatValue(
pristineVal ?? (multiple ? {min, max} : min)
);
onChange?.(value);
}
@autobind
clearValue(type: string = 'clear') {
const {multiple, min: rawMin, max: rawMax, data, onChange} = this.props;
const min = resolveNumVariable(rawMin, data, 0);
const max = resolveNumVariable(rawMax, data, 100);
let resetValue = this.props.resetValue;
if (type === 'clear') {
resetValue = undefined;
}
const value = this.getFormatValue(
resetValue ?? (multiple ? {min, max} : min)
);
const value = this.getFormatValue(multiple ? {min, max} : min);
onChange?.(value);
}

View File

@ -3,7 +3,8 @@ import {
FormItem,
FormControlProps,
FormBaseControl,
resolveEventData
resolveEventData,
getVariable
} from 'amis-core';
import {autobind, createObject, filter, toNumber} from 'amis-core';
import {ActionObject} from 'amis-core';
@ -96,12 +97,14 @@ export default class RatingControl extends React.Component<RatingProps, any> {
doAction(action: ActionObject, data: object, throwErrors: boolean) {
const actionType = action?.actionType as string;
const {onChange, resetValue} = this.props;
const {onChange, resetValue, formStore, store, name} = this.props;
if (actionType === 'clear') {
onChange?.('');
} else if (actionType === 'reset') {
onChange?.(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange?.(pristineVal ?? '');
}
}

View File

@ -2008,7 +2008,10 @@ export class TableControlRenderer extends FormTable {
deleteApi,
resetValue,
translate: __,
onChange
onChange,
formStore,
store,
name
} = this.props;
const actionType = action.actionType as string;
@ -2148,7 +2151,9 @@ export class TableControlRenderer extends FormTable {
);
return;
} else if (actionType === 'reset') {
const newItems = Array.isArray(resetValue) ? resetValue : [];
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
const newItems = Array.isArray(pristineVal) ? pristineVal : [];
this.setState(
{
items: newItems

View File

@ -3,7 +3,8 @@ import {
OptionsControl,
OptionsControlProps,
Option,
resolveEventData
resolveEventData,
getVariable
} from 'amis-core';
import Downshift from 'downshift';
import find from 'lodash/find';
@ -142,13 +143,15 @@ export default class TagControl extends React.PureComponent<
}
doAction(action: ActionObject, data: object, throwErrors: boolean) {
const {resetValue, onChange} = this.props;
const {resetValue, onChange, formStore, store, name} = this.props;
const actionType = action?.actionType as string;
if (actionType === 'clear') {
onChange?.('');
} else if (actionType === 'reset') {
onChange?.(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange?.(pristineVal ?? '');
}
}

View File

@ -19,7 +19,8 @@ import {
createObject,
setVariable,
ucFirst,
isEffectiveApi
isEffectiveApi,
getVariable
} from 'amis-core';
import {Icon, SpinnerExtraProps, Input, Spinner, OverflowTpl} from 'amis-ui';
import {ActionSchema} from '../Action';
@ -270,7 +271,9 @@ export default class TextControl extends React.PureComponent<
) {
const actionType = action?.actionType as string;
if (!!~['clear', 'reset'].indexOf(actionType)) {
if (actionType === 'reset') {
this.resetValue();
} else if (actionType === 'clear') {
this.clearValue();
} else if (actionType === 'focus') {
this.focus();
@ -298,6 +301,34 @@ export default class TextControl extends React.PureComponent<
}
}
async resetValue() {
const {onChange, dispatchEvent, resetValue, formStore, store, name} =
this.props;
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
const changeEvent = await dispatchEvent(
'change',
resolveEventData(this.props, {value: pristineVal})
);
if (changeEvent?.prevented) {
return;
}
onChange(pristineVal);
this.setState(
{
inputValue: pristineVal
},
() => {
this.focus();
this.loadAutoComplete();
}
);
}
async clearValue() {
const {onChange, dispatchEvent, clearValueOnEmpty} = this.props;
let resetValue = this.props.resetValue;
@ -317,7 +348,7 @@ export default class TextControl extends React.PureComponent<
const changeEvent = await dispatchEvent(
'change',
resolveEventData(this.props, {resetValue})
resolveEventData(this.props, {value: resetValue})
);
if (changeEvent?.prevented) {

View File

@ -19,7 +19,8 @@ import {
hasAbility,
findTree,
isEffectiveApi,
BaseApiObject
BaseApiObject,
getVariable
} from 'amis-core';
import {Spinner, SearchBox} from 'amis-ui';
import {FormOptionsSchema, SchemaApi} from '../../Schema';
@ -242,12 +243,14 @@ export default class TreeControl extends React.Component<TreeProps, TreeState> {
doAction(action: ActionObject, data: any, throwErrors: boolean) {
const actionType = action?.actionType as string;
const {resetValue, onChange} = this.props;
const {resetValue, onChange, formStore, store, name} = this.props;
if (actionType === 'clear') {
onChange?.('');
} else if (actionType === 'reset') {
onChange?.(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange?.(pristineVal ?? '');
} else if (action.actionType === 'expand') {
this.treeRef.syncUnFolded(this.props, action.args?.openLevel);
} else if (action.actionType === 'collapse') {

View File

@ -3,7 +3,8 @@ import {
OptionsControl,
OptionsControlProps,
Option,
FormOptionsControl
FormOptionsControl,
getVariable
} from 'amis-core';
import {ActionObject, Schema} from 'amis-core';
import {createObject, isEmpty} from 'amis-core';
@ -68,13 +69,15 @@ export default class ListControl extends React.Component<ListProps, any> {
};
doAction(action: ActionObject, data: object, throwErrors: boolean) {
const {resetValue, onChange} = this.props;
const {resetValue, onChange, formStore, store, name} = this.props;
const actionType = action?.actionType as string;
if (actionType === 'clear') {
onChange?.('');
} else if (actionType === 'reset') {
onChange?.(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange?.(pristineVal ?? '');
}
}

View File

@ -5,7 +5,8 @@ import {
ThemeProps,
Overlay,
PopOver,
autobind
autobind,
getVariable
} from 'amis-core';
import {
FormItem,
@ -121,14 +122,18 @@ export class LocationControl extends React.Component<LocationControlProps> {
}
doAction(action: ActionObject, data: object, throwErrors: boolean): any {
const {resetValue, onChange} = this.props;
const {resetValue, onChange, formStore, store, name} = this.props;
const actionType = action?.actionType as string;
switch (actionType) {
case 'clear':
onChange('');
break;
case 'reset':
onChange?.(resetValue ?? {});
onChange?.(
getVariable(formStore?.pristine ?? store?.pristine, name) ??
resetValue ??
''
);
break;
}
}

View File

@ -8,6 +8,7 @@ import {
FormBaseControl,
FormControlProps,
FormItem,
getVariable,
resolveEventData
} from 'amis-core';
import {buildApi, isValidApi, isEffectiveApi} from 'amis-core';
@ -178,13 +179,16 @@ export default class MatrixCheckbox extends React.Component<
}
doAction(action: ActionObject, data: object, throwErrors: boolean) {
const {resetValue, onChange} = this.props;
const {resetValue, onChange, formStore, store, name} = this.props;
const actionType = action?.actionType as string;
if (actionType === 'clear') {
onChange?.('');
} else if (actionType === 'reset') {
onChange?.(resetValue ?? '');
// todo pristine被更新了需要看看为啥
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange?.(pristineVal ?? '');
}
}

View File

@ -27,7 +27,8 @@ import {
OptionsControlProps,
RootClose,
ActionObject,
renderTextByKeyword
renderTextByKeyword,
getVariable
} from 'amis-core';
import {findDOMNode} from 'react-dom';
import xor from 'lodash/xor';
@ -151,13 +152,15 @@ export default class NestedSelectControl extends React.Component<
}
doAction(action: ActionObject, data: object, throwErrors: boolean) {
const {resetValue, onChange} = this.props;
const {resetValue, onChange, formStore, store, name} = this.props;
const actionType = action?.actionType as string;
if (actionType === 'clear') {
onChange?.('');
} else if (actionType === 'reset') {
onChange?.(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange?.(pristineVal ?? '');
}
}

View File

@ -3,7 +3,8 @@ import {
FormItem,
FormControlProps,
FormBaseControl,
resolveEventData
resolveEventData,
getVariable
} from 'amis-core';
import cx from 'classnames';
import {Checkbox} from 'amis-ui';
@ -63,13 +64,15 @@ export default class RadioControl extends React.Component<RadioProps, any> {
};
doAction(action: ActionObject, data: object, throwErrors: boolean) {
const {resetValue, onChange} = this.props;
const {resetValue, onChange, formStore, store, name} = this.props;
const actionType = action?.actionType as string;
if (actionType === 'clear') {
onChange('');
} else if (actionType === 'reset') {
onChange(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange(pristineVal ?? '');
}
}

View File

@ -7,7 +7,8 @@ import {
Option,
FormOptionsControl,
resolveEventData,
TestIdBuilder
TestIdBuilder,
getVariable
} from 'amis-core';
import {autobind, isEmpty, createObject} from 'amis-core';
import {ActionObject} from 'amis-core';
@ -47,13 +48,15 @@ export default class RadiosControl extends React.Component<RadiosProps, any> {
};
doAction(action: ActionObject, data: object, throwErrors: boolean) {
const {resetValue, onChange} = this.props;
const {resetValue, onChange, formStore, store, name} = this.props;
const actionType = action?.actionType as string;
if (actionType === 'clear') {
onChange?.('');
} else if (actionType === 'reset') {
onChange?.(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange?.(pristineVal ?? '');
}
}

View File

@ -15,7 +15,8 @@ import {
isApiOutdated,
createObject,
autobind,
TestIdBuilder
TestIdBuilder,
getVariable
} from 'amis-core';
import {TransferDropDown, Spinner, Select, SpinnerExtraProps} from 'amis-ui';
import {FormOptionsSchema, SchemaApi} from '../../Schema';
@ -300,6 +301,7 @@ export default class SelectControl extends React.Component<SelectProps, any> {
const {onChange, setOptions, options, data, dispatchEvent} = this.props;
let additonalOptions: Array<any> = [];
let newValue: string | Option | Array<Option> | void = this.getValue(
value,
additonalOptions
@ -442,13 +444,16 @@ export default class SelectControl extends React.Component<SelectProps, any> {
}
doAction(action: ActionObject, data: object, throwErrors: boolean): any {
const {resetValue, onChange} = this.props;
const {resetValue, onChange, formStore, store, name, valueField} =
this.props;
const actionType = action?.actionType as string;
if (actionType === 'clear') {
onChange?.('');
} else if (actionType === 'reset') {
const value = this.getValue(resetValue ?? '');
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
const value = this.getValue({[valueField]: pristineVal ?? ''});
onChange?.(value);
}
}

View File

@ -3,7 +3,9 @@ import {
FormItem,
FormControlProps,
FormBaseControl,
resolveEventData
resolveEventData,
getVariable,
ListenerAction
} from 'amis-core';
import {Icon, Switch} from 'amis-ui';
import {autobind, isObject} from 'amis-core';
@ -130,6 +132,24 @@ export default class SwitchControl extends React.Component<SwitchProps, any> {
return this.renderBody(body);
}
doAction(
action: ListenerAction,
data: any,
throwErrors: boolean = false,
args?: any
) {
const actionType = action?.actionType as string;
const {onChange, formStore, store, name, resetValue} = this.props;
if (actionType === 'clear') {
onChange?.(''); // switch的value可能是任何类型空值可能是'' or null但因为form的clear的清空现在是'',则这里为了保持一致也用''
} else if (actionType === 'reset') {
const pristineVal =
getVariable(formStore?.pristine ?? store?.pristine, name) ?? resetValue;
onChange?.(pristineVal);
}
}
@supportStatic()
render() {
const {

Some files were not shown because too many files have changed in this diff Show More