feat:统一动作特性参数为args&更新文档 (#4095)

* feat:统一动作特性参数为args

* feat:增加入参错误判断

* feat:统一动作特性参数为args
This commit is contained in:
hsm-lv 2022-04-20 15:20:42 +08:00 committed by GitHub
parent 2138b4a2d8
commit c46106b140
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 867 additions and 1787 deletions

View File

@ -1209,10 +1209,10 @@ Form 支持轮询初始化接口,步骤如下:
| --------------------- | ----------------------------- | -------------- |
| inited | 表单数据 | 初始化完成 |
| change | 表单数据 | 值变化 |
| formItemValidateSucc | - | 表单项校验成功 |
| formItemValidateError | - | 表单项校验失败 |
| validateSucc | - | 表单校验成功 |
| validateError | - | 表单校验成功 |
| formItemValidateSucc | 表单数据 | 表单项校验成功 |
| formItemValidateError | 表单数据 | 表单项校验失败 |
| validateSucc | 表单数据 | 表单校验成功 |
| validateError | 表单数据 | 表单校验成功 |
| submitSucc | `result: object` 接口返回内容 | 提交成功 |
| submitFail | `error: object` 接口返回内容 | 提交失败 |

File diff suppressed because it is too large Load Diff

View File

@ -1,236 +0,0 @@
export default {
type: 'page',
title: '广播(自定义事件)',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'button',
id: 'b_001',
label: '发送广播事件1-表单1/2/3都在监听',
onEvent: {
click: {
actions: [
{
actionType: 'broadcast',
eventName: 'broadcast_1',
args: {
name: 'lvxj',
age: 18,
ld: [
{
name: 'ld-lv',
age: 'ld-19'
},
{
name: 'ld-xj',
age: 'ld-21'
}
]
},
description: '一个按钮的点击事件'
}
]
}
}
},
{
type: 'button',
id: 'b_002',
label: '发送广播事件2-表单3在监听',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'broadcast',
eventName: 'broadcast_2',
args: {
job: '拯救世界'
},
description: '一个按钮的点击事件'
}
]
}
}
},
{
type: 'form',
id: 'form_001',
title: '表单1(我的权重最低)-刷新',
name: 'form1',
debug: true,
data: {
selfname: 'selfname' //
},
body: [
{
type: 'form',
id: 'form_001_form_01',
title: '表单1(我的权重最低)-刷新',
name: 'sub-form1',
debug: true,
body: [
{
type: 'input-text',
id: 'form_001_form_01_text_01',
label: '名称',
name: 'name',
disabled: false,
mode: 'horizontal'
},
{
type: 'input-text',
id: 'form_001_form_01_text_02',
label: '等级',
name: 'level',
disabled: false,
mode: 'horizontal'
},
{
type: 'input-text',
id: 'form_001_form_01_text_03',
label: '昵称',
name: 'myname',
disabled: false,
mode: 'horizontal'
}
],
onEvent: {
broadcast_1: {
actions: [
{
actionType: 'reload',
args: {
level: 1,
myname: '${event.data.name}', //
name: '${selfname}' //
},
preventDefault: true,
stopPropagation: false
}
]
}
}
}
]
},
{
type: 'form',
name: 'form2',
id: 'form_002',
title: '表单2(权重2)-刷新+发Ajax',
debug: true,
body: [
{
type: 'input-text',
id: 'form_001_text_01',
label: '年龄',
name: 'age',
disabled: false,
mode: 'horizontal'
}
],
data: {
expression: 'kkk',
param: '1'
},
onEvent: {
broadcast_1: {
weight: 2,
actions: [
{
actionType: 'reload',
args: {
age: '${event.data.age}'
},
preventDefault: false,
stopPropagation: false,
expression: 'expression === "kkk"' // or this.xxx
},
{
actionType: 'ajax',
args: {
param: '2'
},
api: 'https://api/form/form2-ajax?param=${param}', // param=2args
// api: 'https://api/form/form2-ajax?param=${name}', // param=lvxj
expression: 'expression === "kkk"',
preventDefault: false,
stopPropagation: false
},
{
actionType: 'broadcast',
eventName: 'broadcast_2',
args: {
job: '打怪兽'
},
description: '一个按钮的点击事件'
}
]
}
}
},
{
type: 'form',
name: 'form3',
id: 'form_003',
title: '表单3(权重3)-逻辑编排',
debug: true,
body: [
{
type: 'input-text',
id: 'form_003_text_01',
label: '职业',
name: 'job',
disabled: false,
mode: 'horizontal'
}
],
data: {
loopData: [
{
name: 'lv',
age: '19'
},
{
name: 'xj',
age: '21'
}
],
branchCont: 18
},
api: 'https://api/form/form3',
onEvent: {
broadcast_1: {
weight: 3,
actions: [
{
actionType: 'custom',
script:
"doAction({actionType: 'ajax',api: 'https://api/form/form3-custom-ajax-1'});\n //event.stopPropagation();"
}
]
},
broadcast_2: {
actions: [
{
actionType: 'reset-and-submit',
api: 'https://api/form/form3-reset-and-submit',
script: null, //
preventDefault: false,
stopPropagation: false
},
{
actionType: 'reload',
args: {
job: '${event.data.job}'
},
preventDefault: false,
stopPropagation: false
}
]
}
}
}
]
};

View File

