2020-07-28 10:03:53 +08:00
|
|
|
---
|
|
|
|
title: DiffEditor 对比编辑器
|
2020-07-29 17:33:14 +08:00
|
|
|
description:
|
2020-07-28 10:03:53 +08:00
|
|
|
type: 0
|
|
|
|
group: null
|
|
|
|
menuName: DiffEditor 对比编辑器
|
2020-07-29 17:33:14 +08:00
|
|
|
icon:
|
2020-07-28 10:03:53 +08:00
|
|
|
order: 17
|
|
|
|
---
|
|
|
|
|
|
|
|
## 基本使用
|
|
|
|
|
2021-01-07 23:35:03 +08:00
|
|
|
```schema: scope="body"
|
2020-07-28 10:03:53 +08:00
|
|
|
{
|
|
|
|
"type": "form",
|
2021-08-09 18:05:01 +08:00
|
|
|
"api": "/api/mock2/form/saveForm",
|
2021-06-07 10:09:55 +08:00
|
|
|
"body": [
|
2020-07-28 10:03:53 +08:00
|
|
|
{
|
|
|
|
"type": "diff-editor",
|
|
|
|
"name": "diff",
|
|
|
|
"label": "Diff-Editor",
|
|
|
|
"diffValue": "hello world",
|
|
|
|
"value": "hello"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## 禁用编辑器
|
|
|
|
|
|
|
|
左侧编辑器始终不可编辑,右侧编辑器可以通过设置`disabled`或`disabledOn`,控制是否禁用
|
|
|
|
|
2021-01-07 23:35:03 +08:00
|
|
|
```schema: scope="body"
|
2020-07-28 10:03:53 +08:00
|
|
|
{
|
|
|
|
"type": "form",
|
2021-08-09 18:05:01 +08:00
|
|
|
"api": "/api/mock2/form/saveForm",
|
2021-06-07 10:09:55 +08:00
|
|
|
"body": [
|
2020-07-28 10:03:53 +08:00
|
|
|
{
|
|
|
|
"type": "diff-editor",
|
|
|
|
"name": "diff",
|
|
|
|
"label": "Diff-Editor",
|
|
|
|
"diffValue": "hello world",
|
|
|
|
"value": "hello",
|
2020-11-02 11:15:30 +08:00
|
|
|
"disabledOn": "this.isDisabled"
|
2020-07-28 10:03:53 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "switch",
|
|
|
|
"name": "isDisabled",
|
|
|
|
"label": "是否禁用"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## diff 数据域中的两个变量
|
|
|
|
|
|
|
|
如下例,左侧编辑器中的值,通过`"diffValue": "${value1}"`获取,右侧编辑器的值,通过设置`"name": "value2"`,自动映射数据域中`value2`的值
|
|
|
|
|
2021-01-07 23:35:03 +08:00
|
|
|
```schema: scope="body"
|
2020-07-28 10:03:53 +08:00
|
|
|
{
|
|
|
|
"type": "form",
|
2021-08-09 18:05:01 +08:00
|
|
|
"api": "/api/mock2/form/saveForm",
|
2020-07-28 10:03:53 +08:00
|
|
|
"data": {
|
|
|
|
"value1": "hello world",
|
|
|
|
"value2": "hello wrold"
|
|
|
|
},
|
2021-06-07 10:09:55 +08:00
|
|
|
"body": [
|
2020-07-28 10:03:53 +08:00
|
|
|
{
|
|
|
|
"type": "diff-editor",
|
|
|
|
"name": "value2",
|
|
|
|
"label": "Diff-Editor",
|
|
|
|
"diffValue": "${value1}"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## 属性表
|
|
|
|
|
|
|
|
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
|
|
|
|
2020-07-29 17:33:14 +08:00
|
|
|
| 属性名 | 类型 | 默认值 | 说明 |
|
|
|
|
| --------- | ------------- | ------------ | ------------------------------------------------------------------------------------------- |
|
|
|
|
| language | `string` | `javascript` | 编辑器高亮的语言,可选 [支持的语言](./editor#%E6%94%AF%E6%8C%81%E7%9A%84%E8%AF%AD%E8%A8%80) |
|
|
|
|
| diffValue | [Tpl](../tpl) | | 左侧值 |
|
2022-03-16 20:50:59 +08:00
|
|
|
|
|
|
|
## 事件表
|
|
|
|
|
2023-05-28 22:26:48 +08:00
|
|
|
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
2022-05-31 15:05:54 +08:00
|
|
|
|
2022-10-12 15:09:03 +08:00
|
|
|
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
|
|
|
|
|
|
|
| 事件名称 | 事件参数 | 说明 |
|
|
|
|
| -------- | ------------------------- | ------------------------ |
|
|
|
|
| change | `[name]: string` 组件的值 | 代码变化时触发 |
|
|
|
|
| focus | `[name]: string` 组件的值 | 右侧输入框获取焦点时触发 |
|
|
|
|
| blur | `[name]: string` 组件的值 | 右侧输入框失去焦点时触发 |
|
2022-03-16 20:50:59 +08:00
|
|
|
|
|
|
|
## 动作表
|
|
|
|
|
2022-05-31 15:05:54 +08:00
|
|
|
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
|
|
|
|
2022-04-26 21:12:00 +08:00
|
|
|
| 动作名称 | 动作配置 | 说明 |
|
|
|
|
| -------- | ---------------------------------------- | ------------------------------------------------------ |
|
|
|
|
| clear | - | 清空 |
|
|
|
|
| reset | - | 将值重置为`resetValue`,若没有配置`resetValue`,则清空 |
|
|
|
|
| focus | - | 获取焦点,焦点落在右侧编辑面板 |
|
|
|
|
| setValue | `value: string` 更新的右侧编辑面板中的值 | 更新数据 |
|