amis/examples/components/EventAction/Stop.jsx

141 lines
3.3 KiB
React
Raw Normal View History

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
}
]
}
}
}
]
};