@ -17,8 +17,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发点击事件'
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
},
@ -26,8 +28,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发鼠标移入事件'
args: {
msgType: 'info',
msg: '派发鼠标移入事件'
}
}
]
},
@ -35,8 +39,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发鼠标移出事件'
args: {
msgType: 'info',
msg: '派发鼠标移出事件'
}
}
]
}
@ -68,8 +74,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发点击事件'
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
@ -83,8 +91,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发点击事件'
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
@ -109,8 +119,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发点击事件'
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
@ -124,8 +136,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发点击事件'
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
@ -144,8 +158,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发点击事件'
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
@ -159,8 +175,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发点击事件'
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
@ -186,8 +204,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发点击事件'
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
@ -201,8 +221,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发点击事件'
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
}
@ -230,12 +252,14 @@ export default {
}
],
onEvent: {
click: {
change: {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发点击事件'
args: {
msgType: 'info',
msg: '派发点选事件'
}
}
]
}
@ -260,8 +284,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发点击事件'
args: {
msgType: 'info',
msg: '派发点击事件'
}
}
]
},
@ -269,8 +295,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发鼠标移入事件'
args: {
msgType: 'info',
msg: '派发鼠标移入事件'
}
}
]
},
@ -278,8 +306,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发鼠标移出事件'
args: {
msgType: 'info',
msg: '派发鼠标移出事件'
}
}
]
}

View File

@ -83,7 +83,9 @@ export default {
actions: [
{
actionType: 'toast',
msg: '${activeIndex}'
args: {
msg: '滚动至${event.data.activeIndex}'
}
}
]
}

View File

@ -1,502 +0,0 @@
export default {
type: 'page',
title: '触发通用动作',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'button',
id: 'b_001',
label: '发送Ajax请求',
onEvent: {
click: {
actions: [
{
actionType: 'ajax',
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm',
messages: {
success: '成功了!欧耶',
failed: '失败了呢。。'
}
}
]
}
}
},
{
type: 'button',
id: 'b_002',
className: 'ml-2',
label: '打开一个弹窗(模态)',
onEvent: {
click: {
actions: [
{
actionType: 'dialog',
dialog: {
type: 'dialog',
id: 'dialog_1',
title: '一个模态弹窗',
body: [
{
type: 'tpl',
tpl: '<p>对,你打开了一个模态弹窗</p>',
inline: false
}
]
}
}
]
}
}
},
{
type: 'button',
id: 'b_003',
label: '关闭一个弹窗(模态)',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'dialog',
dialog: {
type: 'dialog',
id: 'dialog_1',
title: '一个模态弹窗',
body: [
{
type: 'button',
label: '打开一个子弹窗,然后关闭它的父亲',
onEvent: {
click: {
actions: [
{
actionType: 'dialog',
dialog: {
type: 'dialog',
title: '一个模态子弹窗',
body: [
{
type: 'button',
label: '关闭指定弹窗(关闭父弹窗)',
onEvent: {
click: {
actions: [
{
actionType: 'closeDialog',
componentId: 'dialog_1'
}
]
}
}
}
]
}
}
]
}
}
},
{
type: 'button',
label: '关闭当前弹窗',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'closeDialog'
}
]
}
}
}
]
}
}
]
}
}
},
{
type: 'button',
id: 'b_004',
className: 'ml-2',
label: '打开一个抽屉(模态)',
onEvent: {
click: {
actions: [
{
actionType: 'drawer',
drawer: {
type: 'drawer',
id: 'drawer_1',
title: '一个模态抽屉',
body: [
{
type: 'tpl',
tpl: '<p>对,你打开了一个模态抽屉</p>',
inline: false
}
]
}
}
]
}
}
},
{
type: 'button',
id: 'b_005',
label: '关闭一个抽屉(模态)',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'drawer',
drawer: {
type: 'drawer',
id: 'drawer_1',
title: '一个模态抽屉',
body: [
{
type: 'button',
label: '打开一个子抽屉,然后关闭它的父亲',
onEvent: {
click: {
actions: [
{
actionType: 'drawer',
drawer: {
type: 'drawer',
title: '一个模态子抽屉',
body: [
{
type: 'button',
label: '关闭指定抽屉(关闭父抽屉)',
onEvent: {
click: {
actions: [
{
actionType: 'closeDrawer',
componentId: 'drawer_1'
}
]
}
}
}
]
}
}
]
}
}
},
{
type: 'button',
label: '关闭当前抽屉',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'closeDrawer'
}
]
}
}
}
]
}
}
]
}
}
},
{
type: 'button',
id: 'b_006',
label: '打开页面',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'url',
url: 'http://www.baidu.com',
blank: true
}
]
}
}
},
{
type: 'button',
id: 'b_007',
label: '打开页面(单页模式)',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'link',
link: './broadcat'
}
]
}
}
},
{
type: 'button',
id: 'b_008',
label: '弹个提示对话框(模态)',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'alert',
msg: '该吃饭了~'
}
]
}
}
},
{
type: 'button',
id: 'b_009',
label: '弹个确认对话框(模态)',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'confirmDialog',
title: '操作确认',
msg: '要删除它吗?'
}
]
}
}
},
{
type: 'button',
id: 'b_010',
label: '全局消息提示',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'toast',
msgType: 'warning',
msg: '我是一个全局警告消息,可以配置不同类型和弹出位置~',
options: {
position: 'top-right'
}
}
]
}
}
},
{
type: 'button',
id: 'b_011',
label: '复制一段文本',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'copy',
content: 'http://www.baidu.com'
}
]
}
}
},
{
type: 'button',
id: 'b_012',
label: '复制一段富文本',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'copy',
copyFormat: 'text/html',
content: "<a href='http://www.baidu.com'>link</a> <b>bold</b>"
}
]
}
}
},
{
type: 'button',
id: 'b_013',
label: '发送邮件',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'email',
to: 'amis@baidu.com',
cc: 'baidu@baidu.com',
subject: '这是邮件主题',
body: '这是邮件正文'
}
]
}
}
},
{
type: 'button',
id: 'b_018',
label: '刷新(一个表单)',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'reload',
componentId: 'form-reload'
}
]
}
}
},
{
type: 'button',
id: 'b_019',
label: '刷新(一个下拉框)',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'reload',
componentId: 'select-reload'
}
]
}
}
},
{
type: 'button',
id: 'b_014',
label: '显示',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'show',
componentId: 'input-text_001'
}
]
}
}
},
{
type: 'button',
id: 'b_015',
label: '隐藏',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'hidden',
componentId: 'input-text_001' // b_001
}
]
}
}
},
{
type: 'button',
id: 'b_016',
label: '禁用',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'disabled',
componentId: 'form_disable'
}
]
}
}
},
{
type: 'button',
id: 'b_017',
label: '启用',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'enabled',
componentId: 'form_disable'
}
]
}
}
},
{
label: '刷新下拉框',
type: 'select',
id: 'select-reload',
mode: 'horizontal',
className: 'm-t',
name: 'select',
source:
'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/getOptions?waitSeconds=1'
},
{
type: 'form',
id: 'form-reload',
name: 'form-reload',
initApi:
'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/page/initData',
title: '刷新表单',
body: [
{
type: 'input-text',
id: 'date-input-01',
name: 'date',
label: '时间戳'
}
]
},
{
type: 'input-text',
label: '控制显隐',
id: 'input-text_001',
mode: 'horizontal'
},
{
type: 'form',
id: 'form_disable',
title: '控制状态',
body: [
{
type: 'group',
body: [
{
type: 'button',
id: 'b_002',
className: 'ml-2',
label: '打开一个弹窗(模态)'
}
]
}
]
}
]
};

