amis/examples/components/EventAction/Stop.jsx
hsm-lv 8cc8283ded
feat:补充一些通用动作&完善事件动作机制示例 (#3495)
* feat:补充一些通用动作&完善事件动作机制示例

* feat:补充一些通用动作&完善事件动作机制示例
2022-01-26 09:18:48 +08:00

141 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export default {
type: 'page',
title: '事件/动作干预',
regions: ['body', 'toolbar', 'header'],
body: [
{
type: 'button',
id: 'b_001',
label: '联动表单1(事件干预)',
actionType: 'dialog',
dialog: {
title: '系统提示',
body: '对你点击了'
},
onEvent: {
click: {
actions: [
{
actionType: 'broadcast',
eventName: 'broadcast_1',
args: {
name: 'lvxj',
age: 18
},
description: '一个按钮的点击事件'
}
]
}
}
},
{
type: 'button',
id: 'b_002',
label: '联动表单2(动作干预)',
className: 'ml-2',
actionType: 'dialog',
dialog: {
title: '系统提示',
body: '对你点击了'
},
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: {
execOn: 'kkk',
param: '1'
},
onEvent: {
broadcast_1: {
actions: [
{
actionType: 'reload',
args: {
age: '${event.data.age}'
},
preventDefault: true, // 阻止按钮的弹窗
execOn: 'execOn === "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: {
execOn: 'kkk',
param: '1'
},
onEvent: {
broadcast_1: {
actions: [
{
actionType: 'reload',
args: {
age: '${event.data.age}'
},
preventDefault: false, // 阻止按钮的弹窗
stopPropagation: true,
execOn: 'execOn === "kkk"' // or this.xxx
},
{
actionType: 'ajax',
args: {
param: '2'
},
api: 'https://api/form/ajax?param=${param}', // param=2如果想要拿到当前域的数据需要通过args数据映射
execOn: 'execOn === "kkk"',
preventDefault: false,
stopPropagation: false
}
]
}
}
}
]
};