diff --git a/docs/zh-CN/components/calendar.md b/docs/zh-CN/components/calendar.md index 89d6b9fd7..46f79bfde 100644 --- a/docs/zh-CN/components/calendar.md +++ b/docs/zh-CN/components/calendar.md @@ -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` 更新的值 | 更新数据 | diff --git a/docs/zh-CN/components/form/button-group-select.md b/docs/zh-CN/components/form/button-group-select.md index 9d188972b..191554c19 100755 --- a/docs/zh-CN/components/form/button-group-select.md +++ b/docs/zh-CN/components/form/button-group-select.md @@ -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" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/chain-select.md b/docs/zh-CN/components/form/chain-select.md index ae315491f..8a2ac5efe 100755 --- a/docs/zh-CN/components/form/chain-select.md +++ b/docs/zh-CN/components/form/chain-select.md @@ -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" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/checkbox.md b/docs/zh-CN/components/form/checkbox.md index b37cbe198..c5dde7bac 100755 --- a/docs/zh-CN/components/form/checkbox.md +++ b/docs/zh-CN/components/form/checkbox.md @@ -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 + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/checkboxes.md b/docs/zh-CN/components/form/checkboxes.md index 09e6c0768..5638059c2 100755 --- a/docs/zh-CN/components/form/checkboxes.md +++ b/docs/zh-CN/components/form/checkboxes.md @@ -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" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/combo.md b/docs/zh-CN/components/form/combo.md index 7b31ae492..f40ae1ca2 100755 --- a/docs/zh-CN/components/form/combo.md +++ b/docs/zh-CN/components/form/combo.md @@ -1134,9 +1134,113 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层 | -------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | | addItem | `item: object` 新增项的值 | 只有开启`multiple`模式才能使用, `multiple`模式下,给新增项添加默认值 | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: object \| Array` 更新的值
`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" { diff --git a/docs/zh-CN/components/form/diff-editor.md b/docs/zh-CN/components/form/diff-editor.md index e1d4f30eb..c6e8167a9 100755 --- a/docs/zh-CN/components/form/diff-editor.md +++ b/docs/zh-CN/components/form/diff-editor.md @@ -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!" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/editor.md b/docs/zh-CN/components/form/editor.md index 445572de8..d153a4a88 100755 --- a/docs/zh-CN/components/form/editor.md +++ b/docs/zh-CN/components/form/editor.md @@ -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!" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-city.md b/docs/zh-CN/components/form/input-city.md index 9e01cdf62..38516ebe9 100755 --- a/docs/zh-CN/components/form/input-city.md +++ b/docs/zh-CN/components/form/input-city.md @@ -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" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-date-range.md b/docs/zh-CN/components/form/input-date-range.md index f40b20307..9a3b424f3 100755 --- a/docs/zh-CN/components/form/input-date-range.md +++ b/docs/zh-CN/components/form/input-date-range.md @@ -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" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-date.md b/docs/zh-CN/components/form/input-date.md index dde6d03b5..90bff3912 100755 --- a/docs/zh-CN/components/form/input-date.md +++ b/docs/zh-CN/components/form/input-date.md @@ -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" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-datetime-range.md b/docs/zh-CN/components/form/input-datetime-range.md index efba86203..d2fffc5f7 100755 --- a/docs/zh-CN/components/form/input-datetime-range.md +++ b/docs/zh-CN/components/form/input-datetime-range.md @@ -159,5 +159,5 @@ order: 16 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------------------------- | -------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1650556800,1652889599' | diff --git a/docs/zh-CN/components/form/input-datetime.md b/docs/zh-CN/components/form/input-datetime.md index 3b46ee2b1..e506ce027 100755 --- a/docs/zh-CN/components/form/input-datetime.md +++ b/docs/zh-CN/components/form/input-datetime.md @@ -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' | diff --git a/docs/zh-CN/components/form/input-excel.md b/docs/zh-CN/components/form/input-excel.md index 4653409a9..74405529c 100644 --- a/docs/zh-CN/components/form/input-excel.md +++ b/docs/zh-CN/components/form/input-excel.md @@ -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` | | 自动填充 | `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` | | 自动填充 | `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` 更新的 excel 解析后数据 | 更新数据 | +| 动作名称 | 动作配置 | 说明 | +| -------- | ---------------------------------------------- | ------------------------------------------------ | +| clear | - | 清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | +| setValue | `value: Array` 更新的 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" + } + ] + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-file.md b/docs/zh-CN/components/form/input-file.md index 10b6e8fd3..aa2c5d685 100755 --- a/docs/zh-CN/components/form/input-file.md +++ b/docs/zh-CN/components/form/input-file.md @@ -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" + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-image.md b/docs/zh-CN/components/form/input-image.md index a31cfb068..b8e097655 100755 --- a/docs/zh-CN/components/form/input-image.md +++ b/docs/zh-CN/components/form/input-image.md @@ -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" + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-kv.md b/docs/zh-CN/components/form/input-kv.md index c04b9c956..353f2f339 100644 --- a/docs/zh-CN/components/form/input-kv.md +++ b/docs/zh-CN/components/form/input-kv.md @@ -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` 更新的值 | 更新数据 | diff --git a/docs/zh-CN/components/form/input-month-range.md b/docs/zh-CN/components/form/input-month-range.md index d7f3b7824..fcdf1e4de 100644 --- a/docs/zh-CN/components/form/input-month-range.md +++ b/docs/zh-CN/components/form/input-month-range.md @@ -102,5 +102,5 @@ order: 15 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------------------------- | -------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1646064000,1651334399' | diff --git a/docs/zh-CN/components/form/input-month.md b/docs/zh-CN/components/form/input-month.md index 198553e36..5d185e696 100755 --- a/docs/zh-CN/components/form/input-month.md +++ b/docs/zh-CN/components/form/input-month.md @@ -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' | diff --git a/docs/zh-CN/components/form/input-number.md b/docs/zh-CN/components/form/input-number.md index d41ba35e0..67a962d65 100755 --- a/docs/zh-CN/components/form/input-number.md +++ b/docs/zh-CN/components/form/input-number.md @@ -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 + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-quarter-range.md b/docs/zh-CN/components/form/input-quarter-range.md index ba7d0b584..00a210b07 100644 --- a/docs/zh-CN/components/form/input-quarter-range.md +++ b/docs/zh-CN/components/form/input-quarter-range.md @@ -101,5 +101,5 @@ order: 15 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------------------------- | -------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1640966400,1664553600' | diff --git a/docs/zh-CN/components/form/input-quarter.md b/docs/zh-CN/components/form/input-quarter.md index 3438eb3c5..ee48f6ae7 100644 --- a/docs/zh-CN/components/form/input-quarter.md +++ b/docs/zh-CN/components/form/input-quarter.md @@ -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' | diff --git a/docs/zh-CN/components/form/input-range.md b/docs/zh-CN/components/form/input-range.md index 87e4bf2fc..9990b52a7 100755 --- a/docs/zh-CN/components/form/input-range.md +++ b/docs/zh-CN/components/form/input-range.md @@ -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` | 分割的块数
主持数组传入分块的节点 | | marks | { [number | string]: string | number | SchemaObject } or { [number | string]: { style: CSSProperties, label: string } } | | 刻度标记
- 支持自定义样式
- 设置百分比 | -| tooltipVisible | `boolean` | `false` | 是否显示滑块标签 | -| tooltipPlacement | `auto` or `bottom` or `left` or `right` | `top` | 滑块标签的位置,默认`auto`,方向自适应
前置条件:tooltipVisible 不为 false 时有效 | -| tipFormatter | `function` | | 控制滑块标签显隐函数
前置条件:tooltipVisible 不为 false 时有效 | -| multiple | `boolean` | `false` | 支持选择范围 | -| joinValues | `boolean` | `true` | 默认为 `true`,选择的 `value` 会通过 `delimiter` 连接起来,否则直接将以`{min: 1, max: 100}`的形式提交
前置条件:开启`multiple`时有效 | -| delimiter | `string` | `,` | 分隔符 | -| unit | `string` | | 单位 | -| clearable | `boolean` | `false` | 是否可清除
前置条件:开启`showInput`时有效 | -| showInput | `boolean` | `false` | 是否显示输入框 | -| showInputUnit | `boolean` | `false` | 是否显示输入框单位
前置条件:开启`showInput`且配置了`unit`单位时有效 |`6.0.0`后支持变量 -| onChange | `function` | | 当 组件 的值发生改变时,会触发 onChange 事件,并把改变后的值作为参数传入 | -| onAfterChange | `function` | | 与 `onmouseup` 触发时机一致,把当前值作为参数传入 | +| tooltipVisible | `boolean` | `false` | 是否显示滑块标签 | +| tooltipPlacement | `auto` or `bottom` or `left` or `right` | `top` | 滑块标签的位置,默认`auto`,方向自适应
前置条件:tooltipVisible 不为 false 时有效 | +| tipFormatter | `function` | | 控制滑块标签显隐函数
前置条件:tooltipVisible 不为 false 时有效 | +| multiple | `boolean` | `false` | 支持选择范围 | +| joinValues | `boolean` | `true` | 默认为 `true`,选择的 `value` 会通过 `delimiter` 连接起来,否则直接将以`{min: 1, max: 100}`的形式提交
前置条件:开启`multiple`时有效 | +| delimiter | `string` | `,` | 分隔符 | +| unit | `string` | | 单位 | +| clearable | `boolean` | `false` | 是否可清除
前置条件:开启`showInput`时有效 | +| showInput | `boolean` | `false` | 是否显示输入框 | +| showInputUnit | `boolean` | `false` | 是否显示输入框单位
前置条件:开启`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 | - | 清除输入框
前置条件: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 + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-rating.md b/docs/zh-CN/components/form/input-rating.md index 1253e530e..1fe8e9bb5 100755 --- a/docs/zh-CN/components/form/input-rating.md +++ b/docs/zh-CN/components/form/input-rating.md @@ -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 + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-table.md b/docs/zh-CN/components/form/input-table.md index 3405d888a..2f0f8388c 100755 --- a/docs/zh-CN/components/form/input-table.md +++ b/docs/zh-CN/components/form/input-table.md @@ -2549,7 +2549,7 @@ order: 54 "label": "表格表单", "id": "reset-input-table", "name": "table", - "resetValue": [ + "value": [ { "a": "a-resetValue1", "b": "b-resetValue1" diff --git a/docs/zh-CN/components/form/input-tag.md b/docs/zh-CN/components/form/input-tag.md index c48274690..869415af2 100755 --- a/docs/zh-CN/components/form/input-tag.md +++ b/docs/zh-CN/components/form/input-tag.md @@ -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" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-text.md b/docs/zh-CN/components/form/input-text.md index 37123841c..465c0180e 100755 --- a/docs/zh-CN/components/form/input-text.md +++ b/docs/zh-CN/components/form/input-text.md @@ -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!" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-time-range.md b/docs/zh-CN/components/form/input-time-range.md index 32d62c5fc..3bd9d609b 100644 --- a/docs/zh-CN/components/form/input-time-range.md +++ b/docs/zh-CN/components/form/input-time-range.md @@ -118,5 +118,5 @@ order: 15 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------------------------- | -------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1617206400,1743436800' | diff --git a/docs/zh-CN/components/form/input-time.md b/docs/zh-CN/components/form/input-time.md index 6eb358056..d420fc860 100755 --- a/docs/zh-CN/components/form/input-time.md +++ b/docs/zh-CN/components/form/input-time.md @@ -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' | diff --git a/docs/zh-CN/components/form/input-tree.md b/docs/zh-CN/components/form/input-tree.md index 1a60c987d..887c2fe48 100755 --- a/docs/zh-CN/components/form/input-tree.md +++ b/docs/zh-CN/components/form/input-tree.md @@ -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" + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/input-year-range.md b/docs/zh-CN/components/form/input-year-range.md index b5fac2a28..25033800e 100644 --- a/docs/zh-CN/components/form/input-year-range.md +++ b/docs/zh-CN/components/form/input-year-range.md @@ -101,5 +101,5 @@ order: 15 | 动作名称 | 动作配置 | 说明 | | -------- | ------------------------------------------- | -------------------------------------------------------- | | clear | - | 清空 | -| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 | +| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` | | setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1648746120,1648760760' | diff --git a/docs/zh-CN/components/form/input-year.md b/docs/zh-CN/components/form/input-year.md index 7ea3903ca..638f5c0db 100644 --- a/docs/zh-CN/components/form/input-year.md +++ b/docs/zh-CN/components/form/input-year.md @@ -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' | diff --git a/docs/zh-CN/components/form/list-select.md b/docs/zh-CN/components/form/list-select.md index e3897c708..27af913d2 100755 --- a/docs/zh-CN/components/form/list-select.md +++ b/docs/zh-CN/components/form/list-select.md @@ -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" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/location-picker.md b/docs/zh-CN/components/form/location-picker.md index e9f26a257..4102f64d6 100644 --- a/docs/zh-CN/components/form/location-picker.md +++ b/docs/zh-CN/components/form/location-picker.md @@ -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" + } + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/matrix-checkboxes.md b/docs/zh-CN/components/form/matrix-checkboxes.md index 02394c6a4..5f7764a69 100755 --- a/docs/zh-CN/components/form/matrix-checkboxes.md +++ b/docs/zh-CN/components/form/matrix-checkboxes.md @@ -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 + } + ] + ] + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/nestedselect.md b/docs/zh-CN/components/form/nestedselect.md index b1a01a9d8..2131d3de7 100755 --- a/docs/zh-CN/components/form/nestedselect.md +++ b/docs/zh-CN/components/form/nestedselect.md @@ -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" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/radio.md b/docs/zh-CN/components/form/radio.md index fb49428a8..0df0cc71b 100644 --- a/docs/zh-CN/components/form/radio.md +++ b/docs/zh-CN/components/form/radio.md @@ -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 + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/radios.md b/docs/zh-CN/components/form/radios.md index 10cf4dbb1..38f28f1b1 100644 --- a/docs/zh-CN/components/form/radios.md +++ b/docs/zh-CN/components/form/radios.md @@ -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" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/select.md b/docs/zh-CN/components/form/select.md index 0fe1b3545..4dafc0b60 100755 --- a/docs/zh-CN/components/form/select.md +++ b/docs/zh-CN/components/form/select.md @@ -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" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/switch.md b/docs/zh-CN/components/form/switch.md index c54949916..647899ec0 100755 --- a/docs/zh-CN/components/form/switch.md +++ b/docs/zh-CN/components/form/switch.md @@ -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 diff --git a/docs/zh-CN/components/form/tabs-transfer-picker.md b/docs/zh-CN/components/form/tabs-transfer-picker.md index df2c7d3b6..3a44d5aed 100644 --- a/docs/zh-CN/components/form/tabs-transfer-picker.md +++ b/docs/zh-CN/components/form/tabs-transfer-picker.md @@ -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" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/tabs-transfer.md b/docs/zh-CN/components/form/tabs-transfer.md index e55ebdabe..5f04d1427 100644 --- a/docs/zh-CN/components/form/tabs-transfer.md +++ b/docs/zh-CN/components/form/tabs-transfer.md @@ -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" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/textarea.md b/docs/zh-CN/components/form/textarea.md index e580607d2..1fbf06f3c 100755 --- a/docs/zh-CN/components/form/textarea.md +++ b/docs/zh-CN/components/form/textarea.md @@ -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!" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/transfer-picker.md b/docs/zh-CN/components/form/transfer-picker.md index 932d68fa8..391679d88 100644 --- a/docs/zh-CN/components/form/transfer-picker.md +++ b/docs/zh-CN/components/form/transfer-picker.md @@ -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" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/transfer.md b/docs/zh-CN/components/form/transfer.md index 337ab0d49..6c0a4ff02 100644 --- a/docs/zh-CN/components/form/transfer.md +++ b/docs/zh-CN/components/form/transfer.md @@ -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" + } + } + ] + } + } + } + ] +} +``` diff --git a/docs/zh-CN/components/form/treeselect.md b/docs/zh-CN/components/form/treeselect.md index ca0c1ff97..546eaaed6 100755 --- a/docs/zh-CN/components/form/treeselect.md +++ b/docs/zh-CN/components/form/treeselect.md @@ -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" + } + ] + } + } + } + ] +} +``` diff --git a/packages/amis-editor/src/locale/en-US.ts b/packages/amis-editor/src/locale/en-US.ts index 7a33903b3..d49a0a220 100644 --- a/packages/amis-editor/src/locale/en-US.ts +++ b/packages/amis-editor/src/locale/en-US.ts @@ -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', diff --git a/packages/amis-editor/src/locale/zh-CN.ts b/packages/amis-editor/src/locale/zh-CN.ts index d8d7ed8d2..21a5e60e0 100644 --- a/packages/amis-editor/src/locale/zh-CN.ts +++ b/packages/amis-editor/src/locale/zh-CN.ts @@ -636,8 +636,7 @@ extendLocale('zh-CN', { '528609917710d813a55e5a6cecf1e458': '选中值', '288f0c404c4e546aa3683ff5054e85e2': '清空', 'c374a44713fa5ff5da2565beb398c7d3': '清除选中值', - '8db57ba01ffb9bf29c1656de5f0208f5': - '将值重置为resetValue,若没有配置resetValue,则清空', + '8db57ba01ffb9bf29c1656de5f0208f5': '将值重置为初始值', '8f40db3b25528063f1b6a59602a05cd5': '赋值', '944908c981a86bfa0cfab9360ab38184': '使按钮宽度占满父容器,各按钮宽度自适应', '0b98b0bea3db6ae5b67a09c7bb2d032b': '按钮选中样式', diff --git a/packages/amis-editor/src/plugin/Calendar.tsx b/packages/amis-editor/src/plugin/Calendar.tsx index 2902b70fa..6230e7363 100644 --- a/packages/amis-editor/src/plugin/Calendar.tsx +++ b/packages/amis-editor/src/plugin/Calendar.tsx @@ -131,7 +131,7 @@ export class CalendarPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/ButtonGroupSelect.tsx b/packages/amis-editor/src/plugin/Form/ButtonGroupSelect.tsx index 033ddfb80..9de5d9d35 100644 --- a/packages/amis-editor/src/plugin/Form/ButtonGroupSelect.tsx +++ b/packages/amis-editor/src/plugin/Form/ButtonGroupSelect.tsx @@ -100,7 +100,7 @@ export class ButtonGroupControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/ChainedSelect.tsx b/packages/amis-editor/src/plugin/Form/ChainedSelect.tsx index 6d8c30545..770f55da6 100644 --- a/packages/amis-editor/src/plugin/Form/ChainedSelect.tsx +++ b/packages/amis-editor/src/plugin/Form/ChainedSelect.tsx @@ -88,7 +88,7 @@ export class ChainedSelectControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/Checkbox.tsx b/packages/amis-editor/src/plugin/Form/Checkbox.tsx index bafe5e255..1f00333f4 100644 --- a/packages/amis-editor/src/plugin/Form/Checkbox.tsx +++ b/packages/amis-editor/src/plugin/Form/Checkbox.tsx @@ -108,7 +108,7 @@ export class CheckboxControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/Checkboxes.tsx b/packages/amis-editor/src/plugin/Form/Checkboxes.tsx index 076bcafd1..6f615b9a9 100644 --- a/packages/amis-editor/src/plugin/Form/Checkboxes.tsx +++ b/packages/amis-editor/src/plugin/Form/Checkboxes.tsx @@ -113,7 +113,7 @@ export class CheckboxesControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/CodeEditor.tsx b/packages/amis-editor/src/plugin/Form/CodeEditor.tsx index 3d7250038..b8a42372c 100644 --- a/packages/amis-editor/src/plugin/Form/CodeEditor.tsx +++ b/packages/amis-editor/src/plugin/Form/CodeEditor.tsx @@ -120,7 +120,7 @@ export class CodeEditorControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'focus', diff --git a/packages/amis-editor/src/plugin/Form/Combo.tsx b/packages/amis-editor/src/plugin/Form/Combo.tsx index c56afd1cf..519fe0b06 100644 --- a/packages/amis-editor/src/plugin/Form/Combo.tsx +++ b/packages/amis-editor/src/plugin/Form/Combo.tsx @@ -254,7 +254,7 @@ export class ComboControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'addItem', diff --git a/packages/amis-editor/src/plugin/Form/DiffEditor.tsx b/packages/amis-editor/src/plugin/Form/DiffEditor.tsx index 004b2d812..214cc8047 100644 --- a/packages/amis-editor/src/plugin/Form/DiffEditor.tsx +++ b/packages/amis-editor/src/plugin/Form/DiffEditor.tsx @@ -127,7 +127,7 @@ export class DiffEditorControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'focus', diff --git a/packages/amis-editor/src/plugin/Form/InputDate.tsx b/packages/amis-editor/src/plugin/Form/InputDate.tsx index bb2463f9a..2020cf2cc 100644 --- a/packages/amis-editor/src/plugin/Form/InputDate.tsx +++ b/packages/amis-editor/src/plugin/Form/InputDate.tsx @@ -253,7 +253,7 @@ export class DateControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/InputDateRange.tsx b/packages/amis-editor/src/plugin/Form/InputDateRange.tsx index 168409660..d4a33e17a 100644 --- a/packages/amis-editor/src/plugin/Form/InputDateRange.tsx +++ b/packages/amis-editor/src/plugin/Form/InputDateRange.tsx @@ -299,7 +299,7 @@ export class DateRangeControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/InputExcel.tsx b/packages/amis-editor/src/plugin/Form/InputExcel.tsx index c52aa6f68..0471c0dc2 100644 --- a/packages/amis-editor/src/plugin/Form/InputExcel.tsx +++ b/packages/amis-editor/src/plugin/Form/InputExcel.tsx @@ -85,7 +85,7 @@ export class ExcelControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/InputKV.tsx b/packages/amis-editor/src/plugin/Form/InputKV.tsx index 997149755..5d548ecef 100644 --- a/packages/amis-editor/src/plugin/Form/InputKV.tsx +++ b/packages/amis-editor/src/plugin/Form/InputKV.tsx @@ -118,7 +118,7 @@ export class KVControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/InputRange.tsx b/packages/amis-editor/src/plugin/Form/InputRange.tsx index 56446ad7c..05da18d95 100644 --- a/packages/amis-editor/src/plugin/Form/InputRange.tsx +++ b/packages/amis-editor/src/plugin/Form/InputRange.tsx @@ -160,7 +160,7 @@ export class RangeControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/InputRating.tsx b/packages/amis-editor/src/plugin/Form/InputRating.tsx index 4ebb4e39f..2c4693465 100644 --- a/packages/amis-editor/src/plugin/Form/InputRating.tsx +++ b/packages/amis-editor/src/plugin/Form/InputRating.tsx @@ -85,7 +85,7 @@ export class RateControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/InputTable.tsx b/packages/amis-editor/src/plugin/Form/InputTable.tsx index 360f2de7a..3b5f4dd53 100644 --- a/packages/amis-editor/src/plugin/Form/InputTable.tsx +++ b/packages/amis-editor/src/plugin/Form/InputTable.tsx @@ -1094,7 +1094,7 @@ export class TableControlPlugin extends BasePlugin { // { // actionType: 'reset', // actionLabel: '重置', - // description: '将值重置为resetValue,若没有配置resetValue,则清空' + // description: '将值重置为初始值' // }, { actionType: 'clear', diff --git a/packages/amis-editor/src/plugin/Form/InputText.tsx b/packages/amis-editor/src/plugin/Form/InputText.tsx index 69002e7b2..0062242f8 100644 --- a/packages/amis-editor/src/plugin/Form/InputText.tsx +++ b/packages/amis-editor/src/plugin/Form/InputText.tsx @@ -190,7 +190,7 @@ export class TextControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/ListSelect.tsx b/packages/amis-editor/src/plugin/Form/ListSelect.tsx index 4efd30e77..cc64ddcc8 100644 --- a/packages/amis-editor/src/plugin/Form/ListSelect.tsx +++ b/packages/amis-editor/src/plugin/Form/ListSelect.tsx @@ -107,7 +107,7 @@ export class ListControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/LocationPicker.tsx b/packages/amis-editor/src/plugin/Form/LocationPicker.tsx index 1c90c6f37..edcc9a093 100644 --- a/packages/amis-editor/src/plugin/Form/LocationPicker.tsx +++ b/packages/amis-editor/src/plugin/Form/LocationPicker.tsx @@ -95,7 +95,7 @@ export class LocationControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-editor/src/plugin/Form/NestedSelect.tsx b/packages/amis-editor/src/plugin/Form/NestedSelect.tsx index 74f77a68c..ee1d91931 100644 --- a/packages/amis-editor/src/plugin/Form/NestedSelect.tsx +++ b/packages/amis-editor/src/plugin/Form/NestedSelect.tsx @@ -201,7 +201,7 @@ export class NestedSelectControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/Radios.tsx b/packages/amis-editor/src/plugin/Form/Radios.tsx index 90d904d9b..d853a0cf0 100644 --- a/packages/amis-editor/src/plugin/Form/Radios.tsx +++ b/packages/amis-editor/src/plugin/Form/Radios.tsx @@ -103,7 +103,7 @@ export class RadiosControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/Select.tsx b/packages/amis-editor/src/plugin/Form/Select.tsx index 64b9d6171..8b0bc18b7 100644 --- a/packages/amis-editor/src/plugin/Form/Select.tsx +++ b/packages/amis-editor/src/plugin/Form/Select.tsx @@ -176,7 +176,7 @@ export class SelectControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'reload', diff --git a/packages/amis-editor/src/plugin/Form/Switch.tsx b/packages/amis-editor/src/plugin/Form/Switch.tsx index 292b46b26..21f09ba59 100644 --- a/packages/amis-editor/src/plugin/Form/Switch.tsx +++ b/packages/amis-editor/src/plugin/Form/Switch.tsx @@ -94,6 +94,16 @@ export class SwitchControlPlugin extends BasePlugin { // 动作定义 actions: RendererPluginAction[] = [ + { + actionType: 'clear', + actionLabel: '清空', + description: '清除选中值' + }, + { + actionType: 'reset', + actionLabel: '重置', + description: '将值重置为初始值' + }, { actionType: 'setValue', actionLabel: '赋值', diff --git a/packages/amis-editor/src/plugin/Form/Textarea.tsx b/packages/amis-editor/src/plugin/Form/Textarea.tsx index d4d9dd6a7..b6b2ee576 100644 --- a/packages/amis-editor/src/plugin/Form/Textarea.tsx +++ b/packages/amis-editor/src/plugin/Form/Textarea.tsx @@ -119,7 +119,7 @@ export class TextareaControlPlugin extends BasePlugin { { actionType: 'reset', actionLabel: '重置', - description: '将值重置为resetValue,若没有配置resetValue,则清空' + description: '将值重置为初始值' }, { actionType: 'setValue', diff --git a/packages/amis-ui/src/components/DateRangePicker.tsx b/packages/amis-ui/src/components/DateRangePicker.tsx index fd52bcf8d..4454f6892 100644 --- a/packages/amis-ui/src/components/DateRangePicker.tsx +++ b/packages/amis-ui/src/components/DateRangePicker.tsx @@ -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) diff --git a/packages/amis/__tests__/event-action/renderers/form/locationPicker.test.tsx b/packages/amis/__tests__/event-action/renderers/form/locationPicker.test.tsx index 3904cae1b..b8ed14cca 100755 --- a/packages/amis/__tests__/event-action/renderers/form/locationPicker.test.tsx +++ b/packages/amis/__tests__/event-action/renderers/form/locationPicker.test.tsx @@ -15,7 +15,6 @@ test('EventAction:locationPicker', async () => { id: 'location-picker', ak: 'LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7', coordinatesType: 'bd09', - value: '', name: 'location', resetValue: { address: '北京市东城区天安门广场中央', diff --git a/packages/amis/__tests__/renderers/Form/text.test.tsx b/packages/amis/__tests__/renderers/Form/text.test.tsx index f49ee0226..7e48345fb 100644 --- a/packages/amis/__tests__/renderers/Form/text.test.tsx +++ b/packages/amis/__tests__/renderers/Form/text.test.tsx @@ -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( diff --git a/packages/amis/src/renderers/Form/ButtonGroupSelect.tsx b/packages/amis/src/renderers/Form/ButtonGroupSelect.tsx index 952a2c791..c58b4a8ad 100644 --- a/packages/amis/src/renderers/Form/ButtonGroupSelect.tsx +++ b/packages/amis/src/renderers/Form/ButtonGroupSelect.tsx @@ -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 ?? ''); } } diff --git a/packages/amis/src/renderers/Form/ChainedSelect.tsx b/packages/amis/src/renderers/Form/ChainedSelect.tsx index c2138cb0f..aabf8bac3 100644 --- a/packages/amis/src/renderers/Form/ChainedSelect.tsx +++ b/packages/amis/src/renderers/Form/ChainedSelect.tsx @@ -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 ?? ''); } } diff --git a/packages/amis/src/renderers/Form/Checkbox.tsx b/packages/amis/src/renderers/Form/Checkbox.tsx index d2c3b33c0..fb52fffe6 100644 --- a/packages/amis/src/renderers/Form/Checkbox.tsx +++ b/packages/amis/src/renderers/Form/Checkbox.tsx @@ -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 ?? ''); } } diff --git a/packages/amis/src/renderers/Form/Checkboxes.tsx b/packages/amis/src/renderers/Form/Checkboxes.tsx index a176b3e1b..d0fa34c89 100644 --- a/packages/amis/src/renderers/Form/Checkboxes.tsx +++ b/packages/amis/src/renderers/Form/Checkboxes.tsx @@ -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 ?? ''); } } diff --git a/packages/amis/src/renderers/Form/Combo.tsx b/packages/amis/src/renderers/Form/Combo.tsx index e144addfc..da786707d 100644 --- a/packages/amis/src/renderers/Form/Combo.tsx +++ b/packages/amis/src/renderers/Form/Combo.tsx @@ -516,14 +516,19 @@ export default class ComboControl extends React.Component { 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 ?? ''); } } diff --git a/packages/amis/src/renderers/Form/DiffEditor.tsx b/packages/amis/src/renderers/Form/DiffEditor.tsx index 9ca40ffb8..9ccd621a6 100644 --- a/packages/amis/src/renderers/Form/DiffEditor.tsx +++ b/packages/amis/src/renderers/Form/DiffEditor.tsx @@ -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 { 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(); } diff --git a/packages/amis/src/renderers/Form/Editor.tsx b/packages/amis/src/renderers/Form/Editor.tsx index 8ee96b1f6..1e63c1cb4 100644 --- a/packages/amis/src/renderers/Form/Editor.tsx +++ b/packages/amis/src/renderers/Form/Editor.tsx @@ -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 { 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(); } diff --git a/packages/amis/src/renderers/Form/InputCity.tsx b/packages/amis/src/renderers/Form/InputCity.tsx index d4e277be2..2883f1114 100644 --- a/packages/amis/src/renderers/Form/InputCity.tsx +++ b/packages/amis/src/renderers/Form/InputCity.tsx @@ -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 { @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 ?? ''); } } diff --git a/packages/amis/src/renderers/Form/InputDate.tsx b/packages/amis/src/renderers/Form/InputDate.tsx index 9267f98e7..7aa7af913 100644 --- a/packages/amis/src/renderers/Form/InputDate.tsx +++ b/packages/amis/src/renderers/Form/InputDate.tsx @@ -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); } } diff --git a/packages/amis/src/renderers/Form/InputDateRange.tsx b/packages/amis/src/renderers/Form/InputDateRange.tsx index b295352cd..d9c4bc7d7 100644 --- a/packages/amis/src/renderers/Form/InputDateRange.tsx +++ b/packages/amis/src/renderers/Form/InputDateRange.tsx @@ -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 { // 动作 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); } } diff --git a/packages/amis/src/renderers/Form/InputExcel.tsx b/packages/amis/src/renderers/Form/InputExcel.tsx index 6e1f31333..ac481f788 100644 --- a/packages/amis/src/renderers/Form/InputExcel.tsx +++ b/packages/amis/src/renderers/Form/InputExcel.tsx @@ -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 ?? ''); } } diff --git a/packages/amis/src/renderers/Form/InputNumber.tsx b/packages/amis/src/renderers/Form/InputNumber.tsx index 6b4219dbb..bab72116e 100644 --- a/packages/amis/src/renderers/Form/InputNumber.tsx +++ b/packages/amis/src/renderers/Form/InputNumber.tsx @@ -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 ); diff --git a/packages/amis/src/renderers/Form/InputRange.tsx b/packages/amis/src/renderers/Form/InputRange.tsx index 713334138..a7be12aa1 100644 --- a/packages/amis/src/renderers/Form/InputRange.tsx +++ b/packages/amis/src/renderers/Form/InputRange.tsx @@ -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); } diff --git a/packages/amis/src/renderers/Form/InputRating.tsx b/packages/amis/src/renderers/Form/InputRating.tsx index acb290179..2e43c2f8b 100644 --- a/packages/amis/src/renderers/Form/InputRating.tsx +++ b/packages/amis/src/renderers/Form/InputRating.tsx @@ -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 { 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 ?? ''); } } diff --git a/packages/amis/src/renderers/Form/InputTable.tsx b/packages/amis/src/renderers/Form/InputTable.tsx index fe1e382a6..1cd87d5e4 100644 --- a/packages/amis/src/renderers/Form/InputTable.tsx +++ b/packages/amis/src/renderers/Form/InputTable.tsx @@ -2015,7 +2015,10 @@ export class TableControlRenderer extends FormTable { deleteApi, resetValue, translate: __, - onChange + onChange, + formStore, + store, + name } = this.props; const actionType = action.actionType as string; @@ -2155,7 +2158,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 diff --git a/packages/amis/src/renderers/Form/InputTag.tsx b/packages/amis/src/renderers/Form/InputTag.tsx index 42a983885..a8814ec64 100644 --- a/packages/amis/src/renderers/Form/InputTag.tsx +++ b/packages/amis/src/renderers/Form/InputTag.tsx @@ -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 ?? ''); } } diff --git a/packages/amis/src/renderers/Form/InputText.tsx b/packages/amis/src/renderers/Form/InputText.tsx index 7e0ef20a4..1ba4c37b3 100644 --- a/packages/amis/src/renderers/Form/InputText.tsx +++ b/packages/amis/src/renderers/Form/InputText.tsx @@ -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) { diff --git a/packages/amis/src/renderers/Form/InputTree.tsx b/packages/amis/src/renderers/Form/InputTree.tsx index b716c8ed5..834cc0302 100644 --- a/packages/amis/src/renderers/Form/InputTree.tsx +++ b/packages/amis/src/renderers/Form/InputTree.tsx @@ -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 { 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') { diff --git a/packages/amis/src/renderers/Form/ListSelect.tsx b/packages/amis/src/renderers/Form/ListSelect.tsx index f9810e78f..de14b5c48 100644 --- a/packages/amis/src/renderers/Form/ListSelect.tsx +++ b/packages/amis/src/renderers/Form/ListSelect.tsx @@ -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 { }; 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 ?? ''); } } diff --git a/packages/amis/src/renderers/Form/LocationPicker.tsx b/packages/amis/src/renderers/Form/LocationPicker.tsx index 56f0f8ff3..3cb7b18ed 100644 --- a/packages/amis/src/renderers/Form/LocationPicker.tsx +++ b/packages/amis/src/renderers/Form/LocationPicker.tsx @@ -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 { } 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; } } diff --git a/packages/amis/src/renderers/Form/MatrixCheckboxes.tsx b/packages/amis/src/renderers/Form/MatrixCheckboxes.tsx index 35f4b5ad6..497c6e0fb 100644 --- a/packages/amis/src/renderers/Form/MatrixCheckboxes.tsx +++ b/packages/amis/src/renderers/Form/MatrixCheckboxes.tsx @@ -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 ?? ''); } } diff --git a/packages/amis/src/renderers/Form/NestedSelect.tsx b/packages/amis/src/renderers/Form/NestedSelect.tsx index 42771c596..31411e6b5 100644 --- a/packages/amis/src/renderers/Form/NestedSelect.tsx +++ b/packages/amis/src/renderers/Form/NestedSelect.tsx @@ -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 ?? ''); } } diff --git a/packages/amis/src/renderers/Form/Radio.tsx b/packages/amis/src/renderers/Form/Radio.tsx index ac7a296cf..ea20b558b 100644 --- a/packages/amis/src/renderers/Form/Radio.tsx +++ b/packages/amis/src/renderers/Form/Radio.tsx @@ -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 { }; 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 ?? ''); } } diff --git a/packages/amis/src/renderers/Form/Radios.tsx b/packages/amis/src/renderers/Form/Radios.tsx index a7f7aa8b5..243d31721 100644 --- a/packages/amis/src/renderers/Form/Radios.tsx +++ b/packages/amis/src/renderers/Form/Radios.tsx @@ -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 { }; 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 ?? ''); } } diff --git a/packages/amis/src/renderers/Form/Select.tsx b/packages/amis/src/renderers/Form/Select.tsx index 6971f6f5a..f239bbf0a 100644 --- a/packages/amis/src/renderers/Form/Select.tsx +++ b/packages/amis/src/renderers/Form/Select.tsx @@ -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 { const {onChange, setOptions, options, data, dispatchEvent} = this.props; let additonalOptions: Array = []; + let newValue: string | Option | Array