View File

@ -1,23 +0,0 @@
export default {
type: 'page',
title: '自定义JS',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'button',
label: '发送个请求',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'custom',
script:
"doAction({actionType: 'ajax',api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm'});\n //event.stopPropagation();"
}
]
}
}
}
]
};

View File

@ -1,111 +0,0 @@
export default {
type: 'page',
title: '数据传递',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'tpl',
tpl: '<p>从事件触发开始整个数据流包含事件本身产生的事件数据和动作产生的动作数据事件源头产生的数据在AMIS事件动作机制底层已经自动加入渲染器数据域可以通过"event.data.xxx"直接获取而部分动作产生的数据如何流动需要交互设计者进行介入对于数据流动可以通过数据映射将上一个动作产生的数据作为动作参数写入下一个动作。通过outputVar指定输出的变量名通过args指定输入的参数数据</p>'
},
{
type: 'button',
id: 'b_001',
label: '发一个广播携带args参数',
onEvent: {
click: {
actions: [
{
actionType: 'broadcast',
eventName: 'broadcast_1',
args: {
name: 'lvxj',
age: 18
},
description: '一个按钮的点击事件'
}
]
}
}
},
{
type: 'button',
id: 'b_001',
label: '发送Ajax请求并把返回数据传给弹窗',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'ajax',
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm',
messages: {
success: '成功了!欧耶',
failed: '失败了呢。。'
},
outputVar: 'ajax1'
},
{
actionType: 'dialog',
args: {
id: '${event.data.ajax1.id}'
},
dialog: {
type: 'dialog',
id: 'dialog_1',
title: '弹框标题1',
data: {
id: '${id}'
},
body: [
{
type: 'form',
debug: true,
body: [
{
type: 'tpl',
tpl: '<p>Ajax请求返回的id=${id}</p>',
inline: false
}
]
}
]
}
}
]
}
}
},
{
type: 'form',
name: 'form1',
id: 'form_001',
title: '表单1-监听广播并获取携带的参数',
debug: true,
body: [
{
type: 'input-text',
id: 'form_001_text_01',
label: '年龄',
name: 'age',
disabled: false,
mode: 'horizontal'
}
],
data: {
name: 'amis'
},
onEvent: {
broadcast_1: {
actions: [
{
actionType: 'reload',
args: {
age: '${event.data.age}'
}
}
]
}
}
}
]
};

View File

@ -119,21 +119,9 @@ export default {
change: {
actions: [
{
actionType: 'dialog',
actionType: 'toast',
args: {
val: '${event.data}'
},
dialog: {
title: '触发表单change事件',
data: {
val: '${val}'
},
body: [
{
type: 'tpl',
tpl: '值更新:${val|json}'
}
]
msg: '${event.data|json}'
}
}
]
@ -141,21 +129,9 @@ export default {
inited: {
actions: [
{
actionType: 'dialog',
actionType: 'toast',
args: {
val: '${event.data}'
},
dialog: {
title: '触发表单init事件',
data: {
val: '${val}'
},
body: [
{
type: 'tpl',
tpl: '表单初始化数据:${val|json}'
}
]
msg: '${event.data|json}'
}
}
]
@ -163,21 +139,9 @@ export default {
formItemValidateSucc: {
actions: [
{
actionType: 'dialog',
actionType: 'toast',
args: {
val: '${event.data}'
},
dialog: {
title: '触发表单项校验成功事件',
data: {
val: '${val}'
},
body: [
{
type: 'tpl',
tpl: '当前表单数据:${val|json}'
}
]
msg: '${event.data|json}'
}
}
]
@ -185,21 +149,9 @@ export default {
formItemValidateError: {
actions: [
{
actionType: 'dialog',
actionType: 'toast',
args: {
val: '${event.data}'
},
dialog: {
title: '触发表单项校验失败事件',
data: {
val: '${val}'
},
body: [
{
type: 'tpl',
tpl: '当前表单数据:${val|json}'
}
]
msg: '${event.data|json}'
}
}
]
@ -207,21 +159,9 @@ export default {
validateSucc: {
actions: [
{
actionType: 'dialog',
actionType: 'toast',
args: {
val: '${event.data}'
},
dialog: {
title: '触发表单校验成功事件',
data: {
val: '${val}'
},
body: [
{
type: 'tpl',
tpl: '当前表单数据:${val|json}'
}
]
msg: '${event.data|json}'
}
}
]
@ -229,21 +169,9 @@ export default {
validateFail: {
actions: [
{
actionType: 'dialog',
actionType: 'toast',
args: {
val: '${event.data}'
},
dialog: {
title: '触发表单校验失败事件',
data: {
val: '${val}'
},
body: [
{
type: 'tpl',
tpl: '当前表单数据:${val|json}'
}
]
msg: '${event.data|json}'
}
}
]
@ -251,21 +179,9 @@ export default {
submitSucc: {
actions: [
{
actionType: 'dialog',
actionType: 'toast',
args: {
val: '${event.data}'
},
dialog: {
title: '触发表单提交成功事件',
data: {
val: '${val}'
},
body: [
{
type: 'tpl',
tpl: '保存接口返回内容:${val|json}'
}
]
msg: '${event.data|json}'
}
}
]
@ -273,21 +189,9 @@ export default {
submitFail: {
actions: [
{
actionType: 'dialog',
actionType: 'toast',
args: {
val: '${event.data}'
},
dialog: {
title: '触发表单提交失败事件',
data: {
val: '${val}'
},
body: [
{
type: 'tpl',
tpl: '保存接口返回内容:${val|json}'
}
]
msg: '${event.data|json}'
}
}
]
@ -328,21 +232,9 @@ export default {
formItemValidateSucc: {
actions: [
{
actionType: 'dialog',
actionType: 'toast',
args: {
val: '${event.data}'
},
dialog: {
title: '触发表单项校验成功事件',
data: {
val: '${val}'
},
body: [
{
type: 'tpl',
tpl: '当前表单数据:${val|json}'
}
]
msg: '${event.data|json}'
}
}
]
@ -350,21 +242,9 @@ export default {
formItemValidateError: {
actions: [
{
actionType: 'dialog',
actionType: 'toast',
args: {
val: '${event.data}'
},
dialog: {
title: '触发表单项校验失败事件',
data: {
val: '${val}'
},
body: [
{
type: 'tpl',
tpl: '当前表单数据:${val|json}'
}
]
msg: '${event.data|json}'
}
}
]

View File

@ -34,8 +34,10 @@ export default {
},
{
actionType: 'toast',
msgType: 'info',
msg: '派发clear事件'
args: {
msgType: 'info',
msg: '派发clear事件'
}
}
]
}
@ -71,8 +73,10 @@ export default {
},
{
actionType: 'toast',
msgType: 'info',
msg: '派发focus事件'
args: {
msgType: 'info',
msg: '派发focus事件'
}
}
]
}
@ -123,8 +127,10 @@ export default {
},
{
actionType: 'toast',
msgType: 'info',
msg: '派发clear事件'
args: {
msgType: 'info',
msg: '派发clear事件'
}
}
]
}
@ -160,8 +166,10 @@ export default {
},
{
actionType: 'toast',
msgType: 'info',
msg: '派发focus事件'
args: {
msgType: 'info',
msg: '派发focus事件'
}
}
]
}
@ -207,7 +215,7 @@ export default {
actionType: 'clear',
componentId: 'clear-input-number-receiver',
description: '点击清空指定输入框的内容'
},
}
]
}
}
@ -223,8 +231,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发blur事件'
args: {
msgType: 'info',
msg: '派发blur事件'
}
}
]
},
@ -232,8 +242,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发focus事件'
args: {
msgType: 'info',
msg: '派发focus事件'
}
}
]
},
@ -241,8 +253,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发change事件'
args: {
msgType: 'info',
msg: '派发change事件'
}
}
]
}
@ -287,8 +301,10 @@ export default {
},
{
actionType: 'toast',
msgType: 'info',
msg: '派发focus事件'
args: {
msgType: 'info',
msg: '派发focus事件'
}
}
]
}
@ -326,8 +342,10 @@ export default {
},
{
actionType: 'toast',
msgType: 'info',
msg: '派发focus事件'
args: {
msgType: 'info',
msg: '派发focus事件'
}
}
]
}

View File

@ -29,7 +29,7 @@ export default {
actionType: 'clear',
componentId: 'clear-input-number-receiver',
description: '点击清空指定输入框的内容'
},
}
]
}
}
@ -45,8 +45,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发blur事件'
args: {
msgType: 'info',
msg: '派发blur事件'
}
}
]
},
@ -54,8 +56,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发focus事件'
args: {
msgType: 'info',
msg: '派发focus事件'
}
}
]
},
@ -63,8 +67,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发change事件'
args: {
msgType: 'info',
msg: '派发change事件'
}
}
]
}

View File

@ -14,8 +14,8 @@ export default {
debug: true,
body: [
{
name: "input-rating-clear",
type: "action",
name: 'input-rating-clear',
type: 'action',
label: 'clear触发器',
level: 'primary',
onEvent: {
@ -40,16 +40,18 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发change事件'
args: {
msgType: 'info',
msg: '派发change事件'
}
}
]
}
}
},
{
name: "input-rating-reset",
type: "action",
name: 'input-rating-reset',
type: 'action',
label: 'reset触发器',
level: 'primary',
onEvent: {
@ -75,8 +77,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发change事件'
args: {
msgType: 'info',
msg: '派发change事件'
}
}
]
}

View File

@ -8,8 +8,8 @@ export default {
debug: true,
body: [
{
name: "input-tree-clear",
type: "action",
name: 'input-tree-clear',
type: 'action',
label: 'clear触发器',
level: 'primary',
className: 'mr-3',
@ -26,8 +26,8 @@ export default {
}
},
{
name: "input-tree-reset",
type: "action",
name: 'input-tree-reset',
type: 'action',
label: 'reset触发器',
level: 'primary',
className: 'mr-3',
@ -44,8 +44,8 @@ export default {
}
},
{
name: "input-tree-expand",
type: "action",
name: 'input-tree-expand',
type: 'action',
label: 'expand触发器openLevel: 1',
level: 'primary',
className: 'mr-3',
@ -56,15 +56,17 @@ export default {
actionType: 'expand',
componentId: 'input-tree-action',
description: '点击展开',
openLevel: 1
args: {
openLevel: 1
}
}
]
}
}
},
{
name: "input-tree-collapse",
type: "action",
name: 'input-tree-collapse',
type: 'action',
label: 'collapse触发器',
level: 'primary',
className: 'mr-3',
@ -131,8 +133,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发change事件'
args: {
msgType: 'info',
msg: '派发change事件'
}
}
]
},
@ -149,8 +153,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发edit事件'
args: {
msgType: 'info',
msg: '派发edit事件'
}
}
]
},
@ -158,8 +164,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发delete事件'
args: {
msgType: 'info',
msg: '派发delete事件'
}
}
]
},
@ -167,8 +175,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发loadFinished事件'
args: {
msgType: 'info',
msg: '派发loadFinished事件'
}
}
]
}

View File

@ -1,191 +0,0 @@
export default {
type: 'page',
title: '逻辑编排',
regions: ['body', 'toolbar', 'header'],
body: {
type: 'form',
data: {
loopData: [
{
name: 'lv',
age: '19'
},
{
name: 'xj',
age: '21'
}
],
branchCont: 18,
expression: 'kkk'
},
body: [
{
type: 'button',
id: 'b_001',
label: '条件',
onEvent: {
click: {
actions: [
{
actionType: 'ajax',
args: {
param: '0'
},
api: 'https://api/form/ajax?param=${param}', // param=2args
expression: 'expression === "kkk"'
},
{
actionType: 'ajax',
args: {
param: '1'
},
api: 'https://api/form/ajax?param=${param}', // param=2args
expression: 'expression === "jjj"'
},
{
actionType: 'ajax',
args: {
param: '2'
},
api: 'https://api/form/ajax?param=${param}', // param=2args
expression: 'expression === "kkk"'
}
]
}
}
},
{
type: 'button',
id: 'b_002',
label: '并行',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'parallel',
children: [
{
actionType: 'ajax',
api: 'https://api/form/parallel-ajax-1',
preventDefault: false
// stopPropagation: true
},
{
actionType: 'ajax',
api: 'https://api/form/parallel-ajax-2'
}
]
}
]
}
}
},
{
type: 'button',
id: 'b_003',
label: '循环',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'loop',
loopName: 'loopData',
preventDefault: false,
stopPropagation: false,
args: {
level: 3
},
children: [
{
actionType: 'reload',
preventDefault: false,
stopPropagation: false
},
{
actionType: 'ajax',
api: 'https://api/form/loop-ajax-1?name=${name}',
preventDefault: false,
stopPropagation: false
},
// {
// actionType: 'break'
// },
{
actionType: 'ajax',
api: 'https://api/form/loop-ajax-2?age=${age}'
},
{
actionType: 'loop',
loopName: 'loopData',
args: {
level: 3
},
children: [
{
actionType: 'ajax',
api: 'https://api/form/loop-loop-ajax-1'
},
{
actionType: 'ajax',
api: 'https://api/form/loop-loop-ajax-2?age=${age}',
preventDefault: false,
stopPropagation: false
},
{
actionType: 'continue'
},
{
actionType: 'ajax',
api: 'https://api/form/loop-loop-ajax-3'
}
]
}
]
}
]
}
}
},
{
type: 'button',
id: 'b_004',
label: 'switch排他',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'switch',
preventDefault: false,
stopPropagation: false,
children: [
{
actionType: 'ajax',
api: 'https://api/form/branch-ajax-1',
expression: 'this.branchCont > 19',
preventDefault: false,
stopPropagation: true //
},
{
actionType: 'ajax',
api: 'https://api/form/branch-ajax-2',
expression: 'this.branchCont > 17',
preventDefault: false,
stopPropagation: false
},
{
actionType: 'ajax',
api: 'https://api/form/branch-ajax-3',
expression: 'this.branchCont > 16'
}
]
}
]
}
}
}
]
}
};

View File

@ -2,8 +2,10 @@ const change = {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发change事件'
args: {
msgType: 'info',
msg: '派发change事件'
}
}
]
};
@ -12,8 +14,10 @@ const blur = {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发blur事件'
args: {
msgType: 'info',
msg: '派发blur事件'
}
}
]
};
@ -22,8 +26,10 @@ const focus = {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发focus事件'
args: {
msgType: 'info',
msg: '派发focus事件'
}
}
]
};

View File

@ -37,8 +37,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'success',
msg: 'API inited: <b>${date}</b>'
args: {
msgType: 'success',
msg: 'API inited: <b>${event.data.date}</b>'
}
}
]
}
@ -73,8 +75,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: 'SchemaAPI inited: <b>title: ${title}</b>'
args: {
msgType: 'info',
msg: 'SchemaAPI inited: <b>title: ${event.data.title}</b>'
}
}
]
}
@ -195,7 +199,9 @@ export default {
{
actionType: 'setValue',
componentId: 'service-setvalue',
value: {language: ['🇨🇳 中国']}
args: {
value: {language: ['🇨🇳 中国']}
}
}
]
}

View File

@ -1,130 +0,0 @@
export default {
type: 'page',
title: '事件/动作干预',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'button',
id: 'b_001',
label: '联动表单1(事件干预)',
onEvent: {
click: {
actions: [
{
actionType: 'broadcast',
eventName: 'broadcast_1',
args: {
name: 'lvxj',
age: 18
},
description: '一个按钮的点击事件'
}
]
}
}
},
{
type: 'button',
id: 'b_002',
label: '联动表单2(动作干预)',
className: 'ml-2',
onEvent: {
click: {
actions: [
{
actionType: 'broadcast',
eventName: 'broadcast_1',
args: {
name: 'lvxj',
age: 18
},
description: '一个按钮的点击事件'
}
]
}
}
},
{
type: 'form',
name: 'form1',
id: 'form_001',
title: '表单1-刷新(刷新后,按钮的弹窗动作因为被干预,不会执行)',
debug: true,
body: [
{
type: 'input-text',
id: 'form_001_text_01',
label: '年龄',
name: 'age',
disabled: false,
mode: 'horizontal'
}
],
data: {
expression: 'kkk',
param: '1'
},
onEvent: {
broadcast_1: {
actions: [
{
actionType: 'reload',
args: {
age: '${event.data.age}'
},
preventDefault: true, //
expression: 'expression === "kkk"' // or this.xxx
}
]
}
}
},
{
type: 'form',
name: 'form2',
id: 'form_002',
title: '表单2-刷新+发Ajax只执行刷新Ajax请求被干预不会执行',
debug: true,
body: [
{
type: 'input-text',
id: 'form_001_text_01',
label: '年龄',
name: 'age',
disabled: false,
mode: 'horizontal'
}
],
data: {
expression: 'kkk',
param: '1'
},
onEvent: {
broadcast_1: {
actions: [
{
actionType: 'reload',
args: {
age: '${event.data.age}'
},
preventDefault: false, //
stopPropagation: true,
expression: 'expression === "kkk"' // or this.xxx
},
{
actionType: 'ajax',
args: {
param: '2'
},
api: 'https://api/form/ajax?param=${param}', // param=2args
expression: 'expression === "kkk"',
preventDefault: false,
stopPropagation: false
}
]
}
}
}
]
};

View File

@ -14,16 +14,18 @@ export default {
debug: true,
body: [
{
name: "switch",
type: "switch",
option: "开关事件",
name: 'switch',
type: 'switch',
option: '开关事件',
onEvent: {
change: {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发change事件'
args: {
msgType: 'info',
msg: '派发change事件'
}
}
]
}

View File

@ -16,7 +16,9 @@ export default {
{
actionType: 'changeActiveKey',
componentId: 'tabs-change-receiver',
activeKey: 0
args: {
activeKey: 0
}
}
]
}
@ -35,7 +37,9 @@ export default {
{
actionType: 'changeActiveKey',
componentId: 'tabs-change-receiver',
activeKey: 1
args: {
activeKey: 1
}
}
]
}
@ -86,8 +90,10 @@ export default {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发change事件'
args: {
msgType: 'info',
msg: '更新至${event.data.value}'
}
}
]
}

View File

@ -3,8 +3,10 @@ const getEventDesc = eventName => {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: `派发${eventName}事件`
args: {
msgType: 'info',
msg: `派发${eventName}事件`
}
}
]
};

View File

@ -1,6 +1,6 @@
const wizardSchema = {
type: 'wizard',
initApi: '/api/mock2/form/initForm',
initApi: '/api/mock2/form/initData',
steps: [
{
title: '第一步',
@ -34,7 +34,7 @@ const wizardSchema = {
name: 'name'
}
],
initApi: '/api/mock2/form/initForm',
initApi: '/api/mock2/form/initData',
api: '/api/mock2/form/saveForm?waitSeconds=2'
},
{
@ -52,8 +52,10 @@ function generateEventAcions(events) {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: `派发 ${event} 事件`
args: {
msgType: 'info',
msg: `派发 ${event} 事件,数据:` + '${event.data|json}'
}
}
]
};

View File

@ -1,4 +1,3 @@
const options = [
{
label: 'Folder A',
@ -33,15 +32,17 @@ const options = [
label: 'file D',
value: 5
}
]
];
const onEvent = {
blur: {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发blur事件'
args: {
msgType: 'info',
msg: '派发blur事件'
}
}
]
},
@ -49,8 +50,10 @@ const onEvent = {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发focus事件'
args: {
msgType: 'info',
msg: '派发focus事件'
}
}
]
},
@ -58,8 +61,10 @@ const onEvent = {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发change事件'
args: {
msgType: 'info',
msg: '派发change事件'
}
}
]
},
@ -76,8 +81,10 @@ const onEvent = {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发edit事件'
args: {
msgType: 'info',
msg: '派发edit事件'
}
}
]
},
@ -85,8 +92,10 @@ const onEvent = {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发delete事件'
args: {
msgType: 'info',
msg: '派发delete事件'
}
}
]
},
@ -94,12 +103,14 @@ const onEvent = {
actions: [
{
actionType: 'toast',
msgType: 'info',
msg: '派发loadFinished事件'
args: {
msgType: 'info',
msg: '派发loadFinished事件'
}
}
]
}
}
};
export default {
type: 'page',
@ -111,8 +122,8 @@ export default {
debug: true,
body: [
{
name: "tree-select-clear",
type: "action",
name: 'tree-select-clear',
type: 'action',
label: 'clear触发器',
level: 'primary',
className: 'mr-3',
@ -129,8 +140,8 @@ export default {
}
},
{
name: "tree-select-reset",
type: "action",
name: 'tree-select-reset',
type: 'action',
label: 'reset触发器',
level: 'primary',
className: 'mr-3',

View File

@ -66,12 +66,6 @@ import CRUDLinkPageSchema from './Linkage/CRUD';
import OptionsPageSchema from './Linkage/Options';
import OptionsLocalPageSchema from './Linkage/OptionsLocal';
import FormSubmitSchema from './Linkage/FormSubmit';
import CommonEventActionSchema from './EventAction/Common';
import BroadcastEventActionSchema from './EventAction/Broadcast';
import CustomEventActionSchema from './EventAction/Custom';
import LogicEventActionSchema from './EventAction/Logic';
import StopEventActionSchema from './EventAction/Stop';
import DataFlowEventActionSchema from './EventAction/DataFlow';
import InputEventSchema from './EventAction/InputEvent';
import DateEventSchema from './EventAction/DateEvent';
import SwitchEventSchema from './EventAction/SwitchEvent';
@ -528,16 +522,6 @@ export const examples = [
label: '事件动作机制',
icon: 'fa fa-bullhorn',
children: [
{
label: '执行通用动作',
path: '/examples/event-action/common',
component: makeSchemaRenderer(CommonEventActionSchema)
},
{
label: '广播(自定义事件)',
path: '/examples/event-action/broadcat',
component: makeSchemaRenderer(BroadcastEventActionSchema)
},
{
label: '执行其他组件动作',
children: [
@ -622,26 +606,6 @@ export const examples = [
component: makeSchemaRenderer(ServiceEventSchema)
}
]
},
{
label: '自定义JS',
path: '/examples/event-action/custom',
component: makeSchemaRenderer(CustomEventActionSchema)
},
{
label: '执行逻辑编排动作',
path: '/examples/event-action/logic',
component: makeSchemaRenderer(LogicEventActionSchema)
},
{
label: '事件/动作干预',
path: '/examples/event-action/stop',
component: makeSchemaRenderer(StopEventActionSchema)
},
{
label: '动作间数据传递',
path: '/examples/event-action/dataflow',
component: makeSchemaRenderer(DataFlowEventActionSchema)
}
]
},

View File

@ -1,9 +1,9 @@
import omit from 'lodash/omit';
import {Api} from '../types';
import {normalizeApiResponseData} from '../utils/api';
import {ServerError} from '../utils/errors';
import {createObject, isEmpty, isVisible} from '../utils/helper';
import {createObject, isEmpty} from '../utils/helper';
import {RendererEvent} from '../utils/renderer-event';
import {filter} from '../utils/tpl';
import {
RendererAction,
ListenerAction,
@ -12,12 +12,15 @@ import {
} from './Action';
export interface IAjaxAction extends ListenerAction {
api: Api;
messages: {
success: string;
failed: string;
args: {
api: Api;
messages: {
success: string;
failed: string;
};
options: object;
[propName: string]: any;
};
options: object;
}
/**
@ -33,17 +36,21 @@ export class AjaxAction implements RendererAction {
renderer: ListenerContext,
event: RendererEvent<any>
) {
if (!renderer.props.env?.fetcher) {
throw new Error('env.fetcher is required!');
}
const env = event.context.env;
try {
const result = await env.fetcher(
action.api as string,
action.args,
action.options ?? {}
action.args?.api as string,
omit(action.args ?? {}, ['api', 'options', 'messages']),
action.args?.options ?? {}
);
if (!isEmpty(result.data) || result.ok) {
const responseData = normalizeApiResponseData(result.data);
// 记录请求返回的数据
// 记录请求返回的数据
event.setData(
createObject(
event.data,
@ -58,20 +65,22 @@ export class AjaxAction implements RendererAction {
if (!result.ok) {
throw new ServerError(
(action.messages && action.messages.failed) ?? result.msg,
action.args?.messages?.failed ?? result.msg,
result
);
} else {
env.notify(
'success',
(action.messages && action.messages.success) ?? result.msg,
result.msgTimeout !== undefined
? {
closeButton: true,
timeout: result.msgTimeout
}
: undefined
);
const msg = action.args?.messages?.success ?? result.msg;
msg &&
env.notify(
'success',
msg,
result.msgTimeout !== undefined
? {
closeButton: true,
timeout: result.msgTimeout
}
: undefined
);
}
return result.data;

View File

@ -26,7 +26,7 @@ export class BroadcastAction implements RendererAction {
event: RendererEvent<any>
) {
if (!action.eventName) {
console.warn('eventName 未定义,请定义事件名称');
console.error('eventName 未定义,请定义事件名称');
return;
}

View File

@ -49,11 +49,10 @@ export class CmptAction implements RendererAction {
// 数据更新
if (action.actionType === 'setValue') {
const value = dataMapping(action.value, event.data);
if (component.setData) {
return component.setData(value);
return component.setData(action.args?.value);
} else {
return component.props.onChange?.(value);
return component.props.onChange?.(action.args?.value);
}
}

View File

@ -4,13 +4,15 @@ import {
RendererAction,
ListenerAction,
ListenerContext,
LoopStatus,
registerAction
} from './Action';
export interface ICopyAction extends ListenerAction {
content: string;
copyFormat?: string;
args: {
content: string;
copyFormat?: string;
[propName: string]: any;
};
}
/**
@ -26,9 +28,13 @@ export class CopyAction implements RendererAction {
renderer: ListenerContext,
event: RendererEvent<any>
) {
if (action.content) {
renderer.props.env.copy?.(filter(action.content, action.args, '| raw'), {
format: action.copyFormat
if (!renderer.props.env?.copy) {
throw new Error('env.copy is required!');
}
if (action.args?.content) {
renderer.props.env.copy?.(action.args.content, {
format: action.args?.copyFormat ?? 'text/html'
});
}
}

View File

@ -8,12 +8,18 @@ import {
} from './Action';
export interface IAlertAction extends ListenerAction {
msg: string;
args: {
msg: string;
[propName: string]: any;
};
}
export interface IConfirmAction extends ListenerAction {
title: string;
msg: string;
args: {
title: string;
msg: string;
[propName: string]: any;
};
}
export interface IDialogAction extends ListenerAction {
@ -76,7 +82,7 @@ export class AlertAction implements RendererAction {
renderer: ListenerContext,
event: RendererEvent<any>
) {
event.context.env.alert?.(action.msg);
event.context.env.alert?.(action.args?.msg);
}
}
@ -89,7 +95,7 @@ export class ConfirmAction implements RendererAction {
renderer: ListenerContext,
event: RendererEvent<any>
) {
event.context.env.confirm?.(action.msg, action.title);
event.context.env.confirm?.(action.args?.msg, action.args?.title);
}
}

View File

@ -11,11 +11,14 @@ import {
} from './Action';
export interface IEmailAction extends ListenerAction {
to: string;
cc: string;
bcc: string;
subject: string;
body: string;
args: {
to: string;
cc: string;
bcc: string;
subject: string;
body: string;
[propName: string]: any;
};
}
/**
@ -31,11 +34,8 @@ export class EmailAction implements RendererAction {
renderer: ListenerContext,
event: RendererEvent<any>
) {
const mailTo = filter(action.to, action.args);
const mailInfo = mapValues(
pick(action, 'cc', 'bcc', 'subject', 'body'),
val => filter(val, action.args)
);
const mailTo = action.args?.to;
const mailInfo = pick(action.args ?? {}, 'cc', 'bcc', 'subject', 'body');
const mailStr = qs.stringify(mailInfo);
const mailto = `mailto:${mailTo}?${mailStr}`;

View File

@ -3,6 +3,7 @@ import {buildApi} from '../utils/api';
import {isEmpty, isObject, qsstringify} from '../utils/helper';
import {RendererEvent} from '../utils/renderer-event';
import {filter} from '../utils/tpl';
import omit from 'lodash/omit';
import {
RendererAction,
ListenerAction,
@ -11,20 +12,26 @@ import {
} from './Action';
export interface ILinkAction extends ListenerAction {
link: string;
url?: never;
blank?: boolean;
params?: {
[key: string]: string;
args: {
link: string;
url?: never;
blank?: boolean;
params?: {
[key: string]: string;
};
[propName: string]: any;
};
}
export interface IUrlAction extends ListenerAction {
url: string;
link?: never;
blank?: boolean;
params?: {
[key: string]: string;
args: {
url: string;
link?: never;
blank?: boolean;
params?: {
[key: string]: string;
};
[propName: string]: any;
};
}
@ -37,7 +44,7 @@ export interface IUrlAction extends ListenerAction {
*/
export class LinkAction implements RendererAction {
async run(
action: ILinkAction | IUrlAction,
action: ListenerAction,
renderer: ListenerContext,
event: RendererEvent<any>
) {
@ -48,16 +55,26 @@ export class LinkAction implements RendererAction {
// 通过buildApi兼容较复杂的url情况
let urlObj = buildApi(
{
url: (action.url || action.link) as string,
url: (action.args?.url || action.args?.link) as string,
method: 'get'
},
{...action.params, ...action.args},
{
...(action.args?.params ?? {}),
...omit(action.args ?? {}, ['params', 'blank', 'url', 'link'])
},
{
autoAppend: true
}
);
renderer.props.env.jumpTo(urlObj.url, action as Action, action.args);
renderer.props.env.jumpTo(
urlObj.url,
{
actionType: action.actionType,
...action.args
},
action.args
);
}
}

View File

@ -13,7 +13,10 @@ import {
import {resolveVariable} from '../utils/tpl-builtin';
export interface ILoopAction extends ListenerAction, LogicAction {
loopName: string;
args: {
loopName: string;
[propName: string]: any;
};
}
/**
@ -30,18 +33,19 @@ export class LoopAction implements RendererAction {
event: RendererEvent<any>,
mergeData: any
) {
if (typeof action.loopName !== 'string') {
console.warn('loopName 必须是字符串类型');
const loopName = action.args?.loopName;
if (typeof loopName !== 'string') {
console.error('loopName 必须是字符串类型');
return;
}
const loopData = resolveVariable(action.loopName, mergeData) || [];
const loopData = resolveVariable(loopName, mergeData) || [];
// 必须是数组
if (!loopData) {
console.warn(`没有找到数据 ${action.loopName}`);
console.error(`没有找到数据 ${loopName}`);
} else if (!Array.isArray(loopData)) {
console.warn(`${action.loopName} 数据不是数组`);
console.error(`${loopName} 数据不是数组`);
} else if (action.children?.length) {
// 暂存一下
const protoData = event.data;
@ -62,6 +66,7 @@ export class LoopAction implements RendererAction {
if (renderer.loopStatus === LoopStatus.BREAK || event.stoped) {
// 还原事件数据
event.setData(protoData);
event.stopPropagation();
break;
}
}

View File

@ -7,7 +7,10 @@ import {
} from './Action';
export interface IPageGoAction extends ListenerAction {
delta?: number;
args: {
delta?: number;
[propName: string]: any;
};
}
/**
@ -40,7 +43,7 @@ export class PageGoAction implements RendererAction {
renderer: ListenerContext,
event: RendererEvent<any>
) {
window.history.go(action.delta || 0);
window.history.go(action.args?.delta || 0);
}
}

View File

@ -32,8 +32,15 @@ export class ToastAction implements RendererAction {
renderer: ListenerContext,
event: RendererEvent<any>
) {
const msg = resolveVariableAndFilter(action.msg, action.args, '| raw');
event.context.env.notify?.(action.msgType || 'info', String(msg), action);
if (!renderer.props.env?.notify) {
throw new Error('env.notify is required!');
}
event.context.env.notify?.(
action.args?.msgType || 'info',
String(action.args?.msg),
action.args
);
}
}

View File

@ -122,7 +122,7 @@ export default class TreeControl extends React.Component<TreeProps> {
onChange && onChange(resetValue ?? '');
}
if (action.actionType === 'expand') {
this.treeRef.syncUnFolded(this.props, action.openLevel);
this.treeRef.syncUnFolded(this.props, action.args.openLevel);
}
if (action.actionType === 'collapse') {
this.treeRef.syncUnFolded(this.props, 0);

View File

@ -648,7 +648,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
const previous = store.data;
const final = {...previous, ...values};
if (await this.dispatchEvent('change', {formData: final})) {
if (await this.dispatchEvent('change', final)) {
return;
}
@ -692,7 +692,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
onFinished
} = this.props;
if (await this.dispatchEvent('finished', {formData: store.data})) {
if (await this.dispatchEvent('finished', store.data)) {
return;
}
@ -719,7 +719,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
formStore
.saveRemote(action.api || step.api || api!, store.data, {
onSuccess: () => {
this.dispatchEvent('submitSucc', {formData: store.data});
this.dispatchEvent('submitSucc', store.data);
if (
!isEffectiveApi(finnalAsyncApi, store.data) ||